Skip to content

Commit fa38483

Browse files
authored
1 parent 0582930 commit fa38483

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

pyrogram/types/messages_and_media/message.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -885,14 +885,21 @@ async def _parse(
885885
_requested_users.append(
886886
types.Chat._parse_user_chat(
887887
client,
888-
users.get(raw_peer_id)
888+
users.get(raw_peer_id, raw_peer_id)
889+
)
890+
)
891+
elif isinstance(requested_peer, raw.types.PeerChat):
892+
_requested_chats.append(
893+
types.Chat._parse_chat_chat(
894+
client,
895+
chats.get(raw_peer_id, raw_peer_id)
889896
)
890897
)
891898
else:
892899
_requested_chats.append(
893-
types.Chat._parse_chat(
900+
types.Chat._parse_channel_chat(
894901
client,
895-
chats.get(raw_peer_id)
902+
chats.get(raw_peer_id, raw_peer_id)
896903
)
897904
)
898905

pyrogram/types/user_and_chats/chat.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,13 @@ def __init__(
362362

363363
@staticmethod
364364
def _parse_user_chat(client, user: raw.types.User) -> "Chat":
365+
if isinstance(user, int):
366+
return Chat(
367+
id=user,
368+
client=client,
369+
_raw=None
370+
)
371+
365372
peer_id = user.id
366373

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

409416
@staticmethod
410417
def _parse_chat_chat(client, chat: raw.types.Chat) -> "Chat":
418+
if isinstance(chat, int):
419+
return Chat(
420+
id=-chat,
421+
client=client,
422+
_raw=None
423+
)
424+
411425
peer_id = -chat.id
412426

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

445459
@staticmethod
446460
def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
461+
if isinstance(channel, int):
462+
return Chat(
463+
id=utils.get_channel_id(channel),
464+
client=client,
465+
_raw=None
466+
)
467+
447468
peer_id = utils.get_channel_id(channel.id)
448469

449470
if isinstance(channel, raw.types.ChannelForbidden):

0 commit comments

Comments
 (0)