workaround for connection problems

This commit is contained in:
Rripped
2022-03-29 12:04:49 +02:00
parent 4c517998ba
commit 4afd1ab87b
3 changed files with 39 additions and 14 deletions

View File

@@ -245,12 +245,12 @@ def send_news(message):
user_id = int(message.from_user.id)
keywords = api_handler.get_user_keywords(user_id)
keyword_search = 'OR'.join(keywords)
keywords_search = ','.join(keywords)
news_list = api_handler.get_news_for_keyword(keyword_search)['articles']
news_list = news.get_top_news_by_keyword(keywords_search)["articles"]
for news in news_list:
formatted_article = news.format_article(news)
for article in news_list:
formatted_article = news.format_article(article)
bot.send_message(chat_id=user_id, text=formatted_article, parse_mode="MARKDOWN")
@@ -275,6 +275,7 @@ def store_keyword(message):
api_handler.set_keyword(user_id, keyword)
bot.send_message(chat_id=user_id, text=f'Keyword "{keyword}" added.')
@bot.message_handler(commands=['removekeyword'])
def remove_keyword(message):
""" Remove keyword from user
@@ -296,6 +297,21 @@ def remove_keyword_step(message):
bot.send_message(chat_id=user_id, text=f'Keyword "{keyword}" removed.')
@bot.message_handler(commands=['keywords'])
def send_keywords(message):
""" Send keywords of user
:type message: message object bot
:param message: message that was reacted to, in this case always '/keywords'
:raises: none
:rtype: none
"""
user_id = int(message.from_user.id)
keywords = api_handler.get_user_keywords(user_id)
bot.send_message(chat_id=user_id, text=f'Your keywords are: {keywords}')
@bot.message_handler(func=lambda message: True) # Returning that command is unkown for any other statement
def echo_all(message):