Skip to content

Commit

Permalink
Fix get_chats assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Nov 9, 2023
1 parent d32967e commit 4b1a6a1
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions client/src/telethon/_impl/client/client/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,26 @@ async def get_chats(self: Client, chats: Sequence[ChatLike]) -> List[Chat]:
else:
input_channels.append(packed._to_input_channel())

users = (
(await self(functions.users.get_users(id=input_users))) if input_users else []
)
groups = (
(await self(functions.messages.get_chats(id=input_chats)))
if input_chats
else []
)
assert isinstance(groups, types.messages.Chats)
channels = (
(await self(functions.channels.get_channels(id=input_channels)))
if input_channels
else []
)
assert isinstance(channels, types.messages.Chats)
if input_users:
users = await self(functions.users.get_users(id=input_users))
else:
users = []

if input_chats:
ret_chats = await self(functions.messages.get_chats(id=input_chats))
assert isinstance(ret_chats, types.messages.Chats)
groups = ret_chats.chats
else:
groups = []

if input_chats:
ret_chats = await self(functions.channels.get_channels(id=input_channels))
assert isinstance(ret_chats, types.messages.Chats)
channels = ret_chats.chats
else:
channels = []

chat_map = build_chat_map(self, users, groups.chats + channels.chats)
chat_map = build_chat_map(self, users, groups + channels)
return [
chat_map.get(chat.id)
or expand_peer(self, chat._to_peer(), broadcast=chat.ty == PackedType.BROADCAST)
Expand Down

0 comments on commit 4b1a6a1

Please sign in to comment.