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:
shriMADhav U k 2024-04-20 11:00:26 +02:00 committed by wulan17
parent 51b006cc69
commit eae031f79a
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
3 changed files with 66 additions and 3 deletions

View file

@ -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 <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"

View file

@ -17,6 +17,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
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(

View file

@ -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(