Skip to content

Commit

Permalink
ability to specify our own interactions in send_chat_action
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Apr 21, 2024
1 parent 84a9738 commit c5bf6f8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ it can take advantage of new goodies!
| Scheme layer used: 177 |
+------------------------+

- Updated :obj:
- Added ``emoji_message_interaction`` parameter to :meth:`~pyrogram.Client.send_chat_action` and :meth:`~pyrogram.types.Message.reply_chat_action`.
- **BOTS ONLY**: Updated :obj:`~pyrogram.handlers.ChatMemberUpdatedHandler` to handle updates when the bot is blocked or unblocked by a user.
- Added missing parameters in :meth:`~pyrogram.Client.create_group`, :meth:`~pyrogram.Client.create_supergroup`, :meth:`~pyrogram.Client.create_channel`.
- Try to return the service message (when applicable) in the methods :meth:`~pyrogram.Client.add_chat_members`, :meth:`~pyrogram.Client.promote_chat_member`
Expand Down
22 changes: 14 additions & 8 deletions pyrogram/methods/messages/send_chat_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ async def send_chat_action(
message_thread_id: int = None,
business_connection_id: str = None,
emoji: str = None,
emoji_message_id: int = None
emoji_message_id: int = None,
emoji_message_interaction: "raw.types.DataJSON" = None
) -> bool:
"""Use this method when you need to tell the user that something is happening on the bot's side.
The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
Expand Down Expand Up @@ -66,6 +67,9 @@ async def send_chat_action(
emoji_message_id (``int``, *optional*):
Message identifier of the message containing the animated emoji. Only supported for :obj:`~pyrogram.enums.ChatAction.TRIGGER_EMOJI_ANIMATION`.
emoji_message_interaction (:obj:`raw.types.DataJSON`, *optional*):
Only supported for :obj:`~pyrogram.enums.ChatAction.TRIGGER_EMOJI_ANIMATION`.
Returns:
``bool``: On success, True is returned.
Expand Down Expand Up @@ -111,13 +115,11 @@ async def send_chat_action(
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(
if emoji_message_interaction is None:
_, sticker_set = await self._get_raw_stickers(
raw.types.InputStickerSetAnimatedEmojiAnimations()
)
emoji_message_interaction = raw.types.DataJSON(
data=dumps(
{
"v": 1,
Expand All @@ -133,6 +135,10 @@ async def send_chat_action(
}
)
)
action = action.value(
emoticon=emoji,
msg_id=emoji_message_id,
interaction=emoji_message_interaction
)
else:
action = action.value()
Expand Down
9 changes: 7 additions & 2 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,8 @@ async def reply_chat_action(
action: "enums.ChatAction",
progress: int = 0,
emoji: str = None,
emoji_message_id: int = None
emoji_message_id: int = None,
emoji_message_interaction: "raw.types.DataJSON" = None
) -> bool:
"""Bound method *reply_chat_action* of :obj:`~pyrogram.types.Message`.
Expand Down Expand Up @@ -1871,6 +1872,9 @@ async def reply_chat_action(
emoji_message_id (``int``, *optional*):
Message identifier of the message containing the animated emoji. Only supported for :obj:`~pyrogram.enums.ChatAction.TRIGGER_EMOJI_ANIMATION`.
emoji_message_interaction (:obj:`raw.types.DataJSON`, *optional*):
Only supported for :obj:`~pyrogram.enums.ChatAction.TRIGGER_EMOJI_ANIMATION`.
Returns:
``bool``: On success, True is returned.
Expand All @@ -1885,7 +1889,8 @@ async def reply_chat_action(
message_thread_id=self.message_thread_id,
business_connection_id=self.business_connection_id,
emoji=emoji,
emoji_message_id=emoji_message_id
emoji_message_id=emoji_message_id,
emoji_message_interaction=emoji_message_interaction
)

async def reply_contact(
Expand Down

0 comments on commit c5bf6f8

Please sign in to comment.