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 1/2] 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 From 049718836d9ddb0655e5bafd12cc8acbe6e9eef1 Mon Sep 17 00:00:00 2001 From: mr-brune <49653622+mr-brune@users.noreply.github.com> Date: Mon, 17 Apr 2023 07:57:07 +0200 Subject: [PATCH 2/2] Update args.json --- args.json | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/args.json b/args.json index 7924c76..9daa294 100644 --- a/args.json +++ b/args.json @@ -8,7 +8,9 @@ "min_price": "20", "max_price": "75", "title_keyword_exclude" : [], - "exclude": [] + "exclude": [], + "title_keyword_include" : [], + "include": [] }, { "product_name": "ram", @@ -19,7 +21,9 @@ "min_price": "10", "max_price": "40", "title_keyword_exclude" : [], - "exclude": [] + "exclude": [], + "title_keyword_include" : [], + "include": ["8gb"] }, { "product_name": "grafica", @@ -30,7 +34,9 @@ "min_price": "90", "max_price": "200", "title_keyword_exclude" : [], - "exclude": ["1050", "960"] + "exclude": ["1050", "960"], + "title_keyword_include" : [], + "include": [] }, { "product_name": "nvidia", @@ -41,7 +47,9 @@ "min_price": "90", "max_price": "200", "title_keyword_exclude" : [], - "exclude": ["1050", "960"] + "exclude": ["1050", "960"], + "title_keyword_include" : [], + "include": [] }, { "product_name": "gtx", @@ -52,6 +60,8 @@ "min_price": "90", "max_price": "200", "title_keyword_exclude" : [], - "exclude": ["1050", "960"] + "exclude": ["1050", "960"], + "title_keyword_include" : [], + "include": [] } ]