@@ -95,9 +95,7 @@ async def invite_users_to_group(
9595 operation = "add" ,
9696 ).model_dump (by_alias = True )
9797
98- data = await self ._send_and_wait (
99- opcode = Opcode .CHAT_MEMBERS_UPDATE , payload = payload
100- )
98+ data = await self ._send_and_wait (opcode = Opcode .CHAT_MEMBERS_UPDATE , payload = payload )
10199
102100 if data .get ("payload" , {}).get ("error" ):
103101 MixinsUtils .handle_error (data )
@@ -155,9 +153,7 @@ async def remove_users_from_group(
155153 clean_msg_period = clean_msg_period ,
156154 ).model_dump (by_alias = True )
157155
158- data = await self ._send_and_wait (
159- opcode = Opcode .CHAT_MEMBERS_UPDATE , payload = payload
160- )
156+ data = await self ._send_and_wait (opcode = Opcode .CHAT_MEMBERS_UPDATE , payload = payload )
161157
162158 if data .get ("payload" , {}).get ("error" ):
163159 MixinsUtils .handle_error (data )
@@ -293,6 +289,33 @@ async def join_group(self, link: str) -> Chat:
293289
294290 return chat
295291
292+ async def resolve_group_by_link (self , link : str ) -> Chat | None :
293+ """
294+ Разрешает группу по ссылке
295+
296+ Args:
297+ link (str): Ссылка на группу.
298+
299+ Returns:
300+ Chat | None: Объект чата группы или None, если не найдено.
301+ """
302+ proceed_link = self ._process_chat_join_link (link )
303+ if proceed_link is None :
304+ raise ValueError ("Invalid group link" )
305+
306+ data = await self ._send_and_wait (
307+ opcode = Opcode .LINK_INFO ,
308+ payload = {
309+ "link" : proceed_link ,
310+ },
311+ )
312+
313+ if data .get ("payload" , {}).get ("error" ):
314+ MixinsUtils .handle_error (data )
315+
316+ chat = Chat .from_dict (data ["payload" ].get ("chat" , {}))
317+ return chat
318+
296319 async def rework_invite_link (self , chat_id : int ) -> Chat :
297320 """
298321 Пересоздает ссылку для приглашения в группу
@@ -329,14 +352,10 @@ async def get_chats(self, chat_ids: list[int]) -> list[Chat]:
329352 chat_id for chat_id in chat_ids if await self ._get_chat (chat_id ) is None
330353 ]
331354 if missed_chat_ids :
332- payload = GetChatInfoPayload (chat_ids = missed_chat_ids ).model_dump (
333- by_alias = True
334- )
355+ payload = GetChatInfoPayload (chat_ids = missed_chat_ids ).model_dump (by_alias = True )
335356 else :
336357 chats : list [Chat ] = [
337- chat
338- for chat_id in chat_ids
339- if (chat := await self ._get_chat (chat_id )) is not None
358+ chat for chat_id in chat_ids if (chat := await self ._get_chat (chat_id )) is not None
340359 ]
341360 return chats
342361
0 commit comments