Skip to content

Commit

Permalink
Pyrofork: types: {chat,user}: Use first fragments username as normal …
Browse files Browse the repository at this point in the history
…username if normal username is None

Signed-off-by: wulan17 <[email protected]>
  • Loading branch information
wulan17 committed Jan 3, 2024
1 parent 348d617 commit a8505f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyrogram/types/user_and_chats/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
user_name = username.username
else:
usernames.append(types.Username._parse(username))
if user_name is None and usernames is not None and len(usernames) > 0:
user_name = usernames[0].username
usernames.pop(username[0])

return Chat(
id=peer_id,
Expand Down
3 changes: 3 additions & 0 deletions pyrogram/types/user_and_chats/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ def _parse(client, user: "raw.base.User") -> Optional["User"]:
user_name = username.username
else:
usernames.append(types.Username._parse(username))
if user_name is None and usernames is not None and len(usernames) > 0:
user_name = usernames[0].username
usernames.pop(username[0])

return User(
id=user.id,
Expand Down

0 comments on commit a8505f8

Please sign in to comment.