Ejemplo n.º 1
0
def main():
    """Run bot."""
    assert config.BOT_TOKEN
    updater = Updater(config.BOT_TOKEN, use_context=True)

    Storage.init()

    dispatcher = updater.dispatcher
    dispatcher.add_handler(CommandHandler("start", start))
    dispatcher.add_handler(CommandHandler("help", start))
    dispatcher.add_handler(
        CommandHandler("join", join_group, pass_args=True,
                       pass_chat_data=True))
    dispatcher.add_handler(
        CommandHandler("new", new_group, pass_args=True, pass_chat_data=True))
    updater.dispatcher.add_handler(CallbackQueryHandler(keyboard_callback))
    dispatcher.add_error_handler(error)

    log.info('Bot started')
    updater.start_polling()

    updater.idle()
    log.info(f'Bot shutdown...')
    Storage.close()
Ejemplo n.º 2
0
def storage():
    Storage.init()
    yield
    Storage.close()