From 2a0b9e645d056b32b7abd99c686005ebe5f7dd0d Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 2 Dec 2004 05:08:53 +0000 Subject: [PATCH] Finished conversion to commands.wrap, and fixed some bugs. --- src/Owner.py | 51 +++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/src/Owner.py b/src/Owner.py index db3862b26..5e1327a42 100644 --- a/src/Owner.py +++ b/src/Owner.py @@ -719,63 +719,54 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): irc.replySuccess() disable = wrap(disable, [optional('plugin'), 'commandName']) - def enable(self, irc, msg, args): + def enable(self, irc, msg, args, plugin, command): """[] Enables the command for all users. If if given, only enables the from . This command is the inverse of disable. """ - (plugin, command) = privmsgs.getArgs(args, optional=1) try: - if not command: - (plugin, command) = (None, plugin) - conf.supybot.commands.disabled().remove(command) + if plugin: + command = '%s.%s' % (plugin.name(), command) + self._disabled.remove(command, plugin.name()) else: - name = '%s.%s' % (plugin, command) - conf.supybot.commands.disabled().remove(name) - self._disabled.remove(command, plugin) + self._disabled.remove(command) + conf.supybot.commands.disabled().remove(command) irc.replySuccess() except KeyError: irc.error('That command wasn\'t disabled.') + enable = wrap(enable, [optional('plugin'), 'commandName']) - def rename(self, irc, msg, args): + def rename(self, irc, msg, args, plugin, command, newName): """ Renames in to the . """ - (plugin, command, newName) = privmsgs.getArgs(args, required=3) - name = callbacks.canonicalName(newName) - if name != newName: - irc.errorInvalid('command name', name, - 'Try making it lowercase and removing dashes ' - 'and underscores.', Raise=True) - cb = irc.getCallback(plugin) - if cb is None: - irc.errorInvalid('plugin', plugin, Raise=True) - if not cb.isCommand(command): - what = 'command in the %s plugin' % plugin - irc.errorInvalid(what, name, Raise=True) - if hasattr(cb, name): + if not plugin.isCommand(command): + what = 'command in the %s plugin' % plugin.name() + irc.errorInvalid(what, command) + if hasattr(plugin, newName): irc.error('The %s plugin already has an attribute named %s.' % - (plugin, name)) + (plugin, newName)) return - registerRename(cb.name(), command, name) - renameCommand(cb, command, newName) + registerRename(plugin.name(), command, newName) + renameCommand(plugin, command, newName) irc.replySuccess() + rename = wrap(rename, ['plugin', 'commandName', 'commandName']) - def unrename(self, irc, msg, args): + def unrename(self, irc, msg, args, plugin): """ Removes all renames in . The plugin will be reloaded after this command is run. """ - plugin = privmsgs.getArgs(args) try: - conf.supybot.commands.renames.unregister(plugin) + conf.supybot.commands.renames.unregister(plugin.name()) except registry.NonExistentRegistryEntry: - irc.errorInvalid('plugin', plugin, Raise=True) - self.reload(irc, msg, args) # This makes the replySuccess. + irc.errorInvalid('plugin', plugin.name()) + self.reload(irc, msg, [plugin.name()]) # This makes the replySuccess. + unrename = wrap(unrename, ['plugin']) Class = Owner