From d05be1706099278ea35771fea613431175f99a8d Mon Sep 17 00:00:00 2001 From: mr-brune <49653622+mr-brune@users.noreply.github.com> Date: Fri, 14 Apr 2023 08:10:57 +0200 Subject: [PATCH] Add word includer need to modify args.json too --- worker.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/worker.py b/worker.py index bf2c12f..42285ae 100644 --- a/worker.py +++ b/worker.py @@ -56,7 +56,11 @@ class Worker: if not article['id'] in list: try: - if not self.has_excluded_words(article['title'].lower(), article['description'].lower(), args['exclude']) and not self.is_title_key_word_excluded(article['title'].lower(), args['title_keyword_exclude']): + if (not self.has_excluded_words(article['title'].lower(), article['description'].lower(), args['exclude']) + and not self.is_title_key_word_excluded(article['title'].lower(), args['title_keyword_exclude']) + and (self.has_included_words(article['title'].lower(), article['description'].lower(), args['include']) + or self.is_title_key_word_included(article['title'].lower(), args['title_keyword_include']))): + try: bot.send_message(TELEGRAM_CHANNEL_ID, f"*Artículo*: {article['title']}\n" f"*Descripción*: {article['description']}\n" @@ -97,6 +101,21 @@ class Worker: if word in title: return True return False + + def has_included_words(self, title, description, included_words): + for word in included_words: + print("INCLUDER: Checking '" + word + "' for title: '" + title) + if word in title or word in description: + print("INCLUDE!") + return True + return False + + def is_title_key_word_included(self, title, included_words): + for word in included_words: + print("Checking '" + word + "' for title: '" + title) + if word in title: + return True + return False def get_average_time(self, exec_times): sum = 0