@@ -112,8 +112,7 @@ def parse_user_chat(client, user: types.User) -> "Chat":
112112 last_name = user .last_name ,
113113 photo = ChatPhoto .parse (client , user .photo ),
114114 restriction_reason = user .restriction_reason ,
115- client = client ,
116- raw = user
115+ client = client , raw = user
117116 )
118117
119118 @staticmethod
@@ -129,8 +128,7 @@ def parse_chat_chat(client, chat: types.Chat) -> "Chat":
129128 title = chat .title ,
130129 all_members_are_administrators = admins_enabled ,
131130 photo = ChatPhoto .parse (client , getattr (chat , "photo" , None )),
132- client = client ,
133- raw = chat
131+ client = client , raw = chat
134132 )
135133
136134 @staticmethod
@@ -142,8 +140,7 @@ def parse_channel_chat(client, channel: types.Channel) -> "Chat":
142140 username = getattr (channel , "username" , None ),
143141 photo = ChatPhoto .parse (client , getattr (channel , "photo" , None )),
144142 restriction_reason = getattr (channel , "restriction_reason" , None ),
145- client = client ,
146- raw = channel
143+ client = client , raw = channel
147144 )
148145
149146 @staticmethod
@@ -152,6 +149,43 @@ def parse(client, message: types.Message or types.MessageService, users: dict, c
152149 return Chat .parse_user_chat (client , users [message .to_id .user_id if message .out else message .from_id ])
153150
154151 if isinstance (message .to_id , types .PeerChat ):
155- return Chat .parse_chat_chat (chats [message .to_id .chat_id ])
152+ return Chat .parse_chat_chat (client , chats [message .to_id .chat_id ])
156153
157154 return Chat .parse_channel_chat (client , chats [message .to_id .channel_id ])
155+
156+ @staticmethod
157+ def parse_full (client , chat_full : types .messages .ChatFull or types .UserFull ) -> "Chat" :
158+ if isinstance (chat_full , types .UserFull ):
159+ parsed_chat = Chat .parse_user_chat (client , chat_full .user )
160+ parsed_chat .description = chat_full .about
161+ else :
162+ full_chat = chat_full .full_chat
163+ chat = None
164+
165+ for i in chat_full .chats :
166+ if full_chat .id == i .id :
167+ chat = i
168+
169+ if isinstance (full_chat , types .ChatFull ):
170+ parsed_chat = Chat .parse_chat_chat (client , chat )
171+
172+ if isinstance (full_chat .participants , types .ChatParticipants ):
173+ parsed_chat .members_count = len (full_chat .participants .participants )
174+ else :
175+ parsed_chat = Chat .parse_channel_chat (client , chat )
176+ parsed_chat .members_count = full_chat .participants_count
177+ parsed_chat .description = full_chat .about or None
178+ # TODO: Add StickerSet type
179+ parsed_chat .can_set_sticker_set = full_chat .can_set_stickers
180+ parsed_chat .sticker_set_name = full_chat .stickerset
181+
182+ if full_chat .pinned_msg_id :
183+ parsed_chat .pinned_message = client .get_messages (
184+ parsed_chat .id ,
185+ message_ids = full_chat .pinned_msg_id
186+ )
187+
188+ if isinstance (full_chat .exported_invite , types .ChatInviteExported ):
189+ parsed_chat .invite_link = full_chat .exported_invite .link
190+
191+ return parsed_chat
0 commit comments