diff --git a/pyrogram/methods/messages/send_reaction.py b/pyrogram/methods/messages/send_reaction.py index f4d1d343..416ab428 100644 --- a/pyrogram/methods/messages/send_reaction.py +++ b/pyrogram/methods/messages/send_reaction.py @@ -26,8 +26,9 @@ class SendReaction: async def send_reaction( self: "pyrogram.Client", chat_id: Union[int, str], - message_id: int, - emoji: str = "", + message_id: int = None, + story_id: int = None, + emoji: Union[int, str] = None, big: bool = False ) -> bool: """Send a reaction to a message. @@ -41,10 +42,13 @@ class SendReaction: message_id (``int``): Identifier of the message. - emoji (``str``, *optional*): + story_id (``int``): + Identifier of the story. + + emoji (``int`` | ``str``, *optional*): Reaction emoji. Pass "" as emoji (default) to retract the reaction. - + big (``bool``, *optional*): Pass True to show a bigger and longer reaction. Defaults to False. @@ -61,13 +65,25 @@ class SendReaction: # Retract a reaction await app.send_reaction(chat_id, message_id) """ - await self.invoke( - raw.functions.messages.SendReaction( + if isinstance(emoji, int): + emoji = [raw.types.ReactionCustomEmoji(document_id=emoji)] + else: + emoji = [raw.types.ReactionEmoji(emoticon=emoji)] if emoji else None + + if story_id: + rpc = raw.functions.stories.SendReaction( + peer=await self.resolve_peer(chat_id), + story_id=story_id, + reaction=emoji, + ) + else: + rpc = raw.functions.messages.SendReaction( peer=await self.resolve_peer(chat_id), msg_id=message_id, - reaction=[raw.types.ReactionEmoji(emoticon=emoji)] if emoji else None, + reaction=emoji, big=big ) - ) + + await self.invoke(rpc) return True diff --git a/pyrogram/methods/stories/get_stories_archive.py b/pyrogram/methods/stories/get_stories_archive.py index 92f8bdcd..0e0c924d 100644 --- a/pyrogram/methods/stories/get_stories_archive.py +++ b/pyrogram/methods/stories/get_stories_archive.py @@ -47,34 +47,46 @@ class GetStoriesArchive: offset_id (``int``, *optional*): Identifier of the first story to be returned. - Returns: - ``Generator``: On success, a generator yielding :obj:`~pyrogram.types.Story` objects is returned. + Yields: + :obj:`~pyrogram.types.Story` objects. Example: .. code-block:: python - # Get story archive + # Get stories archive async for story in app.get_stories_archive(chat_id): print(story) - - Raises: - ValueError: In case of invalid arguments. """ - peer = await self.resolve_peer(chat_id) + current = 0 + total = abs(limit) or (1 << 31) + limit = min(100, total) - r = await self.invoke( - raw.functions.stories.GetStoriesArchive( - peer=peer, - offset_id=offset_id, - limit=limit + while True: + peer = await self.resolve_peer(chat_id) + r = await self.invoke( + raw.functions.stories.GetStoriesArchive( + peer=peer, + offset_id=offset_id, + limit=limit + ) ) - ) - for story in r.stories: - yield await types.Story._parse( - self, - story, - {i.id: i for i in r.users}, - {i.id: i for i in r.chats}, - peer - ) + if not r.stories: + return + + last = r.stories[-1] + offset_id = last.id + + for story in r.stories: + yield await types.Story._parse( + self, + story, + {i.id: i for i in r.users}, + {i.id: i for i in r.chats}, + peer + ) + + current += 1 + + if current >= total: + return diff --git a/pyrogram/methods/stories/pin_stories.py b/pyrogram/methods/stories/pin_stories.py index 2e380fae..115c9c2e 100644 --- a/pyrogram/methods/stories/pin_stories.py +++ b/pyrogram/methods/stories/pin_stories.py @@ -28,7 +28,7 @@ class PinStories: self: "pyrogram.Client", chat_id: Union[int, str], stories_ids: Union[int, Iterable[int]], - pinned: bool, + pinned: bool = False, ) -> List[int]: """Toggle stories pinned. diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 2c0b6426..d9c525a6 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -3598,7 +3598,7 @@ class Message(Object, Update): else: await self.reply(button, quote=quote) - async def react(self, emoji: str = "", big: bool = False) -> bool: + async def react(self, emoji: Union[int, str] = None, big: bool = False) -> bool: """Bound method *react* of :obj:`~pyrogram.types.Message`. Use as a shortcut for: