Как правильно настроить конфигурацию плагина в Errbot? - PullRequest
0 голосов
/ 08 июня 2018

Я стараюсь следовать образцу, указанному в документации:

9.1.Настройка плагина с помощью встроенной команды! Config

Однако мне не удается вернуть конфигурацию плагина, для которой установлено значение 'NoneType'

[@admin ➡ @errbot] >>> !plugin config Samples
Default configuration for this plugin (you can copy and paste this directly as a command):
 !plugin config Samples
{'ID_TOKEN': '00112233445566778899aabbccddeeff', 'USERNAME': 'changeme'}


[@admin ➡ @errbot] >>> !mycommand
Computer says nooo. See logs for details:
 'NoneType' object is not subscriptable

[@admin ➡ @errbot] >>> !about
This is Errbot version 5.2.0

Этомой код плагина sample.py

from errbot import BotPlugin, botcmd

class Samples(BotPlugin):
    """Samples of plugins from Errbot documentation"""

    # 9. Configuration
    # 9.1. Plugin configuration through the built-in !config command
    def get_configuration_template(self):
        return {'ID_TOKEN': '00112233445566778899aabbccddeeff',
                'USERNAME':'changeme'}

    @botcmd
    def mycommand(self, mess, args):
        # oh I need my TOKEN !
        token = self.config['ID_TOKEN']

Я не уверен, что это ошибка или неправильная конфигурация.

Решение

Iпришлось позвонить сразу после настройки

[@admin ➡ @errbot] >>> !plugin config Samples {'ID_TOKEN' : '00112233445566778899aabbccddeeff', 'USERNAME':'changeme'}
Plugin configuration done.

[@admin ➡ @errbot] >>> !mycommand
00112233445566778899aabbccddeeff

@ gbin Спасибо за помощь

1 Ответ

0 голосов
/ 08 июня 2018

Вам нужно отправить команду config с помощью json config, здесь errbot просто говорит вам, что вам нужно сделать, чтобы сконфигурировать ее.

...