2022-07-10 12:07:26 +00:00
|
|
|
import logging
|
2022-07-08 19:23:12 +00:00
|
|
|
import os
|
2022-07-10 12:07:26 +00:00
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
2022-07-08 19:23:12 +00:00
|
|
|
from rss import RssReader
|
|
|
|
from update_manager import UpdateManager
|
|
|
|
from database import Database
|
|
|
|
from telegram import Notifier
|
2022-07-10 12:07:26 +00:00
|
|
|
|
2022-07-08 23:49:12 +00:00
|
|
|
|
|
|
|
load_dotenv()
|
2022-07-08 19:23:12 +00:00
|
|
|
|
2022-07-11 00:25:44 +00:00
|
|
|
token = os.getenv('RSSBOT_TG_TOKEN')
|
|
|
|
db_dsn = os.getenv('RSSBOT_DSN')
|
2022-07-10 12:07:26 +00:00
|
|
|
log_level = os.getenv('LOG_LEVEL', 'INFO')
|
|
|
|
|
|
|
|
print('Starting the updater with logging level', log_level.upper())
|
|
|
|
logging.basicConfig(
|
|
|
|
level=log_level.upper(),
|
|
|
|
format='%(asctime)s: <%(name)s> [%(levelname)s] %(message)s',
|
|
|
|
datefmt='%Y-%m-%d %H:%M:%S'
|
|
|
|
)
|
2022-07-08 19:23:12 +00:00
|
|
|
|
2022-07-11 00:25:44 +00:00
|
|
|
db = Database(db_dsn, logging.getLogger('Database'))
|
2022-07-10 12:07:26 +00:00
|
|
|
notifier = Notifier(token, logging.getLogger('Notifier'))
|
|
|
|
rss_reader = RssReader(logging.getLogger('RssReader'))
|
2022-07-08 19:23:12 +00:00
|
|
|
|
2022-07-10 12:07:26 +00:00
|
|
|
updater = UpdateManager(db, notifier, rss_reader, logging.getLogger('UpdateManager'))
|
2022-07-08 19:23:12 +00:00
|
|
|
updater.update()
|