Skip to content

Commit 4b11008

Browse files
feat: add full_name property to User and Chat objects
1 parent 9f51c49 commit 4b11008

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

hydrogram/types/user_and_chats/chat.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class Chat(Object):
6969
last_name (``str``, *optional*):
7070
Last name of the other party in a private chat, for private chats.
7171
72+
full_name (``str``, *property*):
73+
Full name of the other party in a private chat, for private chats and bots.
74+
7275
photo (:obj:`~hydrogram.types.ChatPhoto`, *optional*):
7376
Chat photo. Suitable for downloads only.
7477
@@ -199,6 +202,10 @@ def __init__(
199202
self.send_as_chat = send_as_chat
200203
self.available_reactions = available_reactions
201204

205+
@property
206+
def full_name(self) -> str:
207+
return " ".join(filter(None, [self.first_name, self.last_name])) or None
208+
202209
@staticmethod
203210
def _parse_user_chat(client, user: raw.types.User) -> "Chat":
204211
peer_id = user.id

hydrogram/types/user_and_chats/user.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class User(Object, Update):
101101
last_name (``str``, *optional*):
102102
User's or bot's last name.
103103
104+
full_name (``str``, *property*):
105+
Full name of the other party in a private chat.
106+
104107
status (:obj:`~hydrogram.enums.UserStatus`, *optional*):
105108
User's last seen & online status. ``None``, for bots.
106109
@@ -198,6 +201,10 @@ def __init__(
198201
self.photo = photo
199202
self.restrictions = restrictions
200203

204+
@property
205+
def full_name(self) -> str:
206+
return " ".join(filter(None, [self.first_name, self.last_name])) or None
207+
201208
@property
202209
def mention(self):
203210
return Link(

0 commit comments

Comments
 (0)