26 lines
785 B
Python
Raw Normal View History

from .config.credentials import bot_token
2021-09-18 15:30:56 +02:00
from .config.handlers import handlers
from .handlers.handlerInterface import HandlerInterface
from telegram.ext.dispatcher import Dispatcher
from telegram.ext import Updater
class App:
updater: Updater
dispatcher: Dispatcher
def __init__(self):
self.updater = Updater(bot_token)
def run(self) -> None:
self.registerHandlers()
self.updater.start_polling()
2021-09-18 15:30:56 +02:00
self.updater.idle()
def registerHandlers(self) -> None:
for handler in handlers:
if not isinstance(handler, HandlerInterface):
raise Exception('Invalid list of handlers provided. Handler must implement HandlerInterface')
self.updater.dispatcher.add_handler(handler.getBotHandler())