removed small faults

This commit is contained in:
Linus E 2022-04-25 18:56:19 +02:00
parent 6c99548941
commit 0f4d4e5624

View File

@ -327,11 +327,11 @@ def send_news(message):
top_news = news.get_top_news_by_keyword(keyword)["articles"]
if top_news == None: # true if request to NewsAPI failed
bot.send_message(chat_id=user_id, text='News Server did not respond correctly. Try again later.')
return
if not top_news: # true if no news found for keyword (empty list)
bot.send_message(chat_id=user_id, text=f'No news found for keyword: *{keyword}*', parse_mode="MARKDOWN")
return
else:
formatted_article = news.format_article(top_news[0]) # only format and send most popular news
bot.send_message(chat_id=user_id, text=f"_keyword: {keyword}_\n\n" + formatted_article, parse_mode="MARKDOWN")