Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit ed79f73

Browse files
committed
Rework and simplify message parsing
1 parent 730243f commit ed79f73

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pyrogram/utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ async def parse_messages(client, messages: "raw.types.messages.Messages", replie
9797
if not isinstance(i, raw.types.MessageEmpty) and i.reply_to
9898
}
9999

100-
reply_message_ids = [i[0] for i in filter(lambda x: x[1] is not None, messages_with_replies.items())]
101-
102-
if reply_message_ids:
100+
if messages_with_replies:
103101
# We need a chat id, but some messages might be empty (no chat attribute available)
104102
# Scan until we find a message with a chat available (there must be one, because we are fetching replies)
105103
for m in parsed_messages:
@@ -111,12 +109,12 @@ async def parse_messages(client, messages: "raw.types.messages.Messages", replie
111109

112110
reply_messages = await client.get_messages(
113111
chat_id,
114-
reply_to_message_ids=reply_message_ids,
112+
reply_to_message_ids=messages_with_replies.keys(),
115113
replies=replies - 1
116114
)
117115

118116
for message in parsed_messages:
119-
reply_id = messages_with_replies[message.message_id]
117+
reply_id = messages_with_replies.get(message.message_id, None)
120118

121119
for reply in reply_messages:
122120
if reply.message_id == reply_id:

0 commit comments

Comments
 (0)