From bf2c30b775a772740dd4941c27fc7fa84507c40b Mon Sep 17 00:00:00 2001 From: jcao219 Date: Mon, 18 Jul 2011 16:51:02 -0500 Subject: [PATCH] implement getting !help for individual commands --- decorators.py | 1 + wolfgame.py | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/decorators.py b/decorators.py index 08a8130..d28435c 100644 --- a/decorators.py +++ b/decorators.py @@ -39,6 +39,7 @@ def generate(fdict, **kwargs): innerf.owner_only = owner_only innerf.raw_nick = raw_nick innerf.admin_only = admin_only + innerf.__doc__ = f.__doc__ return innerf return dec diff --git a/wolfgame.py b/wolfgame.py index bf247ce..67ed41c 100644 --- a/wolfgame.py +++ b/wolfgame.py @@ -1818,10 +1818,25 @@ def pm_rules(cli, nick, rest): cli.msg(nick, var.RULES) -@cmd("help", raw_nick = True) -def help(cli, rnick, chan, rest): +@pmcmd("help", raw_nick = True) +def help(cli, rnick, rest): nick, mode, user, cloak = parse_nick(rnick) fns = [] + + cname = rest.strip().replace(botconfig.CMD_CHAR, "").lower() + if cname: + for c in (COMMANDS,PM_COMMANDS): + if cname in c.keys(): + for fn in c[cname]: + if fn.__doc__: + cli.notice(nick, fn.__doc__) + return + else: + continue + else: + cli.notice(nick, "No documentation is available for this function.") + return + cli.notice(nick, "Command not found.") for name, fn in COMMANDS.items(): if name and not fn[0].admin_only and not fn[0].owner_only: fns.append("\u0002"+name+"\u0002") @@ -1833,6 +1848,12 @@ def help(cli, rnick, chan, rest): cli.notice(nick, "Commands: "+", ".join(fns)) if afns: cli.notice(nick, "Admin Commands: "+", ".join(afns)) + + + +@cmd("help", raw_nick = True) +def help2(cli, nick, chan, rest): + help(cli, nick, rest)