actually committing help.py
This commit is contained in:
parent
e3bb74a365
commit
d44223399f
|
@ -0,0 +1,19 @@
|
||||||
|
import re
|
||||||
|
import random
|
||||||
|
|
||||||
|
from util import hook
|
||||||
|
|
||||||
|
@hook.command
|
||||||
|
def choose(inp):
|
||||||
|
".choose <choice1>, <choice2>, ... <choicen> -- makes a decision"
|
||||||
|
|
||||||
|
if not inp:
|
||||||
|
return choose.__doc__
|
||||||
|
|
||||||
|
c = re.findall(r'([^,]+)', inp)
|
||||||
|
if len(c) == 1:
|
||||||
|
c = re.findall(r'(\S+)', inp)
|
||||||
|
if len(c) == 1:
|
||||||
|
return 'the decision is up to you'
|
||||||
|
|
||||||
|
return random.choice(c).strip()
|
|
@ -0,0 +1,17 @@
|
||||||
|
from util import hook
|
||||||
|
|
||||||
|
@hook.command
|
||||||
|
def help(bot, input):
|
||||||
|
".help [command] -- gives a list of commands/help for a command"
|
||||||
|
|
||||||
|
funcs = {}
|
||||||
|
for csig, func, args in bot.plugs['command']:
|
||||||
|
if args['hook'] != r'(.*)':
|
||||||
|
if func.__doc__ is not None:
|
||||||
|
funcs[csig[1]] = func
|
||||||
|
|
||||||
|
if not input.inp.strip():
|
||||||
|
input.pm('available commands: ' + ' '.join(sorted(funcs)))
|
||||||
|
else:
|
||||||
|
if input.inp in funcs:
|
||||||
|
input.pm(funcs[input.inp].__doc__)
|
Loading…
Reference in New Issue