diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 2756f59b..d6be121f 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -3348,7 +3348,8 @@ class Client: def get_messages(self, chat_id: int or str, - message_ids: list or int): + message_ids: list or int, + replies: int = 1): """Use this method to get messages that belong to a specific chat. You can retrieve up to 200 messages at once. @@ -3362,6 +3363,9 @@ class Client: message_ids (``list`` | ``int``): A list of Message identifiers in the chat specified in *chat_id* or a single message id, as integer. + replies (``int``, optional): + The number of replies to get for each message. Defaults to 1. + Returns: On success and in case *message_ids* was a list, the returned value will be a list of the requested :obj:`Messages ` even if a list contains just one element, otherwise if @@ -3395,12 +3399,23 @@ class Client: for i in r.messages: if isinstance(i, types.Message): - parser = message_parser.parse_message + messages.append( + message_parser.parse_message( + self, i, users, chats, + replies=replies + ) + ) elif isinstance(i, types.MessageService): - parser = message_parser.parse_message_service + messages.append( + message_parser.parse_message_service( + self, i, users, chats + ) + ) else: - parser = message_parser.parse_message_empty - - messages.append(parser(self, i, users, chats)) + messages.append( + message_parser.parse_message_empty( + self, i + ) + ) return messages if is_list else messages[0] diff --git a/pyrogram/client/message_parser.py b/pyrogram/client/message_parser.py index 6e930ac4..3072b6f5 100644 --- a/pyrogram/client/message_parser.py +++ b/pyrogram/client/message_parser.py @@ -480,7 +480,7 @@ def parse_message( ) if message.reply_to_msg_id and replies: - m.reply_to_message = client.get_messages(m.chat.id, message.reply_to_msg_id) + m.reply_to_message = client.get_messages(m.chat.id, message.reply_to_msg_id, replies=replies - 1) m.reply_to_message = m.reply_to_message return m @@ -588,8 +588,6 @@ def parse_message_service( def parse_message_empty( client, - message: types.MessageEmpty, - users: dict, - chats: dict + message: types.MessageEmpty ) -> pyrogram_types.Message: return pyrogram_types.Message(message_id=message.id)