mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +03:00
Handle more cases on .get_display_name
This commit is contained in:
parent
86d45cc276
commit
13199f737e
|
@ -15,9 +15,14 @@ def get_display_name(entity):
|
|||
"""Gets the input peer for the given "entity" (user, chat or channel)
|
||||
Returns None if it was not found"""
|
||||
if isinstance(entity, User):
|
||||
if entity.last_name is not None:
|
||||
if entity.last_name and entity.first_name:
|
||||
return '{} {}'.format(entity.first_name, entity.last_name)
|
||||
return entity.first_name
|
||||
elif entity.first_name:
|
||||
return entity.first_name
|
||||
elif entity.last_name:
|
||||
return entity.last_name
|
||||
else:
|
||||
return '(No name)'
|
||||
|
||||
if isinstance(entity, Chat) or isinstance(entity, Channel):
|
||||
return entity.title
|
||||
|
|
Loading…
Reference in New Issue
Block a user