Pyrofork: fix get_chat exception when personal_channel_id is None

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2024-04-07 23:14:36 +07:00
parent 2d090a6db5
commit 756a42c595
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -426,12 +426,14 @@ class Chat(Object):
parsed_chat.business_info = types.BusinessInfo._parse(client, full_user, users)
birthday = getattr(full_user, "birthday", None)
parsed_chat.birthday = types.Birthday._parse(birthday) if birthday is not None else None
personal_chat = await client.invoke(
raw.functions.channels.GetChannels(
id=[await client.resolve_peer(utils.get_channel_id(full_user.personal_channel_id))]
personal_chat_id = getattr(full_user, "personal_channel_id", None)
if personal_chat_id is not None:
personal_chat = await client.invoke(
raw.functions.channels.GetChannels(
id=[await client.resolve_peer(utils.get_channel_id(personal_chat_id))]
)
)
)
parsed_chat.personal_chat = Chat._parse_chat(client, personal_chat.chats[0])
parsed_chat.personal_chat = Chat._parse_chat(client, personal_chat.chats[0])
if full_user.pinned_msg_id:
parsed_chat.pinned_message = await client.get_messages(