From c3df58b4c71fb586fd76d0634e5e3ccd572ad8bd Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Tue, 10 Sep 2024 13:07:59 +0530 Subject: [PATCH] Add emoji to send_sticker and reply_sticker. KurimuzonAkuma/pyrogram#86 Co-authored-by: Surendra9123 Signed-off-by: wulan17 --- pyrogram/methods/messages/send_sticker.py | 10 +++++++++- pyrogram/types/messages_and_media/message.py | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pyrogram/methods/messages/send_sticker.py b/pyrogram/methods/messages/send_sticker.py index aa2bb0f7e..e7696cc62 100644 --- a/pyrogram/methods/messages/send_sticker.py +++ b/pyrogram/methods/messages/send_sticker.py @@ -37,6 +37,7 @@ async def send_sticker( self: "pyrogram.Client", chat_id: Union[int, str], sticker: Union[str, BinaryIO], + emoji: str = None, disable_notification: bool = None, message_thread_id: int = None, business_connection_id: str = None, @@ -76,6 +77,9 @@ async def send_sticker( pass a file path as string to upload a new sticker that exists on your local machine, or pass a binary file-like object with its attribute ".name" set for in-memory uploads. + emoji (``str``, *optional*): + Emoji associated with the sticker; only for just uploaded stickers + disable_notification (``bool``, *optional*): Sends the message silently. Users will receive a notification with no sound. @@ -183,7 +187,11 @@ async def send_sticker( mime_type=self.guess_mime_type(sticker) or "image/webp", file=file, attributes=[ - raw.types.DocumentAttributeFilename(file_name=os.path.basename(sticker)) + raw.types.DocumentAttributeFilename(file_name=os.path.basename(sticker)), + raw.types.DocumentAttributeSticker( + alt=emoji, + stickerset=raw.types.InputStickerSetEmpty() + ) ] ) elif re.match("^https?://", sticker): diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 3546165f7..a7d4294f1 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -3173,6 +3173,7 @@ async def reply_sticker( self, sticker: Union[str, BinaryIO], quote: bool = None, + emoji: str = None, disable_notification: bool = None, reply_to_message_id: int = None, business_connection_id: str = None, @@ -3218,6 +3219,9 @@ async def reply_sticker( If *reply_to_message_id* is passed, this parameter will be ignored. Defaults to ``True`` in group chats and ``False`` in private chats. + emoji (``str``, *optional*): + Emoji associated with the sticker; only for just uploaded stickers + disable_notification (``bool``, *optional*): Sends the message silently. Users will receive a notification with no sound. @@ -3305,6 +3309,7 @@ async def reply_sticker( return await self._client.send_sticker( chat_id=chat_id, sticker=sticker, + emoji=emoji, disable_notification=disable_notification, message_thread_id=message_thread_id, reply_to_message_id=reply_to_message_id,