mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-01 13:14:52 +00:00
Pyrofork: Move Non-fragment username from {chat,user}.usernames to {chat,user}.username
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
207d0929d8
commit
e4964e8470
2 changed files with 12 additions and 4 deletions
|
|
@ -268,12 +268,16 @@ class Chat(Object):
|
|||
def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
|
||||
peer_id = utils.get_channel_id(channel.id)
|
||||
restriction_reason = getattr(channel, "restriction_reason", [])
|
||||
user_name = getattr(channel, "username", None)
|
||||
active_usernames = getattr(channel, "usernames", [])
|
||||
usernames = None
|
||||
if len(active_usernames) >= 1:
|
||||
usernames = []
|
||||
for username in active_usernames:
|
||||
usernames.append(types.Username._parse(username))
|
||||
if username.editable:
|
||||
user_name = username.username
|
||||
else:
|
||||
usernames.append(types.Username._parse(username))
|
||||
|
||||
return Chat(
|
||||
id=peer_id,
|
||||
|
|
@ -285,7 +289,7 @@ class Chat(Object):
|
|||
is_fake=getattr(channel, "fake", None),
|
||||
is_forum=getattr(channel, "forum", None),
|
||||
title=channel.title,
|
||||
username=getattr(channel, "username", None),
|
||||
username=user_name,
|
||||
usernames=usernames,
|
||||
photo=types.ChatPhoto._parse(client, getattr(channel, "photo", None), peer_id,
|
||||
getattr(channel, "access_hash", 0)),
|
||||
|
|
|
|||
|
|
@ -229,12 +229,16 @@ class User(Object, Update):
|
|||
def _parse(client, user: "raw.base.User") -> Optional["User"]:
|
||||
if user is None or isinstance(user, raw.types.UserEmpty):
|
||||
return None
|
||||
user_name = user.username
|
||||
active_usernames = getattr(user, "usernames", [])
|
||||
usernames = None
|
||||
if len(active_usernames) >= 1:
|
||||
usernames = []
|
||||
for username in active_usernames:
|
||||
usernames.append(types.Username._parse(username))
|
||||
if username.editable:
|
||||
user_name = username.username
|
||||
else:
|
||||
usernames.append(types.Username._parse(username))
|
||||
|
||||
return User(
|
||||
id=user.id,
|
||||
|
|
@ -252,7 +256,7 @@ class User(Object, Update):
|
|||
first_name=user.first_name,
|
||||
last_name=user.last_name,
|
||||
**User._parse_status(user.status, user.bot),
|
||||
username=user.username,
|
||||
username=user_name,
|
||||
usernames=usernames,
|
||||
language_code=user.lang_code,
|
||||
emoji_status=types.EmojiStatus._parse(client, user.emoji_status),
|
||||
|
|
|
|||
Loading…
Reference in a new issue