diff --git a/pyrogram/methods/chats/get_dialogs.py b/pyrogram/methods/chats/get_dialogs.py index 487e8f8d..50656cfe 100644 --- a/pyrogram/methods/chats/get_dialogs.py +++ b/pyrogram/methods/chats/get_dialogs.py @@ -91,17 +91,8 @@ class GetDialogs(Scaffold): for message in r.messages: if isinstance(message, raw.types.MessageEmpty): continue - - peer_id = message.peer_id - - if isinstance(peer_id, raw.types.PeerUser): - if message.out: - chat_id = peer_id.user_id - else: - chat_id = utils.get_raw_peer_id(message.from_id) - else: - chat_id = utils.get_peer_id(peer_id) + chat_id = utils.get_peer_id(message.peer_id) messages[chat_id] = await types.Message._parse(self, message, users, chats) parsed_dialogs = [] diff --git a/pyrogram/methods/messages/get_messages.py b/pyrogram/methods/messages/get_messages.py index 3503f16a..a4f9e6a5 100644 --- a/pyrogram/methods/messages/get_messages.py +++ b/pyrogram/methods/messages/get_messages.py @@ -115,4 +115,4 @@ class GetMessages(Scaffold): messages = await utils.parse_messages(self, r, replies=replies) - return messages if is_iterable else messages[0] + return messages if is_iterable else messages[0] if messages else None diff --git a/pyrogram/utils.py b/pyrogram/utils.py index 9f80591d..220f3759 100644 --- a/pyrogram/utils.py +++ b/pyrogram/utils.py @@ -91,7 +91,12 @@ async def parse_messages(client, messages: "raw.types.messages.Messages", replie parsed_messages.append(await types.Message._parse(client, message, users, chats, replies=0)) if replies: - messages_with_replies = {i.id: i.reply_to.reply_to_msg_id for i in messages.messages if i.reply_to} + messages_with_replies = { + i.id: i.reply_to.reply_to_msg_id + for i in messages.messages + if not isinstance(i, raw.types.MessageEmpty) and i.reply_to + } + reply_message_ids = [i[0] for i in filter(lambda x: x[1] is not None, messages_with_replies.items())] if reply_message_ids: