From 60be1e7165fa314477336014ac4c635a7b0c7722 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Sat, 13 Mar 2010 07:09:16 -0700 Subject: [PATCH] fix help plugin --- plugins/help.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/help.py b/plugins/help.py index a9fbde4..c7d1222 100644 --- a/plugins/help.py +++ b/plugins/help.py @@ -6,13 +6,18 @@ def help(inp, bot=None, pm=None): ".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 + 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()) if not inp: - pm('available commands: ' + ' '.join(sorted(funcs))) + pm('available commands: ' + ' '.join(sorted(commands))) else: - if inp in funcs: - pm(funcs[inp].__doc__) + if inp in commands: + pm(commands[inp].__doc__)