mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 04:30:22 +03:00
Exclude empty first_name in get_display_name
This commit is contained in:
parent
fc915b2284
commit
45fb1f3f26
|
@ -14,8 +14,10 @@ def get_display_name(entity):
|
||||||
"""Gets the input peer for the given "entity" (user, chat or channel)
|
"""Gets the input peer for the given "entity" (user, chat or channel)
|
||||||
Returns None if it was not found"""
|
Returns None if it was not found"""
|
||||||
if isinstance(entity, User):
|
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 '{} {}'.format(entity.first_name, entity.last_name)
|
||||||
|
elif entity.last_name:
|
||||||
|
return entity.last_name
|
||||||
return entity.first_name
|
return entity.first_name
|
||||||
|
|
||||||
if isinstance(entity, Chat) or isinstance(entity, Channel):
|
if isinstance(entity, Chat) or isinstance(entity, Channel):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user