JungDev / django-telegrambot

Simple app for Telegram bot in Django
BSD 3-Clause "New" or "Revised" License
237 stars 88 forks source link

"" #19

Closed Burtx closed 6 years ago

Burtx commented 6 years ago

Hello I am using python telegram bot 10 and they added the argument in the updater to updater = Updater("TOKEN", use_context=True). This will be the default going forward. How do I add the argument in the module exist function

    def module_exists(module_name, method_name, execute):
        try:
            m = importlib.import_module(module_name)
            if execute and hasattr(m, method_name):
                logger.debug('Run {}.{}()'.format(module_name,method_name))
                getattr(m, method_name)()
            else:
                logger.debug('Run {}'.format(module_name))

        except ImportError as er:
            logger.debug('{} : {}'.format(module_name, repr(er)))
            return False

        return True

    # import telegram bot handlers for all INSTALLED_APPS
    for app_config in apps.get_app_configs():
        if module_has_submodule(app_config.module, TELEGRAM_BOT_MODULE_NAME):
            module_name = '%s.%s' % (app_config.name, TELEGRAM_BOT_MODULE_NAME)
            if module_exists(module_name, 'main', True):
                logger.info('Loaded {}'.format(module_name))