From 33522e4791d333495b5c754a531fcd7cd42fc147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E6=80=BB=E5=8A=A8=E5=91=98?= <73592731+devourbots@users.noreply.github.com> Date: Fri, 7 May 2021 14:04:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- func.py | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/func.py b/func.py index de6660b..c2266c0 100644 --- a/func.py +++ b/func.py @@ -43,26 +43,15 @@ def chat_content_exec(update, context): except Exception as e: username = update.effective_user.id user = update.message.from_user - firstname = "" - lastname = "" - try: - firstname = str(user["first_name"]) - except Exception as e: - print(e) - print("用户没有设置 firstname") - try: - lastname = str(user["last_name"]) - except Exception as e: - print(e) - print("用户没有设置 last_name") - if firstname == "None" and lastname == "None": + firstname = str(user["first_name"]) + lastname = str(user["last_name"]) + name = "" + if firstname != "None": + name = firstname + " " + if lastname != "None": + name += lastname + if len(name) == 0: name = username - elif firstname == "None" and lastname != "None": - name = lastname - elif firstname != "None" and lastname == "None": - name = firstname - elif firstname != "None" and lastname != "None": - name = firstname + " " + lastname print("\n---------------------------") print("内容: " + text[:10]) print("群组类型: " + str(chat_type))