From 32fd7b2fa273f05b82134e701345bf2509e56556 Mon Sep 17 00:00:00 2001 From: "Vgr E.Barry" Date: Fri, 2 Jan 2015 18:08:19 -0500 Subject: [PATCH] Improve help command. --- modules/wolfgame.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index 6a97ee6..9c016f1 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -5978,12 +5978,11 @@ def get_help(cli, rnick, chan, rest): splitted = re.split(" +", rest, 1) cname = splitted.pop(0) rest = splitted[0] if splitted else "" - found = False if cname: if cname in COMMANDS.keys(): - found = True for fn in COMMANDS[cname]: if fn.__doc__: + got = True if callable(fn.__doc__): msg = botconfig.CMD_CHAR+cname+": "+fn.__doc__(rest) if nick == botconfig.CHANNEL: @@ -5998,17 +5997,22 @@ def get_help(cli, rnick, chan, rest): cli.notice(nick, msg) return else: + got = False continue else: - if not found: - msg = "Command not found." + if got: + return + elif chan == nick: + pm(cli, nick, "Documentation for this command is not available.") else: - msg = "Documentation for this command is not available." - if chan == nick: - pm(cli, nick, msg) - else: - cli.notice(nick, msg) - return + cli.notice(nick, "Documentation for this command is not available.") + + elif chan == nick: + pm(cli, nick, "Command not found.") + else: + cli.notice(nick, "Command not found.") + return + # if command was not found, or if no command was given: for name, fn in COMMANDS.items(): if ((name in ("away", "back") and var.OPT_IN_PING) or