@@ -735,17 +735,35 @@ async def get_full_chat(chat_id: Union[int, str], account: str = None) -> str:
735735 cl = get_client (account )
736736 await ensure_connected (cl )
737737 entity = await resolve_entity (chat_id , cl )
738- full = await cl (functions .channels .GetFullChannelRequest (channel = entity ))
738+
739+ # Basic ("legacy") groups are not channels: GetFullChannelRequest cannot
740+ # cast an InputPeerChat and raises TypeError. They are served by
741+ # messages.GetFullChatRequest instead.
742+ if isinstance (entity , (Chat , InputPeerChat )):
743+ basic_id = getattr (entity , "chat_id" , None ) or getattr (entity , "id" , None )
744+ full = await cl (functions .messages .GetFullChatRequest (chat_id = basic_id ))
745+ else :
746+ full = await cl (functions .channels .GetFullChannelRequest (channel = entity ))
739747
740748 chat = full .chats [0 ] if full .chats else None
741749 full_chat = full .full_chat
742750
751+ # Channels carry participants_count on the full object; basic groups only
752+ # carry the member list, so count that instead.
753+ participants_count = getattr (full_chat , "participants_count" , None )
754+ if participants_count is None :
755+ members = getattr (getattr (full_chat , "participants" , None ), "participants" , None )
756+ if members is not None :
757+ participants_count = len (members )
758+
743759 result = {
744760 "id" : get_marked_id (chat ) if chat else None ,
745761 "title" : sanitize_name (getattr (chat , "title" , None )) if chat else None ,
746762 "username" : getattr (chat , "username" , None ) if chat else None ,
747- "about" : sanitize_user_content (full_chat .about or "" , max_length = 1024 ),
748- "participants_count" : getattr (full_chat , "participants_count" , None ),
763+ "about" : sanitize_user_content (
764+ getattr (full_chat , "about" , None ) or "" , max_length = 1024
765+ ),
766+ "participants_count" : participants_count ,
749767 "linked_chat_id" : getattr (full_chat , "linked_chat_id" , None ),
750768 }
751769
0 commit comments