From 64177b533cd363551621b0bce740ea1aafb18c08 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 5c84ff65..9c98bedd 100644 --- a/pyrogram/client.py +++ b/pyrogram/client.py @@ -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)):