def register_plugins(): plugins = config.get_config(lambda x: x["telebot"]["plugins"], None) if not isinstance(plugins, list): return for plugin_module in plugins: logger.debug("Plugin '{}' is going to be registered".format(plugin_module)) __import__(plugin_module, globals(), locals(), [], -1)
def bot_servant(): api_token = config.get_config(lambda x: x["telebot"]["api_key"]) if api_token is None: init_logger = logging.getLogger("telebot_init") init_logger.fatal("Telegram API token is not specified") raise Exception lich = bot.TelegramBot(api_token) yield lich.poll()
def register_storage(): ephemeral_storage_plugin = config.get_config( lambda x: x['telebot']['ephemeral_storage_plugin'], 'local_storage' ) persistent_storage_plugin = config.get_config( lambda x: x['telebot']['persistent_storage_plugin'], 'local_storage' ) global EphemeralStorage, PersistentStorage logger.debug("Storage plugin '{}' is going to be registered as ephemeral".format(ephemeral_storage_plugin)) _ephemeral_module = __import__(ephemeral_storage_plugin, globals(), locals(), [], -1) EphemeralStorage = _ephemeral_module.EphemeralStorage logger.debug("Storage plugin '{}' is going to be registered as persistent".format(persistent_storage_plugin)) _persistent_module = __import__(persistent_storage_plugin, globals(), locals(), [], -1) PersistentStorage = _persistent_module.PersistentStorage