Skip to content
Merged

_ #140

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,14 +885,21 @@ async def _parse(
_requested_users.append(
types.Chat._parse_user_chat(
client,
users.get(raw_peer_id)
users.get(raw_peer_id, raw_peer_id)
)
)
elif isinstance(requested_peer, raw.types.PeerChat):
_requested_chats.append(
types.Chat._parse_chat_chat(
client,
chats.get(raw_peer_id, raw_peer_id)
)
)
else:
_requested_chats.append(
types.Chat._parse_chat(
types.Chat._parse_channel_chat(
client,
chats.get(raw_peer_id)
chats.get(raw_peer_id, raw_peer_id)
)
)

Expand Down
21 changes: 21 additions & 0 deletions pyrogram/types/user_and_chats/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,13 @@ def __init__(

@staticmethod
def _parse_user_chat(client, user: raw.types.User) -> "Chat":
if isinstance(user, int):
return Chat(
id=user,
client=client,
_raw=None
)

peer_id = user.id

if isinstance(user, raw.types.UserEmpty):
Expand Down Expand Up @@ -408,6 +415,13 @@ def _parse_user_chat(client, user: raw.types.User) -> "Chat":

@staticmethod
def _parse_chat_chat(client, chat: raw.types.Chat) -> "Chat":
if isinstance(chat, int):
return Chat(
id=-chat,
client=client,
_raw=None
)

peer_id = -chat.id

if isinstance(chat, raw.types.ChatEmpty):
Expand Down Expand Up @@ -444,6 +458,13 @@ def _parse_chat_chat(client, chat: raw.types.Chat) -> "Chat":

@staticmethod
def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
if isinstance(channel, int):
return Chat(
id=utils.get_channel_id(channel),
client=client,
_raw=None
)

peer_id = utils.get_channel_id(channel.id)

if isinstance(channel, raw.types.ChannelForbidden):
Expand Down