2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-22 18:07:21 +00:00

Fix resolving peers for users with multiple usernames

This currently makes it work for the first available username only
This commit is contained in:
Dan 2022-12-30 18:07:15 +01:00
parent 3b0dee7dd5
commit 2de8f1921c

View File

@ -487,7 +487,11 @@ class Client(Methods):
if isinstance(peer, raw.types.User):
peer_id = peer.id
access_hash = peer.access_hash
username = (peer.username or "").lower() or None
username = (
peer.username.lower() if peer.username
else peer.usernames[0].username.lower() if peer.usernames
else None
)
phone_number = peer.phone
peer_type = "bot" if peer.bot else "user"
elif isinstance(peer, (raw.types.Chat, raw.types.ChatForbidden)):