diff --git a/HSMensaW_botA.py b/HSMensaW_botA.py index 498ce0b..67bd57c 100644 --- a/HSMensaW_botA.py +++ b/HSMensaW_botA.py @@ -210,10 +210,15 @@ def get_bot_id() -> int: def get_chat_name(msg: dict) -> str: + chat = "" if msg["chat"]["type"] == "group": chat = msg["chat"]["title"] + " (g)" elif msg["chat"]["type"] == "private": - chat = msg["chat"]["first_name"] + " " + msg["chat"]["last_name"] + " (p)" + if "first_name" in msg["chat"].keys(): + chat = msg["chat"]["first_name"] + " " + if "last_name" in msg["chat"].keys(): + chat += msg["chat"]["last_name"] + " " + chat += "(p)" else: chat = "null" return chat