mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +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)
|
||||
|
||||
def defaultplugin(self, irc, msg, args):
|
||||
"""<command> [<plugin>]
|
||||
"""<command> [<plugin>] [--remove]
|
||||
|
||||
Calls <command> from <plugin> by default, rather than complaining about
|
||||
multiple plugins providing it. If <plugin> is not provided, remove the
|
||||
currently used default plugin.
|
||||
multiple plugins providing it. If <plugin> is not provided, shows the
|
||||
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 = callbacks.canonicalName(command)
|
||||
cbs = callbacks.findCallbackForCommand(irc, command)
|
||||
@ -173,9 +180,12 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
||||
self.defaultPlugins[command] = plugin
|
||||
else:
|
||||
try:
|
||||
del self.defaultPlugins[command]
|
||||
if remove:
|
||||
del self.defaultPlugins[command]
|
||||
else:
|
||||
irc.reply(msg, self.defaultPlugins[command])
|
||||
except KeyError:
|
||||
irc.error(msg, 'I have no default for that command.')
|
||||
irc.error(msg,'I have no default plugin for that command.')
|
||||
return
|
||||
irc.reply(msg, conf.replySuccess)
|
||||
|
||||
|
@ -40,7 +40,8 @@ class OwnerTestCase(PluginTestCase, PluginDocumentation):
|
||||
self.assertError('whois osu.edu')
|
||||
self.assertNotError('defaultplugin whois network')
|
||||
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('defaultplugin asdlfkjasdflkjsad Owner')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user