imaginaryfriend/src/bot.py

30 lines
898 B
Python
Raw Normal View History

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
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))
self.updater.start_polling()
self.updater.idle()