Add word includer
need to modify args.json too
This commit is contained in:
21
worker.py
21
worker.py
@@ -56,7 +56,11 @@ class Worker:
|
|||||||
if not article['id'] in list:
|
if not article['id'] in list:
|
||||||
try:
|
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:
|
try:
|
||||||
bot.send_message(TELEGRAM_CHANNEL_ID, f"*Artículo*: {article['title']}\n"
|
bot.send_message(TELEGRAM_CHANNEL_ID, f"*Artículo*: {article['title']}\n"
|
||||||
f"*Descripción*: {article['description']}\n"
|
f"*Descripción*: {article['description']}\n"
|
||||||
@@ -97,6 +101,21 @@ class Worker:
|
|||||||
if word in title:
|
if word in title:
|
||||||
return True
|
return True
|
||||||
return False
|
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):
|
def get_average_time(self, exec_times):
|
||||||
sum = 0
|
sum = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user