Bugfixes in chat.py (#411)

- Fixed this bug: https://t.me/pyrogramchat/169553 (which was caused because pyrogram trying to parse linked_chat even if it was None).

- Fixed another related bug (which was caused because pyrogram trying to get linked_chat_id even with basic groups causing an AttributeError).
This commit is contained in:
SuperCz1 2020-05-23 14:52:14 +02:00 committed by GitHub
parent d5a18eb063
commit d93b9275f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -251,9 +251,10 @@ class Chat(Object):
for c in chat_full.chats:
if full_chat.id == c.id:
chat = c
if full_chat.linked_chat_id == c.id:
linked_chat = c
if isinstance(chat_full, types.ChannelFull):
if full_chat.linked_chat_id == c.id:
linked_chat = c
if isinstance(full_chat, types.ChatFull):
parsed_chat = Chat._parse_chat_chat(client, chat)
@ -268,7 +269,8 @@ class Chat(Object):
# TODO: Add StickerSet type
parsed_chat.can_set_sticker_set = full_chat.can_set_stickers
parsed_chat.sticker_set_name = getattr(full_chat.stickerset, "short_name", None)
parsed_chat.linked_chat = Chat._parse_channel_chat(client, linked_chat)
if linked_chat:
parsed_chat.linked_chat = Chat._parse_channel_chat(client, linked_chat)
if full_chat.pinned_msg_id:
parsed_chat.pinned_message = client.get_messages(