Example #1
0
    def list(self, irc, msg, args, optlist, cb):
        """[--private] [<plugin>]

        Lists the commands available in the given plugin.  If no plugin is
        given, lists the public plugins available.  If --private is given,
        lists the private plugins.
        """
        private = False
        for (option, argument) in optlist:
            if option == "private":
                private = True
                if not self.registryValue("listPrivatePlugins") and not ircdb.checkCapability(msg.prefix, "owner"):
                    irc.errorNoCapability("owner")
        if not cb:

            def isPublic(cb):
                name = cb.name()
                return conf.supybot.plugins.get(name).public()

            names = [
                cb.name() for cb in irc.callbacks if (private and not isPublic(cb)) or (not private and isPublic(cb))
            ]
            names.sort()
            if names:
                irc.reply(format("%L", names))
            else:
                if private:
                    irc.reply("There are no private plugins.")
                else:
                    irc.reply("There are no public plugins.")
        else:
            commands = cb.listCommands()
            if commands:
                commands.sort()
                irc.reply(format("%L", commands))
            else:
                irc.reply(
                    format(
                        "That plugin exists, but has no commands.  "
                        "This probably means that it has some "
                        "configuration variables that can be "
                        "changed in order to modify its behavior.  "
                        'Try "config list supybot.plugins.%s" to see '
                        "what configuration variables it has.",
                        cb.name(),
                    )
                )
Example #2
0
    def list(self, irc, msg, args, optlist, cb):
        """[--private] [--unloaded] [<plugin>]

        Lists the commands available in the given plugin.  If no plugin is
        given, lists the public plugins available.  If --private is given,
        lists the private plugins. If --unloaded is given, it will list
        available plugins that are not loaded.
        """
        private = False
        unloaded = False
        for (option, argument) in optlist:
            if option == 'private':
                private = True
                if not self.registryValue('listPrivatePlugins') and \
                   not ircdb.checkCapability(msg.prefix, 'owner'):
                    irc.errorNoCapability('owner')
            elif option == 'unloaded':
                unloaded = True
                if not self.registryValue('listUnloadedPlugins') and \
                   not ircdb.checkCapability(msg.prefix, 'owner'):
                    irc.errorNoCapability('owner')
        if unloaded and private:
            irc.error(_('--private and --unloaded are uncompatible options.'))
            return
        if not cb:
            if unloaded:
                # We were using the path of Misc + .. to detect the install
                # directory. However, it fails if Misc is not in the
                # installation directory for some reason, so we use a
                # supybot module.
                installedPluginsDirectory = os.path.join(
                        os.path.dirname(conf.__file__), 'plugins')
                plugins = getPluginsInDirectory(installedPluginsDirectory)
                for directory in conf.supybot.directories.plugins()[:]:
                    plugins.extend(getPluginsInDirectory(directory))
                # Remove loaded plugins:
                loadedPlugins = [x.name() for x in irc.callbacks]
                plugins = [x for x in plugins if x not in loadedPlugins]

                plugins.sort()
                irc.reply(format('%L', plugins))
            else:
                def isPublic(cb):
                    name = cb.name()
                    return conf.supybot.plugins.get(name).public()
                names = [cb.name() for cb in irc.callbacks
                         if (private and not isPublic(cb)) or
                            (not private and isPublic(cb))]
                names.sort()
                if names:
                    irc.reply(format('%L', names))
                else:
                    if private:
                        irc.reply(_('There are no private plugins.'))
                    else:
                        irc.reply(_('There are no public plugins.'))
        else:
            commands = cb.listCommands()
            if commands:
                commands.sort()
                irc.reply(format('%L', commands))
            else:
                irc.reply(format(_('That plugin exists, but has no commands.  '
                                 'This probably means that it has some '
                                 'configuration variables that can be '
                                 'changed in order to modify its behavior.  '
                                 'Try "config list supybot.plugins.%s" to see '
                                 'what configuration variables it has.'),
                                 cb.name()))
Example #3
0
 def listCommands(self):
     commands = callbacks.PluginRegexp.listCommands(self)
     commands.remove("messcb")
     commands.extend(mess.keys())
     commands.sort()
     return commands