diff --git a/plugins/Config/plugin.py b/plugins/Config/plugin.py index 5de90c61e..21ea0ce31 100644 --- a/plugins/Config/plugin.py +++ b/plugins/Config/plugin.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2002-2005, Jeremiah Fincher +# Copyright (c) 2009, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -85,7 +86,6 @@ def _hupHandler(sig, frame): if os.name == 'posix': signal.signal(signal.SIGHUP, _hupHandler) - def getConfigVar(irc, msg, args, state): name = args[0] if name.startswith('conf.'): @@ -100,6 +100,13 @@ def getConfigVar(irc, msg, args, state): state.errorInvalid('configuration variable', str(e)) addConverter('configVar', getConfigVar) +def getSettableConfigVar(irc, msg, args, state): + getConfigVar(irc, msg, args, state) + if not hasattr(state.args[-1], 'set'): + state.errorInvalid('settable configuration variable', + state.args[-1]._name) +addConverter('settableConfigVar', getSettableConfigVar) + class Config(callbacks.Plugin): def callCommand(self, command, irc, msg, *args, **kwargs): try: @@ -195,7 +202,8 @@ class Config(callbacks.Plugin): self._setValue(irc, msg, group, value) else: self._getValue(irc, msg, group) - channel = wrap(channel, ['channel', 'configVar', additional('text')]) + channel = wrap(channel, ['channel', 'settableConfigVar', + additional('text')]) def config(self, irc, msg, args, group, value): """ [] @@ -208,7 +216,7 @@ class Config(callbacks.Plugin): self._setValue(irc, msg, group, value) else: self._getValue(irc, msg, group) - config = wrap(config, ['configVar', additional('text')]) + config = wrap(config, ['settableConfigVar', additional('text')]) def help(self, irc, msg, args, group): """ @@ -236,7 +244,7 @@ class Config(callbacks.Plugin): """ v = group.__class__(group._default, '') irc.reply(str(v)) - default = wrap(default, ['configVar']) + default = wrap(default, ['settableConfigVar']) def reload(self, irc, msg, args): """takes no arguments diff --git a/plugins/Config/test.py b/plugins/Config/test.py index 0a8bd4439..49130b08e 100644 --- a/plugins/Config/test.py +++ b/plugins/Config/test.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2002-2005, Jeremiah Fincher +# Copyright (c) 2009, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -77,7 +78,7 @@ class ConfigTestCase(ChannelPluginTestCase): self.assertRegexp('config supybot.repl', 'not a valid') self.assertRegexp('config supybot.reply.withNickPrefix 123', 'True or False') - + self.assertRegexp('config supybot.replies foo', 'settable') # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: