【问题标题】:How to set the configuration of a plugin correctly in Errbot?如何在 Errbot 中正确设置插件的配置?
【发布时间】:2018-06-08 13:44:37
【问题描述】:

我尝试按照文档给出的示例进行操作:

9.1. Plugin configuration through the built-in !config command

但是,我无法取回设置为'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 谢谢你的帮助

【问题讨论】:

    标签: python plugins configuration errbot


    【解决方案1】:

    你需要发送带有 json 配置的 config 命令,这里 errbot 只是告诉你需要做什么来配置它。

    【讨论】:

      猜你喜欢
      • 2020-10-31
      • 2021-02-13
      • 1970-01-01
      • 2013-10-25
      • 2021-03-31
      • 1970-01-01
      • 1970-01-01
      • 2019-11-21
      • 2012-05-25
      相关资源
      最近更新 更多