diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 0ff6c28c..a8989427 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -3830,3 +3830,53 @@ class Client: r = self.send(functions.messages.GetFullChat(peer.chat_id)) return utils.parse_chat_full(self, r) + + def get_history(self, + chat_id: int or str, + offset: int, + limit: int, + offset_id: int = 0, + offset_date: int = 0, + max_id: int = 0, + min_id: int = 0): + # TODO: Documentation + + r = self.send( + functions.messages.GetHistory( + peer=self.resolve_peer(chat_id), + offset_id=offset_id, + offset_date=offset_date, + add_offset=offset, + limit=limit, + max_id=max_id, + min_id=min_id, + hash=0 + ) + ) + + users = {i.id: i for i in r.users} + chats = {i.id: i for i in r.chats} + + messages = [] + + for i in r.messages: + if isinstance(i, types.Message): + messages.append( + utils.parse_message( + self, i, users, chats + ) + ) + elif isinstance(i, types.MessageService): + messages.append( + utils.parse_message_service( + self, i, users, chats + ) + ) + else: + messages.append( + utils.parse_message_empty( + self, i + ) + ) + + return messages