h/plugins/help.py

24 lines
677 B
Python
Raw Normal View History

from util import hook
2010-03-01 02:32:41 +00:00
@hook.command(autohelp=False)
2010-02-02 04:42:34 +00:00
def help(inp, bot=None, pm=None):
".help [command] -- gives a list of commands/help for a command"
2010-03-01 02:32:41 +00:00
funcs = {}
2010-03-13 14:09:16 +00:00
for command, (func, args) in bot.commands.iteritems():
if func.__doc__ is not None:
if func in funcs:
if len(funcs[func]) < len(command):
funcs[func] = command
else:
funcs[func] = command
commands = dict((value, key) for key, value in funcs.iteritems())
2010-02-02 04:42:34 +00:00
if not inp:
2010-03-13 14:09:16 +00:00
pm('available commands: ' + ' '.join(sorted(commands)))
else:
2010-03-13 14:09:16 +00:00
if inp in commands:
pm(commands[inp].__doc__)