I try to follow the sample given by the documentation:
9.1. Plugin configuration through the built-in !config command
However, I do not manage in getting back the configuration of the plugin which is set to '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
This is my plugin code 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 am not sure if it is a bug or a bad configuration.
Solution
I had to call once the configuration given
[@admin ➡ @errbot] >>> !plugin config Samples {'ID_TOKEN' : '00112233445566778899aabbccddeeff', 'USERNAME':'changeme'}
Plugin configuration done.
[@admin ➡ @errbot] >>> !mycommand
00112233445566778899aabbccddeeff
@gbin Thank you for your help
You need to send the config command with the json config, here errbot just tells you what you need to do to configure it.