Fix get_dialogs breaking in case of empty messages
This commit is contained in:
parent
19878ae633
commit
4b77bbd468
@ -91,17 +91,8 @@ class GetDialogs(Scaffold):
|
|||||||
for message in r.messages:
|
for message in r.messages:
|
||||||
if isinstance(message, raw.types.MessageEmpty):
|
if isinstance(message, raw.types.MessageEmpty):
|
||||||
continue
|
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)
|
messages[chat_id] = await types.Message._parse(self, message, users, chats)
|
||||||
|
|
||||||
parsed_dialogs = []
|
parsed_dialogs = []
|
||||||
|
@ -115,4 +115,4 @@ class GetMessages(Scaffold):
|
|||||||
|
|
||||||
messages = await utils.parse_messages(self, r, replies=replies)
|
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
|
||||||
|
@ -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))
|
parsed_messages.append(await types.Message._parse(client, message, users, chats, replies=0))
|
||||||
|
|
||||||
if replies:
|
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())]
|
reply_message_ids = [i[0] for i in filter(lambda x: x[1] is not None, messages_with_replies.items())]
|
||||||
|
|
||||||
if reply_message_ids:
|
if reply_message_ids:
|
||||||
|
Loading…
Reference in New Issue
Block a user