Skip to content

Commit 9a0e47e

Browse files
alissonlauffernull-nick
authored andcommitted
Add full_name property to User and Chat objects
PR (pyrogram#1194)
1 parent c3d3dbe commit 9a0e47e

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

pyrogram/types/user_and_chats/chat.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class Chat(Object):
132132
133133
usernames (List of :obj:`~pyrogram.types.Username`, *optional*):
134134
The list of chat's collectible (and basic) usernames if availables.
135+
136+
full_name (``str``, *property*):
137+
Full name of the other party in a private chat, for private chats and bots.
135138
"""
136139

137140
def __init__(
@@ -200,6 +203,10 @@ def __init__(
200203
self.available_reactions = available_reactions
201204
self.usernames = usernames
202205

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

pyrogram/types/user_and_chats/user.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ class User(Object, Update):
140140
The list of reasons why this bot might be unavailable to some users.
141141
This field is available only in case *is_restricted* is True.
142142
143+
full_name (``str``, *optional*):
144+
User's or bot's full name.
145+
143146
mention (``str``, *property*):
144147
Generate a text mention for this user.
145148
You can use ``user.mention()`` to mention the user using their first name (styled using html), or
@@ -208,6 +211,10 @@ def __init__(
208211
self.restrictions = restrictions
209212
self.usernames = usernames
210213

214+
@property
215+
def full_name(self) -> str:
216+
return " ".join(filter(None, [self.first_name, self.last_name])) or None
217+
211218
@property
212219
def mention(self):
213220
return Link(

0 commit comments

Comments
 (0)