mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 20:14:51 +00:00
PyroFork: Add usernames field to User
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
73c1c179d0
commit
9d9b8dcac8
1 changed files with 13 additions and 0 deletions
|
|
@ -119,6 +119,10 @@ class User(Object, Update):
|
|||
username (``str``, *optional*):
|
||||
User's or bot's username.
|
||||
|
||||
usernames (List of :obj:`~pyrogram.types.Username`, *optional*):
|
||||
List of all chat (fragment) usernames; for private chats, supergroups and channels.
|
||||
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
||||
|
||||
language_code (``str``, *optional*):
|
||||
IETF language tag of the user's language.
|
||||
|
||||
|
|
@ -173,6 +177,7 @@ class User(Object, Update):
|
|||
last_online_date: datetime = None,
|
||||
next_offline_date: datetime = None,
|
||||
username: str = None,
|
||||
usernames: List["types.Username"] = None,
|
||||
language_code: str = None,
|
||||
emoji_status: Optional["types.EmojiStatus"] = None,
|
||||
dc_id: int = None,
|
||||
|
|
@ -200,6 +205,7 @@ class User(Object, Update):
|
|||
self.last_online_date = last_online_date
|
||||
self.next_offline_date = next_offline_date
|
||||
self.username = username
|
||||
self.usernames = usernames
|
||||
self.language_code = language_code
|
||||
self.emoji_status = emoji_status
|
||||
self.dc_id = dc_id
|
||||
|
|
@ -223,6 +229,12 @@ 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
|
||||
active_usernames = getattr(user, "usernames", [])
|
||||
usernames = None
|
||||
if len(active_usernames) >= 1:
|
||||
usernames = []
|
||||
for username in active_usernames:
|
||||
usernames.append(types.Username._parse(username))
|
||||
|
||||
return User(
|
||||
id=user.id,
|
||||
|
|
@ -241,6 +253,7 @@ class User(Object, Update):
|
|||
last_name=user.last_name,
|
||||
**User._parse_status(user.status, user.bot),
|
||||
username=user.username,
|
||||
usernames=usernames,
|
||||
language_code=user.lang_code,
|
||||
emoji_status=types.EmojiStatus._parse(client, user.emoji_status),
|
||||
dc_id=getattr(user.photo, "dc_id", None),
|
||||
|
|
|
|||
Loading…
Reference in a new issue