2016-10-29 16:47:38 +02:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from telegram.ext import Updater
|
2016-11-12 13:37:14 +01:00
|
|
|
from src.handlers.message_handler import MessageHandler
|
|
|
|
from src.handlers.command_handler import CommandHandler
|
|
|
|
from src.handlers.status_handler import StatusHandler
|
|
|
|
from . import chat_purge_queue
|
2016-11-01 22:01:40 +01:00
|
|
|
|
2016-10-29 16:47:38 +02:00
|
|
|
|
|
|
|
class Bot:
|
|
|
|
def __init__(self, config):
|
|
|
|
self.config = config
|
|
|
|
self.updater = Updater(token=config['bot']['token'])
|
|
|
|
self.dispatcher = self.updater.dispatcher
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
logging.info("Bot started")
|
2016-11-12 13:37:14 +01:00
|
|
|
|
|
|
|
chat_purge_queue.init(
|
2016-11-10 17:04:02 +01:00
|
|
|
queue=self.updater.job_queue,
|
|
|
|
default_interval=self.config['bot']['purge_interval']
|
|
|
|
)
|
|
|
|
|
2016-11-12 13:37:14 +01:00
|
|
|
self.dispatcher.add_handler(MessageHandler(self.config))
|
|
|
|
self.dispatcher.add_handler(CommandHandler(self.config))
|
|
|
|
self.dispatcher.add_handler(StatusHandler(self.config))
|
2016-11-09 21:41:56 +01:00
|
|
|
|
2016-10-29 16:47:38 +02:00
|
|
|
self.updater.start_polling()
|
2016-11-09 21:41:56 +01:00
|
|
|
self.updater.idle()
|