Browse Source

implement getting !help for individual commands

master
jcao219 14 years ago
parent
commit
bf2c30b775
  1. 1
      decorators.py
  2. 25
      wolfgame.py

1
decorators.py

@ -39,6 +39,7 @@ def generate(fdict, **kwargs): @@ -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

25
wolfgame.py

@ -1818,10 +1818,25 @@ def pm_rules(cli, nick, rest): @@ -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): @@ -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)

Loading…
Cancel
Save