mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-04 20:20:23 +03:00
add abcs.Peer resolving to resolve_to_packed
This commit is contained in:
parent
17996e8a9b
commit
27d6cce8e2
|
@ -172,6 +172,28 @@ async def resolve_to_packed(client: Client, chat: ChatLike) -> PackedChat:
|
|||
else:
|
||||
raise RuntimeError("unexpected case")
|
||||
|
||||
if isinstance(chat, abcs.Peer):
|
||||
if isinstance(chat, types.PeerUser):
|
||||
return PackedChat(
|
||||
ty=PackedType.USER,
|
||||
id=chat.user_id,
|
||||
access_hash=0,
|
||||
)
|
||||
elif isinstance(chat, types.PeerChat):
|
||||
return PackedChat(
|
||||
ty=PackedType.CHAT,
|
||||
id=chat.chat_id,
|
||||
access_hash=0,
|
||||
)
|
||||
elif isinstance(chat, types.PeerChannel):
|
||||
return PackedChat(
|
||||
ty=PackedType.BROADCAST,
|
||||
id=chat.channel_id,
|
||||
access_hash=0,
|
||||
)
|
||||
else:
|
||||
raise RuntimeError("unexpected case")
|
||||
|
||||
if isinstance(chat, str):
|
||||
if chat.startswith("+"):
|
||||
resolved = await resolve_phone(client, chat)
|
||||
|
|
Loading…
Reference in New Issue
Block a user