From 8c02a1553d1fd740a5e24842efcafb40b98feac8 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 17 Dec 2018 16:12:53 +0100 Subject: [PATCH] Add Chat.parse_dialog --- pyrogram/client/types/user_and_chats/chat.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pyrogram/client/types/user_and_chats/chat.py b/pyrogram/client/types/user_and_chats/chat.py index d98d57aa..a9564836 100644 --- a/pyrogram/client/types/user_and_chats/chat.py +++ b/pyrogram/client/types/user_and_chats/chat.py @@ -149,6 +149,15 @@ class Chat(PyrogramType): return Chat.parse_channel_chat(client, chats[message.to_id.channel_id]) + @staticmethod + def parse_dialog(client, peer, users: dict, chats: dict): + if isinstance(peer, types.PeerUser): + return Chat.parse_user_chat(client, users[peer.user_id]) + elif isinstance(peer, types.PeerChat): + return Chat.parse_chat_chat(client, chats[peer.chat_id]) + else: + return Chat.parse_channel_chat(client, chats[peer.channel_id]) + @staticmethod def parse_full(client, chat_full: types.messages.ChatFull or types.UserFull) -> "Chat": if isinstance(chat_full, types.UserFull):