Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 5b48432

Browse files
Add full_name property to User and Chat objects
1 parent f9a9673 commit 5b48432

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pyrogram/types/user_and_chats/chat.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class Chat(Object):
129129
available_reactions (:obj:`~pyrogram.types.ChatReactions`, *optional*):
130130
Available reactions in the chat.
131131
Returned only in :meth:`~pyrogram.Client.get_chat`.
132+
133+
full_name (``str``, *property*):
134+
Full name of the other party in a private chat, for private chats and bots.
132135
"""
133136

134137
def __init__(
@@ -195,6 +198,10 @@ def __init__(
195198
self.send_as_chat = send_as_chat
196199
self.available_reactions = available_reactions
197200

201+
@property
202+
def full_name(self) -> str:
203+
return " ".join(filter(None, [self.first_name, self.last_name])) or None
204+
198205
@staticmethod
199206
def _parse_user_chat(client, user: raw.types.User) -> "Chat":
200207
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
@@ -203,6 +206,10 @@ def __init__(
203206
self.photo = photo
204207
self.restrictions = restrictions
205208

209+
@property
210+
def full_name(self) -> str:
211+
return " ".join(filter(None, [self.first_name, self.last_name])) or None
212+
206213
@property
207214
def mention(self):
208215
return Link(

0 commit comments

Comments
 (0)