diff --git a/pyrogram/client/types/user_and_chats/chat.py b/pyrogram/client/types/user_and_chats/chat.py index 6e1c675e..2169f1d7 100644 --- a/pyrogram/client/types/user_and_chats/chat.py +++ b/pyrogram/client/types/user_and_chats/chat.py @@ -112,8 +112,7 @@ class Chat(PyrogramType): last_name=user.last_name, photo=ChatPhoto.parse(client, user.photo), restriction_reason=user.restriction_reason, - client=client, - raw=user + client=client, raw=user ) @staticmethod @@ -129,8 +128,7 @@ class Chat(PyrogramType): title=chat.title, all_members_are_administrators=admins_enabled, photo=ChatPhoto.parse(client, getattr(chat, "photo", None)), - client=client, - raw=chat + client=client, raw=chat ) @staticmethod @@ -142,8 +140,7 @@ class Chat(PyrogramType): username=getattr(channel, "username", None), photo=ChatPhoto.parse(client, getattr(channel, "photo", None)), restriction_reason=getattr(channel, "restriction_reason", None), - client=client, - raw=channel + client=client, raw=channel ) @staticmethod @@ -152,6 +149,43 @@ class Chat(PyrogramType): return Chat.parse_user_chat(client, users[message.to_id.user_id if message.out else message.from_id]) if isinstance(message.to_id, types.PeerChat): - return Chat.parse_chat_chat(chats[message.to_id.chat_id]) + return Chat.parse_chat_chat(client, chats[message.to_id.chat_id]) return Chat.parse_channel_chat(client, chats[message.to_id.channel_id]) + + @staticmethod + def parse_full(client, chat_full: types.messages.ChatFull or types.UserFull) -> "Chat": + if isinstance(chat_full, types.UserFull): + parsed_chat = Chat.parse_user_chat(client, chat_full.user) + parsed_chat.description = chat_full.about + else: + full_chat = chat_full.full_chat + chat = None + + for i in chat_full.chats: + if full_chat.id == i.id: + chat = i + + if isinstance(full_chat, types.ChatFull): + parsed_chat = Chat.parse_chat_chat(client, chat) + + if isinstance(full_chat.participants, types.ChatParticipants): + parsed_chat.members_count = len(full_chat.participants.participants) + else: + parsed_chat = Chat.parse_channel_chat(client, chat) + parsed_chat.members_count = full_chat.participants_count + parsed_chat.description = full_chat.about or None + # TODO: Add StickerSet type + parsed_chat.can_set_sticker_set = full_chat.can_set_stickers + parsed_chat.sticker_set_name = full_chat.stickerset + + if full_chat.pinned_msg_id: + parsed_chat.pinned_message = client.get_messages( + parsed_chat.id, + message_ids=full_chat.pinned_msg_id + ) + + if isinstance(full_chat.exported_invite, types.ChatInviteExported): + parsed_chat.invite_link = full_chat.exported_invite.link + + return parsed_chat