-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
38 lines (30 loc) · 812 Bytes
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from sys import exit as sysexit
import logging
from telegram.ext import Updater
from dbhelper import DBHelper
from plugins.release_radar import Plugin as ReleaseRadar
try:
from dotenv import load_dotenv
load_dotenv()
except ImportError:
pass
TOKEN = os.environ.get('BOT_TOKEN')
if not TOKEN:
print("Cannot find BOT_TOKEN")
sysexit()
db = DBHelper()
db.setup()
plugins = [
ReleaseRadar(db)
]
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
updater = Updater(token=TOKEN)
dispatcher = updater.dispatcher
for plugin in plugins:
if not plugin: continue
for handler in plugin.handlers:
if not handler: continue
dispatcher.add_handler(handler, plugin.group)
updater.start_polling()
updater.idle()