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 committed by wulan17
parent 3c0e86a167
commit 64177b533c
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -464,7 +464,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)):