mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-10 20:22:36 +01:00
supybot.plugins.Plugin.public.
This commit is contained in:
parent
349245a78e
commit
e8470b40c0
@ -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
|
* Added Misc.author, a command for finding out which author
|
||||||
claims a particular plugin.
|
claims a particular plugin.
|
||||||
|
|
||||||
|
@ -83,8 +83,10 @@ class Misc(callbacks.Privmsg):
|
|||||||
name = privmsgs.getArgs(rest, required=0, optional=1)
|
name = privmsgs.getArgs(rest, required=0, optional=1)
|
||||||
name = callbacks.canonicalName(name)
|
name = callbacks.canonicalName(name)
|
||||||
if not name:
|
if not name:
|
||||||
names = [cb.name() for cb in irc.callbacks
|
def isPublic(cb):
|
||||||
if evenPrivate or (hasattr(cb, 'public') and cb.public)]
|
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()
|
names.sort()
|
||||||
irc.reply(utils.commaAndify(names))
|
irc.reply(utils.commaAndify(names))
|
||||||
else:
|
else:
|
||||||
|
26
src/Owner.py
26
src/Owner.py
@ -99,12 +99,25 @@ def loadPluginModule(name, ignoreDeprecation=False):
|
|||||||
linecache.checkcache()
|
linecache.checkcache()
|
||||||
return module
|
return module
|
||||||
|
|
||||||
def loadPluginClass(irc, module):
|
def loadPluginClass(irc, module, register=None):
|
||||||
"""Loads the plugin Class from the given module into the given irc."""
|
"""Loads the plugin Class from the given module into the given irc."""
|
||||||
callback = module.Class()
|
cb = module.Class()
|
||||||
assert not irc.getCallback(callback.name())
|
name = cb.name()
|
||||||
irc.addCallback(callback)
|
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')
|
||||||
conf.registerGroup(conf.supybot.commands, 'defaultPlugins')
|
conf.registerGroup(conf.supybot.commands, 'defaultPlugins')
|
||||||
conf.supybot.commands.defaultPlugins.help = utils.normalizeWhitespace("""
|
conf.supybot.commands.defaultPlugins.help = utils.normalizeWhitespace("""
|
||||||
@ -197,7 +210,8 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
privmsgs.CapabilityCheckingPrivmsg.reset(self)
|
privmsgs.CapabilityCheckingPrivmsg.reset(self)
|
||||||
|
|
||||||
def do001(self, irc, msg):
|
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'):
|
for s in ('Admin', 'Channel', 'Config', 'Misc', 'User'):
|
||||||
if irc.getCallback(s) is None:
|
if irc.getCallback(s) is None:
|
||||||
self.log.info('Loading %s.' % s)
|
self.log.info('Loading %s.' % s)
|
||||||
@ -205,6 +219,8 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
loadPluginClass(irc, m)
|
loadPluginClass(irc, m)
|
||||||
self.log.info('Loading plugins/ plugins.')
|
self.log.info('Loading plugins/ plugins.')
|
||||||
for (name, value) in conf.supybot.plugins.getValues(fullNames=False):
|
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 irc.getCallback(name) is None:
|
||||||
if value():
|
if value():
|
||||||
if not irc.getCallback(name):
|
if not irc.getCallback(name):
|
||||||
|
Loading…
Reference in New Issue
Block a user