add abcs.Peer resolving to resolve_to_packed

This commit is contained in:
apepenkov 2023-11-09 23:54:01 +03:00
parent 17996e8a9b
commit 27d6cce8e2

View File

@ -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)