Changed setconf to show what the value of the variable is if we don't give something to set it.

This commit is contained in:
Jeremy Fincher 2003-10-30 02:13:12 +00:00
parent 83e16b0d89
commit 47a9d24434
2 changed files with 10 additions and 10 deletions

View File

@ -185,17 +185,17 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
setattr(conf, name, value) setattr(conf, name, value)
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)
elif name: elif name:
typetable = {'mystr': 'string', typeNames = {conf.mystr: 'string',
'mybool': 'boolean', conf.mybool: 'boolean',
'float': 'float'} float: 'float'}
try: try:
vtype = conf.types[name].__name__ type = typeNames[conf.types[name]]
except KeyError: except KeyError:
irc.error(msg, 'That conf variable doesn\'t exist.') irc.error(msg, 'That configuration variable doesn\'t exist.')
return return
try: try:
irc.reply(msg, '%s is a %s.' % (name, typetable[vtype])) value = getattr(conf, name)
irc.reply(msg, '%s is a %s (%s).' % (name, type, value))
except KeyError: except KeyError:
irc.error(msg, '%s is of an unknown type.' % name) irc.error(msg, '%s is of an unknown type.' % name)
else: else:

View File

@ -101,9 +101,9 @@ class OwnerTestCase(PluginTestCase, PluginDocumentation):
def testSetconf(self): def testSetconf(self):
self.assertRegexp('setconf', 'confDir') self.assertRegexp('setconf', 'confDir')
self.assertNotRegexp('setconf', 'allowEval') self.assertNotRegexp('setconf', 'allowEval')
self.assertResponse('setconf confDir', 'confDir is a string.') self.assertResponse('setconf confDir',
self.assertResponse('setconf whackyConfOption', 'confDir is a string (%s).' % conf.confDir)
'Error: That conf variable doesn\'t exist.') self.assertError('setconf whackyConfOption')
try: try:
originalConfAllowEval = conf.allowEval originalConfAllowEval = conf.allowEval
conf.allowEval = False conf.allowEval = False