0

我尝试遵循文档给出的示例:

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']

我不确定这是错误还是配置错误。

解决方案

一旦给定配置,我就不得不打电话

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

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

@gbin 谢谢你的帮助

4

1 回答 1

1

您需要使用 json 配置发送 config 命令,这里 errbot 只是告诉您需要做什么来配置它。

于 2018-06-08T16:59:02.940 回答