Ignore KeyError in get_dialogs and get_folders

This commit is contained in:
KurimuzonAkuma 2023-12-24 00:32:43 +03:00
parent fc33b39e4b
commit aba1ac387b
2 changed files with 21 additions and 5 deletions

View File

@ -76,7 +76,11 @@ class GetDialogs:
continue
chat_id = utils.get_peer_id(message.peer_id)
messages[chat_id] = await types.Message._parse(self, message, users, chats)
try:
messages[chat_id] = await types.Message._parse(self, message, users, chats)
except KeyError:
pass
dialogs = []
@ -84,7 +88,10 @@ class GetDialogs:
if not isinstance(dialog, raw.types.Dialog):
continue
dialogs.append(types.Dialog._parse(self, dialog, messages, users, chats))
try:
dialogs.append(types.Dialog._parse(self, dialog, messages, users, chats))
except KeyError:
pass
if not dialogs:
return

View File

@ -117,14 +117,23 @@ class Folder(Object):
pinned_chats = []
for peer in folder.include_peers:
included_chats.append(types.Chat._parse_dialog(client, peer, users, chats))
try:
included_chats.append(types.Chat._parse_dialog(client, peer, users, chats))
except KeyError:
pass
if getattr(folder, "exclude_peers", None):
for peer in folder.exclude_peers:
excluded_chats.append(types.Chat._parse_dialog(client, peer, users, chats))
try:
excluded_chats.append(types.Chat._parse_dialog(client, peer, users, chats))
except KeyError:
pass
for peer in folder.pinned_peers:
pinned_chats.append(types.Chat._parse_dialog(client, peer, users, chats))
try:
pinned_chats.append(types.Chat._parse_dialog(client, peer, users, chats))
except KeyError:
pass
return Folder(
id=folder.id,