mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-22 10:42:55 +01:00
Finished conversion to commands.wrap, and fixed some bugs.
This commit is contained in:
parent
cbba7c6115
commit
2a0b9e645d
51
src/Owner.py
51
src/Owner.py
@ -719,63 +719,54 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
disable = wrap(disable, [optional('plugin'), 'commandName'])
|
disable = wrap(disable, [optional('plugin'), 'commandName'])
|
||||||
|
|
||||||
def enable(self, irc, msg, args):
|
def enable(self, irc, msg, args, plugin, command):
|
||||||
"""[<plugin>] <command>
|
"""[<plugin>] <command>
|
||||||
|
|
||||||
Enables the command <command> for all users. If <plugin>
|
Enables the command <command> for all users. If <plugin>
|
||||||
if given, only enables the <command> from <plugin>. This command is
|
if given, only enables the <command> from <plugin>. This command is
|
||||||
the inverse of disable.
|
the inverse of disable.
|
||||||
"""
|
"""
|
||||||
(plugin, command) = privmsgs.getArgs(args, optional=1)
|
|
||||||
try:
|
try:
|
||||||
if not command:
|
if plugin:
|
||||||
(plugin, command) = (None, plugin)
|
command = '%s.%s' % (plugin.name(), command)
|
||||||
conf.supybot.commands.disabled().remove(command)
|
self._disabled.remove(command, plugin.name())
|
||||||
else:
|
else:
|
||||||
name = '%s.%s' % (plugin, command)
|
self._disabled.remove(command)
|
||||||
conf.supybot.commands.disabled().remove(name)
|
conf.supybot.commands.disabled().remove(command)
|
||||||
self._disabled.remove(command, plugin)
|
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error('That command wasn\'t disabled.')
|
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):
|
||||||
"""<plugin> <command> <new name>
|
"""<plugin> <command> <new name>
|
||||||
|
|
||||||
Renames <command> in <plugin> to the <new name>.
|
Renames <command> in <plugin> to the <new name>.
|
||||||
"""
|
"""
|
||||||
(plugin, command, newName) = privmsgs.getArgs(args, required=3)
|
if not plugin.isCommand(command):
|
||||||
name = callbacks.canonicalName(newName)
|
what = 'command in the %s plugin' % plugin.name()
|
||||||
if name != newName:
|
irc.errorInvalid(what, command)
|
||||||
irc.errorInvalid('command name', name,
|
if hasattr(plugin, newName):
|
||||||
'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):
|
|
||||||
irc.error('The %s plugin already has an attribute named %s.' %
|
irc.error('The %s plugin already has an attribute named %s.' %
|
||||||
(plugin, name))
|
(plugin, newName))
|
||||||
return
|
return
|
||||||
registerRename(cb.name(), command, name)
|
registerRename(plugin.name(), command, newName)
|
||||||
renameCommand(cb, command, newName)
|
renameCommand(plugin, command, newName)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
rename = wrap(rename, ['plugin', 'commandName', 'commandName'])
|
||||||
|
|
||||||
def unrename(self, irc, msg, args):
|
def unrename(self, irc, msg, args, plugin):
|
||||||
"""<plugin>
|
"""<plugin>
|
||||||
|
|
||||||
Removes all renames in <plugin>. The plugin will be reloaded after
|
Removes all renames in <plugin>. The plugin will be reloaded after
|
||||||
this command is run.
|
this command is run.
|
||||||
"""
|
"""
|
||||||
plugin = privmsgs.getArgs(args)
|
|
||||||
try:
|
try:
|
||||||
conf.supybot.commands.renames.unregister(plugin)
|
conf.supybot.commands.renames.unregister(plugin.name())
|
||||||
except registry.NonExistentRegistryEntry:
|
except registry.NonExistentRegistryEntry:
|
||||||
irc.errorInvalid('plugin', plugin, Raise=True)
|
irc.errorInvalid('plugin', plugin.name())
|
||||||
self.reload(irc, msg, args) # This makes the replySuccess.
|
self.reload(irc, msg, [plugin.name()]) # This makes the replySuccess.
|
||||||
|
unrename = wrap(unrename, ['plugin'])
|
||||||
|
|
||||||
|
|
||||||
Class = Owner
|
Class = Owner
|
||||||
|
Loading…
Reference in New Issue
Block a user