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):
innerf.owner_only = owner_only innerf.owner_only = owner_only
innerf.raw_nick = raw_nick innerf.raw_nick = raw_nick
innerf.admin_only = admin_only innerf.admin_only = admin_only
innerf.__doc__ = f.__doc__
return innerf return innerf
return dec return dec

25
wolfgame.py

@ -1818,10 +1818,25 @@ def pm_rules(cli, nick, rest):
cli.msg(nick, var.RULES) cli.msg(nick, var.RULES)
@cmd("help", raw_nick = True) @pmcmd("help", raw_nick = True)
def help(cli, rnick, chan, rest): def help(cli, rnick, rest):
nick, mode, user, cloak = parse_nick(rnick) nick, mode, user, cloak = parse_nick(rnick)
fns = [] 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(): for name, fn in COMMANDS.items():
if name and not fn[0].admin_only and not fn[0].owner_only: if name and not fn[0].admin_only and not fn[0].owner_only:
fns.append("\u0002"+name+"\u0002") fns.append("\u0002"+name+"\u0002")
@ -1836,6 +1851,12 @@ def help(cli, rnick, chan, rest):
@cmd("help", raw_nick = True)
def help2(cli, nick, chan, rest):
help(cli, nick, rest)
@hook("invite", raw_nick = False, admin_only = True) @hook("invite", raw_nick = False, admin_only = True)
def on_invite(cli, nick, something, chan): def on_invite(cli, nick, something, chan):
cli.join(chan) cli.join(chan)

Loading…
Cancel
Save