From 00c91120d82b5ae3b23961e60b5edb5f2eaadde4 Mon Sep 17 00:00:00 2001 From: SUBIN <64341611+subinps@users.noreply.github.com> Date: Thu, 30 Dec 2021 15:36:37 +0530 Subject: [PATCH] Handle the case when default_send_as is None (#842) * fix parsing send_as peer. * Update chat.py Co-authored-by: Dan <14043624+delivrance@users.noreply.github.com> --- pyrogram/types/user_and_chats/chat.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index 4cee9640..898a4325 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -320,12 +320,13 @@ class Chat(Object): default_send_as = full_chat.default_send_as - if isinstance(default_send_as, raw.types.PeerUser): - send_as_raw = users[default_send_as.user_id] - else: - send_as_raw = chats[default_send_as.channel_id] - - parsed_chat.send_as_chat = Chat._parse_chat(client, send_as_raw) + if default_send_as: + if isinstance(default_send_as, raw.types.PeerUser): + send_as_raw = users[default_send_as.user_id] + else: + send_as_raw = chats[default_send_as.channel_id] + + parsed_chat.send_as_chat = Chat._parse_chat(client, send_as_raw) if full_chat.pinned_msg_id: parsed_chat.pinned_message = await client.get_messages(