From 6b648e5dbeba44cfdb321f17fdc934fba102e7c9 Mon Sep 17 00:00:00 2001 From: Rykov7 Date: Wed, 2 Nov 2022 12:36:05 +0300 Subject: [PATCH] fix bug checking url entities in message --- app/bot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/bot.py b/app/bot.py index 603a6c6..525dc02 100644 --- a/app/bot.py +++ b/app/bot.py @@ -19,6 +19,7 @@ app = Flask(__name__) print(">>> LutzBot is running! <<<") + zen_rows = ['Beautiful is better than ugly.', 'Explicit is better than implicit.', 'Simple is better than complex.', 'Complex is better than complicated.', 'Flat is better than nested.', 'Sparse is better than dense.', 'Readability counts.', @@ -63,9 +64,10 @@ def check_delete_list(type_message: types.Message) -> bool: for phrase in unwanted_phrases: if phrase in type_message.text.casefold(): return True - for entity in type_message.entities: - if phrase in entity.url: - return True + if type_message.entities: + for entity in type_message.entities: + if entity.url and phrase in entity.url: + return True @bot.message_handler(func=check_delete_list, content_types=['text'])