mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
pyrofork: Add trigger and watch emoji animations in send_chat_action and reply_chat_action
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
51b006cc69
commit
eae031f79a
3 changed files with 66 additions and 3 deletions
|
|
@ -71,3 +71,9 @@ class ChatAction(AutoName):
|
||||||
|
|
||||||
CANCEL = raw.types.SendMessageCancelAction
|
CANCEL = raw.types.SendMessageCancelAction
|
||||||
"Cancel ongoing chat action"
|
"Cancel ongoing chat action"
|
||||||
|
|
||||||
|
TRIGGER_EMOJI_ANIMATION = raw.types.SendMessageEmojiInteraction
|
||||||
|
"User has clicked on an animated emoji triggering a `reaction <https://core.telegram.org/api/animated-emojis#emoji-reactions>`_"
|
||||||
|
|
||||||
|
WATCH_EMOJI_ANIMATION = raw.types.SendMessageEmojiInteractionSeen
|
||||||
|
"The user is watching animations sent by the other party by clicking on an animated emoji"
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from json import dumps
|
||||||
|
from random import randint
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
|
|
@ -29,7 +31,9 @@ class SendChatAction:
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
action: "enums.ChatAction",
|
action: "enums.ChatAction",
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
business_connection_id: str = None
|
business_connection_id: str = None,
|
||||||
|
emoji: str = None,
|
||||||
|
emoji_message_id: int = None
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Tell the other party that something is happening on your side.
|
"""Tell the other party that something is happening on your side.
|
||||||
|
|
||||||
|
|
@ -53,6 +57,12 @@ class SendChatAction:
|
||||||
Business connection identifier.
|
Business connection identifier.
|
||||||
for business bots only.
|
for business bots only.
|
||||||
|
|
||||||
|
emoji (``str``, *optional*):
|
||||||
|
The animated emoji. Only supported for :obj:`~pyrogram.enums.ChatAction.TRIGGER_EMOJI_ANIMATION` and :obj:`~pyrogram.enums.ChatAction.WATCH_EMOJI_ANIMATION`.
|
||||||
|
|
||||||
|
emoji_message_id (``int``, *optional*):
|
||||||
|
Message identifier of the message containing the animated emoji. Only supported for :obj:`~pyrogram.enums.ChatAction.TRIGGER_EMOJI_ANIMATION`.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
``bool``: On success, True is returned.
|
``bool``: On success, True is returned.
|
||||||
|
|
||||||
|
|
@ -81,6 +91,43 @@ class SendChatAction:
|
||||||
|
|
||||||
if "upload" in action_name or "history" in action_name:
|
if "upload" in action_name or "history" in action_name:
|
||||||
action = action.value(progress=0)
|
action = action.value(progress=0)
|
||||||
|
elif "watch_emoji" in action_name:
|
||||||
|
if emoji is None:
|
||||||
|
raise ValueError(
|
||||||
|
"Invalid Argument Provided"
|
||||||
|
)
|
||||||
|
action = action.value(emoticon=emoji)
|
||||||
|
elif "trigger_emoji" in action_name:
|
||||||
|
if (
|
||||||
|
emoji is None or
|
||||||
|
emoji_message_id is None
|
||||||
|
):
|
||||||
|
raise ValueError(
|
||||||
|
"Invalid Argument Provided"
|
||||||
|
)
|
||||||
|
_, sticker_set = await self._get_raw_stickers(
|
||||||
|
raw.types.InputStickerSetAnimatedEmojiAnimations()
|
||||||
|
)
|
||||||
|
action = action.value(
|
||||||
|
emoticon=emoji,
|
||||||
|
msg_id=emoji_message_id,
|
||||||
|
interaction=raw.types.DataJSON(
|
||||||
|
data=dumps(
|
||||||
|
{
|
||||||
|
"v": 1,
|
||||||
|
"a":[
|
||||||
|
{
|
||||||
|
"t": 0,
|
||||||
|
"i": randint(
|
||||||
|
1,
|
||||||
|
sticker_set.count
|
||||||
|
)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
action = action.value()
|
action = action.value()
|
||||||
rpc = raw.functions.messages.SetTyping(
|
rpc = raw.functions.messages.SetTyping(
|
||||||
|
|
|
||||||
|
|
@ -1862,7 +1862,9 @@ class Message(Object, Update):
|
||||||
async def reply_chat_action(
|
async def reply_chat_action(
|
||||||
self,
|
self,
|
||||||
action: "enums.ChatAction",
|
action: "enums.ChatAction",
|
||||||
business_connection_id: str = None
|
business_connection_id: str = None,
|
||||||
|
emoji: str = None,
|
||||||
|
emoji_message_id: int = None
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Bound method *reply_chat_action* of :obj:`~pyrogram.types.Message`.
|
"""Bound method *reply_chat_action* of :obj:`~pyrogram.types.Message`.
|
||||||
|
|
||||||
|
|
@ -1892,6 +1894,12 @@ class Message(Object, Update):
|
||||||
Business connection identifier.
|
Business connection identifier.
|
||||||
for business bots only.
|
for business bots only.
|
||||||
|
|
||||||
|
emoji (``str``, *optional*):
|
||||||
|
The animated emoji. Only supported for :obj:`~pyrogram.enums.ChatAction.TRIGGER_EMOJI_ANIMATION` and :obj:`~pyrogram.enums.ChatAction.WATCH_EMOJI_ANIMATION`.
|
||||||
|
|
||||||
|
emoji_message_id (``int``, *optional*):
|
||||||
|
Message identifier of the message containing the animated emoji. Only supported for :obj:`~pyrogram.enums.ChatAction.TRIGGER_EMOJI_ANIMATION`.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
``bool``: On success, True is returned.
|
``bool``: On success, True is returned.
|
||||||
|
|
||||||
|
|
@ -1905,7 +1913,9 @@ class Message(Object, Update):
|
||||||
return await self._client.send_chat_action(
|
return await self._client.send_chat_action(
|
||||||
chat_id=self.chat.id,
|
chat_id=self.chat.id,
|
||||||
business_connection_id=business_connection_id,
|
business_connection_id=business_connection_id,
|
||||||
action=action
|
action=action,
|
||||||
|
emoji=emoji,
|
||||||
|
emoji_message_id=emoji_message_id
|
||||||
)
|
)
|
||||||
|
|
||||||
async def reply_contact(
|
async def reply_contact(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue