From 2de8f1921cd68a88d5b3a6755c10baf85d1685fe Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Fri, 30 Dec 2022 18:07:15 +0100 Subject: [PATCH] Fix resolving peers for users with multiple usernames This currently makes it work for the first available username only --- pyrogram/client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyrogram/client.py b/pyrogram/client.py index f4f6eee3..7848c1f5 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -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)):