actually committing help.py

This commit is contained in:
Ryan Hitchman 2009-11-18 20:30:28 -07:00
parent e3bb74a365
commit d44223399f
2 changed files with 36 additions and 0 deletions

19
plugins/choose.py Normal file
View File

@ -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()

17
plugins/help.py Normal file
View File

@ -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__)