diff --git a/pyrogram/methods/chats/get_dialogs.py b/pyrogram/methods/chats/get_dialogs.py index f4f7e016..b40443e9 100644 --- a/pyrogram/methods/chats/get_dialogs.py +++ b/pyrogram/methods/chats/get_dialogs.py @@ -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 diff --git a/pyrogram/types/user_and_chats/folder.py b/pyrogram/types/user_and_chats/folder.py index c0df0968..60f2b0e2 100644 --- a/pyrogram/types/user_and_chats/folder.py +++ b/pyrogram/types/user_and_chats/folder.py @@ -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,