Merge pull request #920 from GLolol/misc/better-help

Misc: give better help when command isn't found but coincides w/ the name of a loaded plugin
This commit is contained in:
Valentin Lorentz 2014-11-27 10:03:26 +01:00
commit 261a9c4d2a

View File

@ -179,6 +179,10 @@ class Misc(callbacks.Plugin):
else: else:
pass # Let's just do nothing, I can't think of better. pass # Let's just do nothing, I can't think of better.
def isPublic(self, cb):
name = cb.name()
return conf.supybot.plugins.get(name).public()
@internationalizeDocstring @internationalizeDocstring
def list(self, irc, msg, args, optlist, cb): def list(self, irc, msg, args, optlist, cb):
"""[--private] [--unloaded] [<plugin>] """[--private] [--unloaded] [<plugin>]
@ -222,12 +226,9 @@ class Misc(callbacks.Plugin):
plugins.sort() plugins.sort()
irc.reply(format('%L', plugins)) irc.reply(format('%L', plugins))
else: else:
def isPublic(cb):
name = cb.name()
return conf.supybot.plugins.get(name).public()
names = [cb.name() for cb in irc.callbacks names = [cb.name() for cb in irc.callbacks
if (private and not isPublic(cb)) or if (private and not self.isPublic(cb)) or
(not private and isPublic(cb))] (not private and self.isPublic(cb))]
names.sort() names.sort()
if names: if names:
irc.reply(format('%L', names)) irc.reply(format('%L', names))
@ -298,8 +299,15 @@ class Misc(callbacks.Plugin):
assert cbs, 'Odd, maxL == command, but no cbs.' assert cbs, 'Odd, maxL == command, but no cbs.'
irc.reply(_.__call__(cbs[0].getCommandHelp(command, False))) irc.reply(_.__call__(cbs[0].getCommandHelp(command, False)))
else: else:
irc.error(format(_('There is no command %q.'), plugins = [cb.name() for cb in irc.callbacks
callbacks.formatCommand(command))) if self.isPublic(cb)]
s = format(_('There is no command %q.'),
callbacks.formatCommand(command))
if command[0].lower() in map(str.lower, plugins):
s += (' However, "{0}" is the name of a loaded plugin, and '
'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, [many('something')])
@internationalizeDocstring @internationalizeDocstring