Skip to content

Commit

Permalink
Add emoji to send_sticker and reply_sticker.
Browse files Browse the repository at this point in the history
KurimuzonAkuma/pyrogram#86

Co-authored-by: Surendra9123 <[email protected]>
Signed-off-by: wulan17 <[email protected]>
  • Loading branch information
2 people authored and wulan17 committed Sep 25, 2024
1 parent 1aee338 commit 2950427
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pyrogram/methods/messages/send_sticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down
21 changes: 21 additions & 0 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3173,6 +3173,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,
reply_to_message_id: int = None,
business_connection_id: str = None,
Expand Down Expand Up @@ -3218,6 +3222,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.
Expand Down Expand Up @@ -3305,6 +3322,10 @@ async def reply_sticker(
return await self._client.send_sticker(
chat_id=chat_id,
sticker=sticker,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,
emoji=emoji,
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
Expand Down

0 comments on commit 2950427

Please sign in to comment.