From fb59b25a633c42a357ad056e6dbfc777dd2e120e Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 14 Feb 2004 00:47:21 +0000 Subject: [PATCH] Added the ability for configuration variables to be private so they can't have their values gotten by people who can't change them. --- plugins/Services.py | 2 +- src/Config.py | 9 ++++++++- src/registry.py | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/Services.py b/plugins/Services.py index 613e9838b..55bfd7353 100644 --- a/plugins/Services.py +++ b/plugins/Services.py @@ -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.""")) diff --git a/src/Config.py b/src/Config.py index c357da839..f6fb5e067 100644 --- a/src/Config.py +++ b/src/Config.py @@ -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 ' diff --git a/src/registry.py b/src/registry.py index 38c7fc0df..849dc53bb 100644 --- a/src/registry.py +++ b/src/registry.py @@ -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)