mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 06:00:42 +01:00
Made defaultplugin show the default plugin for a command if not given a plugin.
This commit is contained in:
parent
ee5de6e0d7
commit
882b872d7c
20
src/Owner.py
20
src/Owner.py
@ -157,12 +157,19 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
callbacks.IrcObjectProxy(irc, msg, tokens)
|
callbacks.IrcObjectProxy(irc, msg, tokens)
|
||||||
|
|
||||||
def defaultplugin(self, irc, msg, args):
|
def defaultplugin(self, irc, msg, args):
|
||||||
"""<command> [<plugin>]
|
"""<command> [<plugin>] [--remove]
|
||||||
|
|
||||||
Calls <command> from <plugin> by default, rather than complaining about
|
Calls <command> from <plugin> by default, rather than complaining about
|
||||||
multiple plugins providing it. If <plugin> is not provided, remove the
|
multiple plugins providing it. If <plugin> is not provided, shows the
|
||||||
currently used default plugin.
|
current default plugin for <command>. If --remove is given, removes
|
||||||
|
the current default plugin for <command>.
|
||||||
"""
|
"""
|
||||||
|
if '--remove' in args:
|
||||||
|
while '--remove' in args:
|
||||||
|
args.remove('--remove')
|
||||||
|
remove = True
|
||||||
|
else:
|
||||||
|
remove = False
|
||||||
(command, plugin) = privmsgs.getArgs(args, optional=1)
|
(command, plugin) = privmsgs.getArgs(args, optional=1)
|
||||||
command = callbacks.canonicalName(command)
|
command = callbacks.canonicalName(command)
|
||||||
cbs = callbacks.findCallbackForCommand(irc, command)
|
cbs = callbacks.findCallbackForCommand(irc, command)
|
||||||
@ -173,9 +180,12 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
self.defaultPlugins[command] = plugin
|
self.defaultPlugins[command] = plugin
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
del self.defaultPlugins[command]
|
if remove:
|
||||||
|
del self.defaultPlugins[command]
|
||||||
|
else:
|
||||||
|
irc.reply(msg, self.defaultPlugins[command])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error(msg, 'I have no default for that command.')
|
irc.error(msg,'I have no default plugin for that command.')
|
||||||
return
|
return
|
||||||
irc.reply(msg, conf.replySuccess)
|
irc.reply(msg, conf.replySuccess)
|
||||||
|
|
||||||
|
@ -40,7 +40,8 @@ class OwnerTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertError('whois osu.edu')
|
self.assertError('whois osu.edu')
|
||||||
self.assertNotError('defaultplugin whois network')
|
self.assertNotError('defaultplugin whois network')
|
||||||
self.assertNotError('whois osu.edu')
|
self.assertNotError('whois osu.edu')
|
||||||
self.assertNotError('defaultplugin whois')
|
self.assertResponse('defaultplugin whois', 'network')
|
||||||
|
self.assertNotError('defaultplugin --remove whois')
|
||||||
self.assertError('whois osu.edu')
|
self.assertError('whois osu.edu')
|
||||||
self.assertError('defaultplugin asdlfkjasdflkjsad Owner')
|
self.assertError('defaultplugin asdlfkjasdflkjsad Owner')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user