From 45fb1f3f2608d718dd39f5f82a654894b2587855 Mon Sep 17 00:00:00 2001 From: Christian Stemmle Date: Thu, 15 Jun 2017 00:02:36 +0200 Subject: [PATCH] Exclude empty first_name in get_display_name --- telethon/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/telethon/utils.py b/telethon/utils.py index 7d11ef17..fba2a674 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -14,8 +14,10 @@ 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) + elif entity.last_name: + return entity.last_name return entity.first_name if isinstance(entity, Chat) or isinstance(entity, Channel):