From f5bf5129a94473a88fc139778fb2839e8811b3f4 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 5 Dec 2014 19:05:01 -0800 Subject: [PATCH] Misc: add ability to specify custom help URLs when 'help' is ran without arguments --- plugins/Misc/config.py | 3 +++ plugins/Misc/plugin.py | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/Misc/config.py b/plugins/Misc/config.py index 810c21db5..73e71c327 100644 --- a/plugins/Misc/config.py +++ b/plugins/Misc/config.py @@ -49,6 +49,9 @@ conf.registerGlobalValue(Misc, 'listPrivatePlugins', plugins with the list command if given the --private switch. If this is disabled, non-owner users should be unable to see what private plugins are loaded."""))) +conf.registerGlobalValue(Misc, 'customHelpString', + registry.String('', _("""Sets a custom help string, displayed when the 'help' + command is called without arguments."""))) conf.registerGlobalValue(Misc, 'listUnloadedPlugins', registry.Boolean(False, _("""Determines whether the bot will list unloaded plugins with the list command if given the --unloaded switch. If this is diff --git a/plugins/Misc/plugin.py b/plugins/Misc/plugin.py index 9b184578d..51c129380 100644 --- a/plugins/Misc/plugin.py +++ b/plugins/Misc/plugin.py @@ -47,6 +47,7 @@ import supybot.irclib as irclib import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.callbacks as callbacks +import supybot.registry as registry from supybot import commands from supybot.i18n import PluginInternationalization, internationalizeDocstring @@ -289,6 +290,18 @@ class Misc(callbacks.Plugin): You may also want to use the 'list' command to list all available plugins and commands. """ + if not command: + cHelp = self.registryValue("customHelpString") + if cHelp: + irc.reply(cHelp) + return + try: + renames = conf.supybot.commands.renames.get("Misc")() + if "help" in renames: + ourcmd = conf.supybot.commands.renames.get("Misc").get("help")() + except registry.NonExistentRegistryEntry: + ourcmd = "help" + command = ["misc", ourcmd] command = list(map(callbacks.canonicalName, command)) (maxL, cbs) = irc.findCallbacksForArgs(command) if maxL == command: @@ -310,7 +323,7 @@ class Misc(callbacks.Plugin): 'you may be able to find its provided commands ' 'using \'list {0}\'.'.format(command[0].title())) irc.error(s) - help = wrap(help, [many('something')]) + help = wrap(help, [any('something')]) @internationalizeDocstring def version(self, irc, msg, args):