diff --git a/pyrogram/methods/messages/__init__.py b/pyrogram/methods/messages/__init__.py index 1812c36a6..eb44fc82a 100644 --- a/pyrogram/methods/messages/__init__.py +++ b/pyrogram/methods/messages/__init__.py @@ -55,7 +55,9 @@ from .send_message import SendMessage from .send_photo import SendPhoto from .send_poll import SendPoll -from .set_message_reaction import SetMessageReaction +from .set_message_reaction import ( + SetMessageReaction +) from .send_sticker import SendSticker from .send_venue import SendVenue from .send_video import SendVideo diff --git a/pyrogram/methods/messages/set_message_reaction.py b/pyrogram/methods/messages/set_message_reaction.py index 8559ec06c..670d4bb59 100644 --- a/pyrogram/methods/messages/set_message_reaction.py +++ b/pyrogram/methods/messages/set_message_reaction.py @@ -28,6 +28,7 @@ async def set_message_reaction( self: "pyrogram.Client", chat_id: Union[int, str], message_id: int = None, + story_id: int = None, reaction: List["types.ReactionType"] = [], is_big: bool = False, add_to_recent: bool = True @@ -40,14 +41,19 @@ async def set_message_reaction( .. include:: /_includes/usable-by/users-bots.rst + .. include:: /_includes/usable-by/users.rst + Parameters: chat_id (``int`` | ``str``): Unique identifier (int) or username (str) of the target chat. - message_id (``int``): + message_id (``int``, *optional*): Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead. - reaction (List of :obj:`~pyrogram.types.ReactionType` *optional*): + story_id (``int``, *optional*): + Identifier of the story. + + reaction (List of :obj:`~pyrogram.types.ReactionType`, *optional*): New list of reaction types to set on the message. Pass None as emoji (default) to retract the reaction. @@ -90,5 +96,24 @@ async def set_message_reaction( for i in r.updates: if isinstance(i, raw.types.UpdateMessageReactions): return types.MessageReactions._parse(self, i.reactions) + + elif story_id is not None: + r = await self.invoke( + raw.functions.stories.SendReaction( + peer=await self.resolve_peer(chat_id), + story_id=story_id, + reaction=( + [ + r.write(self) + for r in reaction + ] if reaction else [ + raw.types.ReactionEmpty() + ] + )[0], + add_to_recent=add_to_recent + ) + ) + # TODO + return r else: - raise ValueError("You need to pass one of message_id!") + raise ValueError("You need to pass one of message_id OR story_id!") diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 5239f36ab..31baa82e4 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -3546,7 +3546,11 @@ async def react( is_big (``bool``, *optional*): Pass True to set the reaction with a big animation. Defaults to False. - + + add_to_recent (``bool``, *optional*): + Pass True if the reaction should appear in the recently used reactions. + This option is applicable only for users. + Defaults to True. Returns: On success, :obj:`~pyrogram.types.MessageReactions`: is returned.