Added the ability for configuration variables to be private so they can't have their values gotten by people who can't change them.

This commit is contained in:
Jeremy Fincher 2004-02-14 00:47:21 +00:00
parent 38cf55ebce
commit fb59b25a63
3 changed files with 12 additions and 3 deletions

View File

@ -75,7 +75,7 @@ conf.registerChannelValue(conf.supybot.plugins.Services, 'nick',
services."""))
conf.registerChannelValue(conf.supybot.plugins.Services, 'password',
registry.String('', """Determines what password the bot will use with
services."""))
services.""", private=True))
conf.registerChannelValue(conf.supybot.plugins.Services, 'NickServ',
ValidNickOrEmptyString('', """Determines what nick the 'NickServ' service
has."""))

View File

@ -162,7 +162,14 @@ class Config(callbacks.Privmsg):
name = self._canonicalizeName(name)
wrapper = getWrapper(name)
if hasattr(wrapper, 'value'):
irc.reply(str(wrapper))
if not wrapper.private:
irc.reply(str(wrapper))
else:
capability = getCapability(name)
if ircdb.checkCapability(msg.prefix, capability):
irc.reply(str(wrapper))
else:
irc.errorNoCapability(capability)
else:
irc.error('That registry variable has no value. Use the list '
'command in this plugin to see what values are '

View File

@ -191,9 +191,11 @@ class Group(object):
class Value(Group):
def __init__(self, default, help, showDefault=True, **kwargs):
def __init__(self, default, help,
private=False, showDefault=True, **kwargs):
Group.__init__(self, **kwargs)
self.default = default
self.private = private
self.showDefault = showDefault
self.help = utils.normalizeWhitespace(help.strip())
self.setValue(default)