From 0835877aaf431857aa42e3814f5344745a62b538 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 --- docs/source/releases/changes-in-this-fork.rst | 2 ++ pyrogram/methods/messages/send_sticker.py | 14 ++++++++++--- pyrogram/types/messages_and_media/message.py | 21 +++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/source/releases/changes-in-this-fork.rst b/docs/source/releases/changes-in-this-fork.rst index 7d122bd77e..573ecf41e9 100644 --- a/docs/source/releases/changes-in-this-fork.rst +++ b/docs/source/releases/changes-in-this-fork.rst @@ -14,6 +14,8 @@ If you found any issue or have any suggestions, feel free to make `an issue `__. + - Added the field ``prize_star_count`` to the classes :obj:`~pyrogram.types.GiveawayCreated`, :obj:`~pyrogram.types.Giveaway`, :obj:`~pyrogram.types.GiveawayWinners`. - Added the field ``is_star_giveaway`` to the class :obj:`~pyrogram.types.GiveawayCompleted`. - Added the ability to specify a payload in :meth:`~pyrogram.Client.send_paid_media` that is unused currently. diff --git a/pyrogram/methods/messages/send_sticker.py b/pyrogram/methods/messages/send_sticker.py index b26aba79bb..47dbae9eb1 100644 --- a/pyrogram/methods/messages/send_sticker.py +++ b/pyrogram/methods/messages/send_sticker.py @@ -39,7 +39,7 @@ async def send_sticker( caption: str = "", parse_mode: Optional["enums.ParseMode"] = None, caption_entities: List["types.MessageEntity"] = None, - # emoji: str = None, + emoji: str = None, disable_notification: bool = None, protect_content: bool = None, message_thread_id: int = None, @@ -52,8 +52,8 @@ async def send_sticker( "types.ReplyKeyboardRemove", "types.ForceReply" ] = None, - reply_to_message_id: int = None, schedule_date: datetime = None, + reply_to_message_id: int = None, progress: Callable = None, progress_args: tuple = () ) -> Optional["types.Message"]: @@ -84,7 +84,7 @@ async def send_sticker( caption_entities (List of :obj:`~pyrogram.types.MessageEntity`): List of special entities that appear in the caption, which can be specified instead of *parse_mode*. - emoji (``str``, *optional*): // UNUSED CURRENTLY + emoji (``str``, *optional*): Emoji associated with the sticker; only for just uploaded stickers disable_notification (``bool``, *optional*): @@ -174,6 +174,10 @@ async def send_sticker( file=file, attributes=[ raw.types.DocumentAttributeFilename(file_name=os.path.basename(sticker)), + raw.types.DocumentAttributeSticker( + alt=emoji, + stickerset=raw.types.InputStickerSetEmpty() + ), ] ) elif re.match("^https?://", sticker): @@ -189,6 +193,10 @@ async def send_sticker( file=file, attributes=[ raw.types.DocumentAttributeFilename(file_name=sticker.name), + raw.types.DocumentAttributeSticker( + alt=emoji, + stickerset=raw.types.InputStickerSetEmpty() + ), ] ) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index b823622346..6db53f9862 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -2983,6 +2983,10 @@ async def reply_sticker( self, sticker: Union[str, BinaryIO], quote: bool = None, + caption: str = "", + parse_mode: Optional["enums.ParseMode"] = None, + caption_entities: List["types.MessageEntity"] = None, + emoji: str = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: int = None, @@ -3026,6 +3030,19 @@ 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. + caption (``str``, *optional*): + Photo caption, 0-1024 characters. + + parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*): + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + + caption_entities (List of :obj:`~pyrogram.types.MessageEntity`): + List of special entities that appear in the caption, which can be specified instead of *parse_mode*. + + 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. @@ -3087,6 +3104,10 @@ async def reply_sticker( return await self._client.send_sticker( chat_id=self.chat.id, sticker=sticker, + caption=caption, + parse_mode=parse_mode, + caption_entities=caption_entities, + emoji=emoji, disable_notification=disable_notification, protect_content=protect_content, message_thread_id=self.message_thread_id,