fixed errors
This commit is contained in:
@@ -37,7 +37,6 @@ class User: # Currently saving users in this class to test functionality -> late
|
||||
self.chat_id = int(p_chat_id)
|
||||
self.user_name = str(p_user_name)
|
||||
|
||||
print(os.getenv('BOT_API_KEY'))
|
||||
bot = telebot.TeleBot(os.getenv('BOT_API_KEY'))
|
||||
|
||||
@bot.message_handler(commands=['start']) # /start -> saving as new user and sending welcome
|
||||
@@ -89,10 +88,16 @@ def send_update(message):
|
||||
|
||||
@bot.message_handler(commands=['news']) # /news -> send news by keyword
|
||||
def send_news(message):
|
||||
keyword = "business"
|
||||
user_id = int(message.from_user.id)
|
||||
#Get Information for user with this id
|
||||
articles = news_fetcher.get_top_news_by_keyword("bitcoin") #tbd: get keyword from db
|
||||
formatted_article = news_fetcher.format_article(articles["articles"][0])
|
||||
|
||||
articles = news_fetcher.get_top_news_by_keyword(keyword) #tbd: get keyword from db
|
||||
try:
|
||||
formatted_article = news_fetcher.format_article(articles["articles"][0])
|
||||
except IndexError:
|
||||
bot.send_message(chat_id=user_id, text=f"no news currently available for keyword: {keyword}")
|
||||
return
|
||||
bot.send_message(chat_id=user_id, text=formatted_article)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user