Added Owner.rename, to rename commands.

This commit is contained in:
Jeremy Fincher 2004-08-03 07:20:53 +00:00
parent 86f2cb8efa
commit 2eedf7dfad
2 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,6 @@
* Added Owner.rename, a command for renaming commands in other
plugins.
* Added a new plugin, Tail, which will tail logfiles and send the
new lines to a configurable list of targets.

View File

@ -622,6 +622,31 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
raise
irc.error('That command wasn\'t disabled.')
def rename(self, irc, msg, args):
"""<plugin> <command> <new name>
Renames <command> in <plugin> to the <new name>.
"""
(plugin, command, newName) = privmsgs.getArgs(args, required=3)
name = callbacks.canonicalName(newName)
if name != newName:
irc.error('%s is a not a valid new command name. '
'Try making it lowercase and removing - and _.' %newName)
return
cb = irc.getCallback(plugin)
if cb is None:
irc.error('%s is not a valid plugin.' % plugin)
return
if not cb.isCommand(command):
s = '%s is not a valid command in the %s plugin.' % (name, plugin)
irc.error(s)
return
method = getattr(cb.__class__, command)
setattr(cb.__class__, name, method)
delattr(cb.__class__, command)
irc.replySuccess()
Class = Owner