Rework and simplify message parsing
This commit is contained in:
parent
730243f451
commit
ed79f73bd7
@ -97,9 +97,7 @@ async def parse_messages(client, messages: "raw.types.messages.Messages", replie
|
|||||||
if not isinstance(i, raw.types.MessageEmpty) and i.reply_to
|
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 messages_with_replies:
|
||||||
|
|
||||||
if reply_message_ids:
|
|
||||||
# We need a chat id, but some messages might be empty (no chat attribute available)
|
# We need a chat id, but some messages might be empty (no chat attribute available)
|
||||||
# Scan until we find a message with a chat available (there must be one, because we are fetching replies)
|
# Scan until we find a message with a chat available (there must be one, because we are fetching replies)
|
||||||
for m in parsed_messages:
|
for m in parsed_messages:
|
||||||
@ -111,12 +109,12 @@ async def parse_messages(client, messages: "raw.types.messages.Messages", replie
|
|||||||
|
|
||||||
reply_messages = await client.get_messages(
|
reply_messages = await client.get_messages(
|
||||||
chat_id,
|
chat_id,
|
||||||
reply_to_message_ids=reply_message_ids,
|
reply_to_message_ids=messages_with_replies.keys(),
|
||||||
replies=replies - 1
|
replies=replies - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
for message in parsed_messages:
|
for message in parsed_messages:
|
||||||
reply_id = messages_with_replies[message.message_id]
|
reply_id = messages_with_replies.get(message.message_id, None)
|
||||||
|
|
||||||
for reply in reply_messages:
|
for reply in reply_messages:
|
||||||
if reply.message_id == reply_id:
|
if reply.message_id == reply_id:
|
||||||
|
Loading…
Reference in New Issue
Block a user