diff --git a/pyrogram/enums/chat_action.py b/pyrogram/enums/chat_action.py index cba9c386..79647ca9 100644 --- a/pyrogram/enums/chat_action.py +++ b/pyrogram/enums/chat_action.py @@ -71,3 +71,9 @@ class ChatAction(AutoName): CANCEL = raw.types.SendMessageCancelAction "Cancel ongoing chat action" + + TRIGGER_EMOJI_ANIMATION = raw.types.SendMessageEmojiInteraction + "User has clicked on an animated emoji triggering a `reaction `_" + + WATCH_EMOJI_ANIMATION = raw.types.SendMessageEmojiInteractionSeen + "The user is watching animations sent by the other party by clicking on an animated emoji" diff --git a/pyrogram/methods/messages/send_chat_action.py b/pyrogram/methods/messages/send_chat_action.py index 8ec307ef..8f8d7677 100644 --- a/pyrogram/methods/messages/send_chat_action.py +++ b/pyrogram/methods/messages/send_chat_action.py @@ -17,6 +17,8 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrofork. If not, see . +from json import dumps +from random import randint from typing import Union import pyrogram @@ -29,7 +31,9 @@ class SendChatAction: chat_id: Union[int, str], action: "enums.ChatAction", message_thread_id: int = None, - business_connection_id: str = None + business_connection_id: str = None, + emoji: str = None, + emoji_message_id: int = None ) -> bool: """Tell the other party that something is happening on your side. @@ -53,6 +57,12 @@ class SendChatAction: Business connection identifier. 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: ``bool``: On success, True is returned. @@ -81,6 +91,43 @@ class SendChatAction: if "upload" in action_name or "history" in action_name: 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: action = action.value() rpc = raw.functions.messages.SetTyping( diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index f7755222..69e2fd94 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -1862,7 +1862,9 @@ class Message(Object, Update): async def reply_chat_action( self, action: "enums.ChatAction", - business_connection_id: str = None + business_connection_id: str = None, + emoji: str = None, + emoji_message_id: int = None ) -> bool: """Bound method *reply_chat_action* of :obj:`~pyrogram.types.Message`. @@ -1892,6 +1894,12 @@ class Message(Object, Update): Business connection identifier. 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: ``bool``: On success, True is returned. @@ -1905,7 +1913,9 @@ class Message(Object, Update): return await self._client.send_chat_action( chat_id=self.chat.id, business_connection_id=business_connection_id, - action=action + action=action, + emoji=emoji, + emoji_message_id=emoji_message_id ) async def reply_contact(