mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-07 15:34: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,11 +268,15 @@ class Chat(Object):
|
||||||
def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
|
def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
|
||||||
peer_id = utils.get_channel_id(channel.id)
|
peer_id = utils.get_channel_id(channel.id)
|
||||||
restriction_reason = getattr(channel, "restriction_reason", [])
|
restriction_reason = getattr(channel, "restriction_reason", [])
|
||||||
|
user_name = getattr(channel, "username", None)
|
||||||
active_usernames = getattr(channel, "usernames", [])
|
active_usernames = getattr(channel, "usernames", [])
|
||||||
usernames = None
|
usernames = None
|
||||||
if len(active_usernames) >= 1:
|
if len(active_usernames) >= 1:
|
||||||
usernames = []
|
usernames = []
|
||||||
for username in active_usernames:
|
for username in active_usernames:
|
||||||
|
if username.editable:
|
||||||
|
user_name = username.username
|
||||||
|
else:
|
||||||
usernames.append(types.Username._parse(username))
|
usernames.append(types.Username._parse(username))
|
||||||
|
|
||||||
return Chat(
|
return Chat(
|
||||||
|
|
@ -285,7 +289,7 @@ class Chat(Object):
|
||||||
is_fake=getattr(channel, "fake", None),
|
is_fake=getattr(channel, "fake", None),
|
||||||
is_forum=getattr(channel, "forum", None),
|
is_forum=getattr(channel, "forum", None),
|
||||||
title=channel.title,
|
title=channel.title,
|
||||||
username=getattr(channel, "username", None),
|
username=user_name,
|
||||||
usernames=usernames,
|
usernames=usernames,
|
||||||
photo=types.ChatPhoto._parse(client, getattr(channel, "photo", None), peer_id,
|
photo=types.ChatPhoto._parse(client, getattr(channel, "photo", None), peer_id,
|
||||||
getattr(channel, "access_hash", 0)),
|
getattr(channel, "access_hash", 0)),
|
||||||
|
|
|
||||||
|
|
@ -229,11 +229,15 @@ class User(Object, Update):
|
||||||
def _parse(client, user: "raw.base.User") -> Optional["User"]:
|
def _parse(client, user: "raw.base.User") -> Optional["User"]:
|
||||||
if user is None or isinstance(user, raw.types.UserEmpty):
|
if user is None or isinstance(user, raw.types.UserEmpty):
|
||||||
return None
|
return None
|
||||||
|
user_name = user.username
|
||||||
active_usernames = getattr(user, "usernames", [])
|
active_usernames = getattr(user, "usernames", [])
|
||||||
usernames = None
|
usernames = None
|
||||||
if len(active_usernames) >= 1:
|
if len(active_usernames) >= 1:
|
||||||
usernames = []
|
usernames = []
|
||||||
for username in active_usernames:
|
for username in active_usernames:
|
||||||
|
if username.editable:
|
||||||
|
user_name = username.username
|
||||||
|
else:
|
||||||
usernames.append(types.Username._parse(username))
|
usernames.append(types.Username._parse(username))
|
||||||
|
|
||||||
return User(
|
return User(
|
||||||
|
|
@ -252,7 +256,7 @@ class User(Object, Update):
|
||||||
first_name=user.first_name,
|
first_name=user.first_name,
|
||||||
last_name=user.last_name,
|
last_name=user.last_name,
|
||||||
**User._parse_status(user.status, user.bot),
|
**User._parse_status(user.status, user.bot),
|
||||||
username=user.username,
|
username=user_name,
|
||||||
usernames=usernames,
|
usernames=usernames,
|
||||||
language_code=user.lang_code,
|
language_code=user.lang_code,
|
||||||
emoji_status=types.EmojiStatus._parse(client, user.emoji_status),
|
emoji_status=types.EmojiStatus._parse(client, user.emoji_status),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue