Improve help command.

This commit is contained in:
Vgr E.Barry 2015-01-02 18:08:19 -05:00
parent df26d8d25e
commit 32fd7b2fa2

View File

@ -5978,12 +5978,11 @@ def get_help(cli, rnick, chan, rest):
splitted = re.split(" +", rest, 1) splitted = re.split(" +", rest, 1)
cname = splitted.pop(0) cname = splitted.pop(0)
rest = splitted[0] if splitted else "" rest = splitted[0] if splitted else ""
found = False
if cname: if cname:
if cname in COMMANDS.keys(): if cname in COMMANDS.keys():
found = True
for fn in COMMANDS[cname]: for fn in COMMANDS[cname]:
if fn.__doc__: if fn.__doc__:
got = True
if callable(fn.__doc__): if callable(fn.__doc__):
msg = botconfig.CMD_CHAR+cname+": "+fn.__doc__(rest) msg = botconfig.CMD_CHAR+cname+": "+fn.__doc__(rest)
if nick == botconfig.CHANNEL: if nick == botconfig.CHANNEL:
@ -5998,17 +5997,22 @@ def get_help(cli, rnick, chan, rest):
cli.notice(nick, msg) cli.notice(nick, msg)
return return
else: else:
got = False
continue continue
else: else:
if not found: if got:
msg = "Command not found." return
elif chan == nick:
pm(cli, nick, "Documentation for this command is not available.")
else: else:
msg = "Documentation for this command is not available." cli.notice(nick, "Documentation for this command is not available.")
if chan == nick:
pm(cli, nick, msg) elif chan == nick:
else: pm(cli, nick, "Command not found.")
cli.notice(nick, msg) else:
return cli.notice(nick, "Command not found.")
return
# if command was not found, or if no command was given: # if command was not found, or if no command was given:
for name, fn in COMMANDS.items(): for name, fn in COMMANDS.items():
if ((name in ("away", "back") and var.OPT_IN_PING) or if ((name in ("away", "back") and var.OPT_IN_PING) or