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>
This commit is contained in:
SUBIN 2021-12-30 15:36:37 +05:30 committed by GitHub
parent 9c67084170
commit 00c91120d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]
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)
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(