checking for keys in msg dictionary
Signed-off-by: klux2 <k.lux.gm@gmail.com>
This commit is contained in:
parent
84ba13f77c
commit
a4b42c945c
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue