supybot.plugins.Plugin.public.

This commit is contained in:
Jeremy Fincher 2004-04-28 08:42:01 +00:00
parent 349245a78e
commit e8470b40c0
3 changed files with 30 additions and 7 deletions

View File

@ -1,3 +1,8 @@
* Added a configuration variable for every plugin, "public", that
determines whether the plugin is considered public (i.e., whether
it will show up in the list command when the list command isn't
given the --private option).
* Added Misc.author, a command for finding out which author
claims a particular plugin.

View File

@ -83,8 +83,10 @@ class Misc(callbacks.Privmsg):
name = privmsgs.getArgs(rest, required=0, optional=1)
name = callbacks.canonicalName(name)
if not name:
names = [cb.name() for cb in irc.callbacks
if evenPrivate or (hasattr(cb, 'public') and cb.public)]
def isPublic(cb):
name = cb.name()
return conf.supybot.plugins.get(name).public() or evenPrivate
names = [cb.name() for cb in irc.callbacks if isPublic(cb)]
names.sort()
irc.reply(utils.commaAndify(names))
else:

View File

@ -99,12 +99,25 @@ def loadPluginModule(name, ignoreDeprecation=False):
linecache.checkcache()
return module
def loadPluginClass(irc, module):
def loadPluginClass(irc, module, register=None):
"""Loads the plugin Class from the given module into the given irc."""
callback = module.Class()
assert not irc.getCallback(callback.name())
irc.addCallback(callback)
cb = module.Class()
name = cb.name()
conf.registerPlugin(name)
public = True
if hasattr(cb, 'public'):
public = cb.public
conf.registerPlugin(name, register)
conf.supybot.plugins.get(name).register('public',
registry.Boolean(public, """Determines whether this plugin is
publically visible."""))
assert not irc.getCallback(name)
irc.addCallback(cb)
return cb
conf.registerPlugin('Owner', True)
conf.supybot.plugins.Owner.register('public', registry.Boolean(True,
"""Determines whether this plugin is publically visible."""))
conf.registerGroup(conf.supybot, 'commands')
conf.registerGroup(conf.supybot.commands, 'defaultPlugins')
conf.supybot.commands.defaultPlugins.help = utils.normalizeWhitespace("""
@ -197,7 +210,8 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
privmsgs.CapabilityCheckingPrivmsg.reset(self)
def do001(self, irc, msg):
self.log.info('Loading other src/ plugins.')
if len(irc.callbacks) < 6:
self.log.info('Loading other src/ plugins.')
for s in ('Admin', 'Channel', 'Config', 'Misc', 'User'):
if irc.getCallback(s) is None:
self.log.info('Loading %s.' % s)
@ -205,6 +219,8 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
loadPluginClass(irc, m)
self.log.info('Loading plugins/ plugins.')
for (name, value) in conf.supybot.plugins.getValues(fullNames=False):
if name.lower() == 'owner':
continue # Just in case.
if irc.getCallback(name) is None:
if value():
if not irc.getCallback(name):