Merge pull request #932 from GLolol/misc/customhelp

Misc: add ability to specify custom help strings
This commit is contained in:
Valentin Lorentz 2014-12-07 09:29:18 +01:00
commit 5fdf8c3c9e
2 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -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,13 @@ 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)
else:
irc.error()
return
command = list(map(callbacks.canonicalName, command))
(maxL, cbs) = irc.findCallbacksForArgs(command)
if maxL == command:
@ -310,7 +318,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):