From 59a169857ca875b408964075d7436a11aa4f86f9 Mon Sep 17 00:00:00 2001 From: F4ria Date: Thu, 11 Jul 2024 18:13:16 +0800 Subject: [PATCH] fix: 'NoneType' object has no attribute 'startswith' --- handlers/useful.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/handlers/useful.py b/handlers/useful.py index f723472..22cb4d7 100644 --- a/handlers/useful.py +++ b/handlers/useful.py @@ -192,8 +192,12 @@ def latest_handle_messages(message: Message, bot: TeleBot): """ignore""" chat_id = message.chat.id chat_user_id = message.from_user.id + # if not text, ignore + if message.text is None: + return + # if is bot command, ignore - if message.text and message.text.startswith("/"): + if message.text.startswith("/"): return # start command ignore elif message.text.startswith( @@ -218,9 +222,6 @@ def latest_handle_messages(message: Message, bot: TeleBot): # answer_it command ignore elif message.text.startswith("answer_it"): return - # if not text, ignore - elif not message.text: - return else: if chat_user_dict.get(chat_user_id): message.text += chat_message_dict[chat_id].text