From 45b534fa03c3e42abbfa1f132837177b72d14bc2 Mon Sep 17 00:00:00 2001 From: James Vega Date: Fri, 18 Jun 2004 20:18:14 +0000 Subject: [PATCH] Make Owner.defaultplugin more robust in it's error detection. --- src/Owner.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Owner.py b/src/Owner.py index 1a37a899c..90b30eb18 100644 --- a/src/Owner.py +++ b/src/Owner.py @@ -175,7 +175,7 @@ class LogErrorHandler(logging.Handler): else: s = record.msg # Send to the owner dudes. - + class Owner(privmsgs.CapabilityCheckingPrivmsg): # This plugin must be first; its priority must be lowest; otherwise odd @@ -363,7 +363,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): irc.error('You must give your bot the --allow-eval option for ' 'this command to be enabled.') _exec = eval - + def announce(self, irc, msg, args): """ @@ -377,7 +377,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): c = ircdb.channels.getChannel(channel) if not c.lobotomized: irc.queueMsg(ircmsgs.privmsg(channel, text)) - + def defaultplugin(self, irc, msg, args): """[--remove] [] @@ -393,9 +393,17 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): (command, plugin) = privmsgs.getArgs(rest, optional=1) command = callbacks.canonicalName(command) cbs = callbacks.findCallbackForCommand(irc, command) + def isDispatcher(cb): + name = callbacks.canonicalName(getattr(cb, 'name')()) + return getattr(cb, name).isDispatcher + # Ensure someone isn't trying to use a plugin for their command + cbs = [cb for cb in cbs if not isDispatcher(cb)] if remove: - conf.supybot.commands.defaultPlugins.unregister(command) - irc.replySuccess() + try: + conf.supybot.commands.defaultPlugins.unregister(command) + irc.replySuccess() + except registry.NonExistentRegistryEntry: + raise callbacks.ArgumentError elif not cbs: irc.error('That\'s not a valid command.') return