implemented /news and deleted debugbot (edit BOT_API_KEY instead) #2

Merged
Rripped merged 40 commits from bot-features into main 2022-03-16 09:08:43 +00:00
4 changed files with 40 additions and 3 deletions
Showing only changes of commit 32d45053ec - Show all commits

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
.env
env
__pycache__/*
telegram_bot/__pycache__/*
telegram_bot/__pycache__/*
telegram_bot/news/__pycache__/*

View File

@ -21,8 +21,12 @@ import time
import sys
import logging
<<<<<<< HEAD
import news_fetcher
import share_fetcher
=======
import news.news_fetcher as news
>>>>>>> 725f9806b7109b68219cc273edc616c1059ee4bb
from telebot import types
from dotenv import load_dotenv
@ -184,9 +188,9 @@ def send_news(message):
user_id = int(message.from_user.id)
#Get Information for user with this id
articles = news_fetcher.get_top_news_by_keyword(keyword) #tbd: get keyword from db
articles = news.get_top_news_by_keyword(keyword) #tbd: get keyword from db
try:
formatted_article = news_fetcher.format_article(articles["articles"][0])
formatted_article = news.format_article(articles["articles"][0])
except IndexError:
bot.send_message(chat_id=user_id, text=f"no news currently available for keyword: {keyword}")
return

View File

@ -0,0 +1,32 @@
{
"status": "ok",
"totalResults": 1,
"articles": [
{
"source": {
"id": "the-verge",
"name": "The Verge"
},
"author": "Justine Calma",
"title": "EU Parliament backs off plans to phase out energy-hungry cryptocurrencies",
"description": "EU Parliament abandoned a measure in its proposed legislative framework for regulating cryptocurrencies that would have amounted to a de facto ban on energy-hungry networks like Bitcoin.",
"url": "https://www.theverge.com/2022/3/14/22977132/bitcoin-european-union-parliament-ban-proof-of-work-cryptocurrencies",
"urlToImage": "https://cdn.vox-cdn.com/thumbor/8bE-uBwwu-eXg-CcB6cOqcAGVDw=/0x286:4000x2380/fit-in/1200x630/cdn.vox-cdn.com/uploads/chorus_asset/file/23315944/834392892.jpg",
"publishedAt": "2022-03-14T23:40:25Z",
"content": "But Bitcoin is still under scrutiny \r\nPower cords for bitcoin mining machines are plugged into electrical outlets at a mining facility operated by Bitmain Technologies Ltd. in Ordos, Inner Mongolia, \u2026 [+5797 chars]"
},
{
"source": {
"id": "the-verge",
"name": "The Verge"
},
"author": "Justine Calma",
"title": "EU Parliament backs off plans to phase out energy-hungry cryptocurrencies",
"description": "EU Parliament abandoned a measure in its proposed legislative framework for regulating cryptocurrencies that would have amounted to a de facto ban on energy-hungry networks like Bitcoin.",
"url": "https://www.theverge.com/2022/3/14/22977132/bitcoin-european-union-parliament-ban-proof-of-work-cryptocurrencies",
"urlToImage": "https://cdn.vox-cdn.com/thumbor/8bE-uBwwu-eXg-CcB6cOqcAGVDw=/0x286:4000x2380/fit-in/1200x630/cdn.vox-cdn.com/uploads/chorus_asset/file/23315944/834392892.jpg",
"publishedAt": "2022-03-14T23:40:25Z",
"content": "But Bitcoin is still under scrutiny \r\nPower cords for bitcoin mining machines are plugged into electrical outlets at a mining facility operated by Bitmain Technologies Ltd. in Ordos, Inner Mongolia, \u2026 [+5797 chars]"
}
]
}