Update chat username parsing in case of multiple usernames

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
Dan 2023-03-11 16:45:32 +01:00 committed by wulan17
parent 3163030574
commit 8940c7d1f6
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5

View file

@ -478,7 +478,11 @@ class Client(Methods):
elif isinstance(peer, (raw.types.Channel, raw.types.ChannelForbidden)):
peer_id = utils.get_channel_id(peer.id)
access_hash = peer.access_hash
username = (getattr(peer, "username", None) or "").lower() or None
username = (
peer.username.lower() if peer.username
else peer.usernames[0].username.lower() if peer.usernames
else None
)
peer_type = "channel" if peer.broadcast else "supergroup"
else:
continue