mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-27 13:12:45 +01:00
Added Owner.rename, to rename commands.
This commit is contained in:
parent
86f2cb8efa
commit
2eedf7dfad
@ -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.
|
||||
|
||||
|
25
src/Owner.py
25
src/Owner.py
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user