Exclude empty first_name in get_display_name

This commit is contained in:
Christian Stemmle 2017-06-15 00:02:36 +02:00
parent fc915b2284
commit 45fb1f3f26

View File

@ -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):