Exemple #1
0
    def init_plugins(self):
        plugins = []

        logging.debug('Importing plugins...')

        if type(self.config.plugins) is list:
            plugins_to_load = self.config.plugins
        elif self.config.plugins == 'all':
            plugins_to_load = load_plugin_list()
        else:
            plugins_to_load = load_plugin_list()

        for plugin in plugins_to_load:
            try:
                plugins.append(
                    importlib.import_module('polaris.plugins.' +
                                            plugin).plugin(self))
                logging.debug('  [OK] %s ' % (plugin))
            except Exception as e:
                logging.error('  [Failed] %s - %s ' % (plugin, str(e)))

        logging.debug('  Loaded: ' + str(len(plugins)) + '/' +
                      str(len(plugins_to_load)))

        return plugins
Exemple #2
0
    def init_plugins(self):
        plugins = []

        logging.debug('Importing plugins...')

        plugins_list = []

        if self.config.plugins == 'all':
            plugins_to_load = load_plugin_list()
        elif self.config.plugins == 'all':
            plugins_to_load = self.config.plugins

        if 'excluded_plugins' in self.config:
            plugins_to_load = [
                p for p in plugins_to_load
                if p not in self.config.excluded_plugins
            ]

        for plugin in plugins_to_load:
            try:
                plugins.append(
                    importlib.import_module('polaris.plugins.' +
                                            plugin).plugin(self))
                logging.debug('  [OK] {} '.format(plugin))
            except Exception as e:
                logging.error('  [Failed] {} - {} '.format(plugin, str(e)))

        logging.debug('  Loaded: ' + str(len(plugins)) + '/' +
                      str(len(plugins_to_load)))

        return plugins
Exemple #3
0
    def init_plugins(self):
        plugins = []

        logging.info('Importing plugins...')

        if type(self.config.plugins) is list:
            plugins_to_load = self.config.plugins
        elif self.config.plugins == 'all':
            plugins_to_load = load_plugin_list()
        else:
            plugins_to_load = load_plugin_list()

        for plugin in plugins_to_load:
            try:
                plugins.append(importlib.import_module('polaris.plugins.' + plugin).plugin(self))
                logging.info('  [OK] %s ' % (plugin))
            except Exception as e:
                logging.error('  [Failed] %s - %s ' % (plugin, str(e)))

        logging.info('  Loaded: ' + str(len(plugins)) + '/' + str(len(plugins_to_load)))

        return plugins
Exemple #4
0
    def bot_config(name):
        config = AutosaveDict('bots/%s.json' % name)

        i = 1
        finished = False
        while not finished:
            text = 'Editing /bots/%s.json\n' % name

            if 'bindings' in config:
                bindings = config['bindings']
            else:
                bindings = 'telegram-bot-api'

            if 'bindings_token' in config:
                bindings_token = config['bindings_token']
            else:
                bindings_token = 'YOUR TELEGRAM BOT TOKEN'

            if 'command_start' in config:
                command_start = config['command_start']
            else:
                command_start = '/'

            if 'owner' in config:
                owner = config['owner']
            else:
                owner = 0

            if 'debug' in config:
                debug = config['debug']
            else:
                debug = False

            if 'language' in config:
                language = config['language']
            else:
                language = 'default'

            if 'plugins' in config:
                plugins = config['plugins']
            else:
                plugins = load_plugin_list()

            if 'api_keys' in config:
                api_keys = config['api_keys']
            else:
                api_keys = {}

            text += '(0) Finish editing\n'
            text += '(1) bindings: %s\n' % bindings
            text += '(2) bindings_token: %s\n' % bindings_token
            text += '(3) command_start: %s\n' % command_start
            text += '(4) owner: %s\n' % owner
            text += '(5) debug: %s\n' % debug
            text += '(6) language: %s\n' % language
            text += '(7) plugins: %s\n' % plugins
            text += '(8) api_keys: %s\n' % api_keys

            option = int(input(text))
            if option == 0:
                print('Saving all values to "bots/%s.json".' % name)
                config.bindings = bindings
                config.bindings_token = bindings_token
                config.command_start = command_start
                config.owner = owner
                config.debug = debug
                config.language = language
                config.plugins = plugins
                config.api_keys = api_keys
                finished = True

            elif option == 1:
                option = input(
                    'What bindings want to use? (Current value: "%s")\n' %
                    bindings)
                config.bindings = option
Exemple #5
0
    def bot_config(name):
        config = AutosaveDict('bots/%s.json' % name)

        i = 1
        finished = False
        while not finished:
            text = 'Editing /bots/%s.json\n' % name

            if 'bindings' in config:
                bindings = config['bindings']
            else:
                bindings = 'telegram-bot-api'

            if 'bindings_token' in config:
                bindings_token = config['bindings_token']
            else:
                bindings_token = 'YOUR TELEGRAM BOT TOKEN'

            if 'command_start' in config:
                command_start = config['command_start']
            else:
                command_start = '/'

            if 'owner' in config:
                owner = config['owner']
            else:
                owner = 0

            if 'debug' in config:
                debug = config['debug']
            else:
                debug = False

            if 'language' in config:
                language = config['language']
            else:
                language = 'default'

            if 'plugins' in config:
                plugins = config['plugins']
            else:
                plugins = load_plugin_list()

            if 'api_keys' in config:
                api_keys = config['api_keys']
            else:
                api_keys = {}

            text += '(0) Finish editing\n'
            text += '(1) bindings: %s\n' % bindings
            text += '(2) bindings_token: %s\n' % bindings_token
            text += '(3) command_start: %s\n' % command_start
            text += '(4) owner: %s\n' % owner
            text += '(5) debug: %s\n' % debug
            text += '(6) language: %s\n' % language
            text += '(7) plugins: %s\n' % plugins
            text += '(8) api_keys: %s\n' % api_keys

            option = int(input(text))
            if option == 0:
                print('Saving all values to "bots/%s.json".' % name)
                config.bindings = bindings
                config.bindings_token = bindings_token
                config.command_start = command_start
                config.owner = owner
                config.debug = debug
                config.language = language
                config.plugins = plugins
                config.api_keys = api_keys
                finished = True
            
            elif option == 1:
                option = input('What bindings want to use? (Current value: "%s")\n' % bindings)
                config.bindings = option