diff --git a/pyrogram/client/methods/messages/get_history.py b/pyrogram/client/methods/messages/get_history.py index 4089dde9..f55a64ed 100644 --- a/pyrogram/client/methods/messages/get_history.py +++ b/pyrogram/client/methods/messages/get_history.py @@ -27,7 +27,8 @@ class GetHistory(BaseClient): offset: int = 0, limit: int = 100, offset_id: int = 0, - offset_date: int = 0): + offset_date: int = 0, + reverse: bool = False): """Use this method to retrieve the history of a chat. You can get up to 100 messages at once. @@ -52,6 +53,9 @@ class GetHistory(BaseClient): offset_date (``int``, *optional*): Pass a date in Unix time as offset to retrieve only older messages starting from that date. + + reverse (``bool``, *optional*): + get the messages in order from first to last (instead of newest to oldest). Returns: On success, a :obj:`Messages ` object is returned. @@ -59,7 +63,9 @@ class GetHistory(BaseClient): Raises: :class:`Error ` """ - + if reverse: + offset = -limit*(offset + 1) + if offset_id: offset_id +=1 r = self.send( functions.messages.GetHistory( peer=self.resolve_peer(chat_id), @@ -107,5 +113,5 @@ class GetHistory(BaseClient): return pyrogram.Messages( total_count=getattr(r, "count", len(r.messages)), - messages=messages + messages=messages if not reverse else messages[::-1] )