Ejemplo n.º 1
0
    def disable(self, irc, msg, args, plugin, command):
        """[<plugin>] <command>

        Disables the command <command> for all users (including the owners).
        If <plugin> is given, only disables the <command> from <plugin>.  If
        you want to disable a command for most users but not for yourself, set
        a default capability of -plugin.command or -command (if you want to
        disable the command in all plugins).
        """
        if command in ('enable', 'identify'):
            irc.error('You can\'t disable %s.' % command)
            return
        if plugin:
            if plugin.isCommand(command):
                pluginCommand = '%s.%s' % (plugin.name(), command)
                conf.supybot.commands.disabled().add(pluginCommand)
                plugin._disabled.add(command)
            else:
                irc.error('%s is not a command in the %s plugin.' %
                          (command, plugin.name()))
                return
        else:
            conf.supybot.commands.disabled().add(command)
            self._disabled.add(command)
        irc.replySuccess()
Ejemplo n.º 2
0
    def disable(self, irc, msg, args, plugin, command):
        """[<plugin>] <command>

        Disables the command <command> for all users (including the owners).
        If <plugin> is given, only disables the <command> from <plugin>.  If
        you want to disable a command for most users but not for yourself, set
        a default capability of -plugin.command or -command (if you want to
        disable the command in all plugins).
        """
        if command in ('enable', 'identify'):
            irc.error('You can\'t disable %s.' % command)
            return
        if plugin:
            if plugin.isCommand(command):
                pluginCommand = '%s.%s' % (plugin.name(), command)
                conf.supybot.commands.disabled().add(pluginCommand)
                plugin._disabled.add(command, plugin.name())
            else:
                irc.error('%s is not a command in the %s plugin.' %
                          (command, plugin.name()))
                return
        else:
            conf.supybot.commands.disabled().add(command)
            self._disabled.add(command)
        irc.replySuccess()
Ejemplo n.º 3
0
    def defaultplugin(self, irc, msg, args, optlist, command, plugin):
        """[--remove] <command> [<plugin>]

        Sets the default plugin for <command> to <plugin>.  If --remove is
        given, removes the current default plugin for <command>.  If no plugin
        is given, returns the current default plugin set for <command>.  See
        also, supybot.commands.defaultPlugins.importantPlugins.
        """
        remove = False
        for (option, arg) in optlist:
            if option == 'remove':
                remove = True
        (_, cbs) = irc.findCallbacksForArgs([command])
        if remove:
            try:
                conf.supybot.commands.defaultPlugins.unregister(command)
                irc.replySuccess()
            except registry.NonExistentRegistryEntry:
                s = 'I don\'t have a default plugin set for that command.'
                irc.error(s)
        elif not cbs:
            irc.errorInvalid('command', command)
        elif plugin:
            if not plugin.isCommand(command):
                irc.errorInvalid('command in the %s plugin' % plugin.name(),
                                 command)
            registerDefaultPlugin(command, plugin.name())
            irc.replySuccess()
        else:
            try:
                irc.reply(conf.supybot.commands.defaultPlugins.get(command)())
            except registry.NonExistentRegistryEntry:
                s = 'I don\'t have a default plugin set for that command.'
                irc.error(s)
Ejemplo n.º 4
0
    def defaultplugin(self, irc, msg, args, optlist, command, plugin):
        """[--remove] <command> [<plugin>]

        Sets the default plugin for <command> to <plugin>.  If --remove is
        given, removes the current default plugin for <command>.  If no plugin
        is given, returns the current default plugin set for <command>.  See
        also, supybot.commands.defaultPlugins.importantPlugins.
        """
        remove = False
        for (option, arg) in optlist:
            if option == 'remove':
                remove = True
        (_, cbs) = irc.findCallbacksForArgs([command])
        if remove:
            try:
                conf.supybot.commands.defaultPlugins.unregister(command)
                irc.replySuccess()
            except registry.NonExistentRegistryEntry:
                s = 'I don\'t have a default plugin set for that command.'
                irc.error(s)
        elif not cbs:
            irc.errorInvalid('command', command)
        elif plugin:
            if not plugin.isCommand(command):
                irc.errorInvalid('command in the %s plugin' % plugin.name(),
                                 command)
            registerDefaultPlugin(command, plugin.name())
            irc.replySuccess()
        else:
            try:
                irc.reply(conf.supybot.commands.defaultPlugins.get(command)())
            except registry.NonExistentRegistryEntry:
                s = 'I don\'t have a default plugin set for that command.'
                irc.error(s)
Ejemplo n.º 5
0
 def unrename(self, irc, msg, args, plugin):
     """<plugin>
     Removes all renames in <plugin>.  The plugin will be reloaded after
     this command is run.
     """
     try:
         conf.supybot.commands.renames.unregister(plugin.name())
     except registry.NonExistentRegistryEntry:
         irc.errorInvalid('plugin', plugin.name())
     self.reload(irc, msg, [plugin.name()])  # This makes the replySuccess.
Ejemplo n.º 6
0
 def unrename(self, irc, msg, args, plugin):
     """<plugin>
     Removes all renames in <plugin>.  The plugin will be reloaded after
     this command is run.
     """
     try:
         conf.supybot.commands.renames.unregister(plugin.name())
     except registry.NonExistentRegistryEntry:
         irc.errorInvalid('plugin', plugin.name())
     self.reload(irc, msg, [plugin.name()])  # This makes the replySuccess.
Ejemplo n.º 7
0
    def rename(self, irc, msg, args, plugin, command, newName):
        """<plugin> <command> <new name>

        Renames <command> in <plugin> to the <new 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, newName))
            return
        registerRename(plugin.name(), command, newName)
        renameCommand(plugin, command, newName)
        irc.replySuccess()
Ejemplo n.º 8
0
    def rename(self, irc, msg, args, plugin, command, newName):
        """<plugin> <command> <new name>

        Renames <command> in <plugin> to the <new 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, newName))
            return
        registerRename(plugin.name(), command, newName)
        renameCommand(plugin, command, newName)
        irc.replySuccess()
Ejemplo n.º 9
0
 def enable(self, irc, msg, args, plugin, command):
     """[<plugin>] <command>
     Enables the command <command> for all users.  If <plugin>
     if given, only enables the <command> from <plugin>.  This command is
     the inverse of disable.
     """
     try:
         if plugin:
             plugin._disabled.remove(command, plugin.name())
             command = '%s.%s' % (plugin.name(), command)
         else:
             self._disabled.remove(command)
         conf.supybot.commands.disabled().remove(command)
         irc.replySuccess()
     except KeyError:
         irc.error('That command wasn\'t disabled.')
Ejemplo n.º 10
0
 def enable(self, irc, msg, args, plugin, command):
     """[<plugin>] <command>
     Enables the command <command> for all users.  If <plugin>
     if given, only enables the <command> from <plugin>.  This command is
     the inverse of disable.
     """
     try:
         if plugin:
             plugin._disabled.remove(command, plugin.name())
             command = '%s.%s' % (plugin.name(), command)
         else:
             self._disabled.remove(command)
         conf.supybot.commands.disabled().remove(command)
         irc.replySuccess()
     except KeyError:
         irc.error('That command wasn\'t disabled.')