Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 31 lines (24 sloc) 1.003 kb
a24da5f @rainyday Changed help to not display commands from disabled plugins.
rainyday authored
1 import re
2
c183032 Fix unintentional changes to plugin directory structure.
Hamled authored
3 from util import hook
4
253881f @rmmh PEP8 compliance + clean dotnetpad
authored
5
6452c11 @rmmh disable !command, enable fuzzy command matching, make help automatic, ad...
authored
6 @hook.command(autohelp=False)
1dd86ba @rmmh change calling convention
authored
7 def help(inp, bot=None, pm=None):
c183032 Fix unintentional changes to plugin directory structure.
Hamled authored
8 ".help [command] -- gives a list of commands/help for a command"
253881f @rmmh PEP8 compliance + clean dotnetpad
authored
9
c183032 Fix unintentional changes to plugin directory structure.
Hamled authored
10 funcs = {}
4d0d730 @rainyday Don't show disabled commands.
rainyday authored
11 disabled = bot.config.get('disabled_plugins', [])
83a94fe @rainyday Moved disabled commands around.
rainyday authored
12 disabled_comm = bot.config.get('disabled_commands', [])
60be1e7 @rmmh fix help plugin
authored
13 for command, (func, args) in bot.commands.iteritems():
a24da5f @rainyday Changed help to not display commands from disabled plugins.
rainyday authored
14 fn = re.match(r'^plugins.(.+).py$', func._filename)
15 if fn.group(1).lower() not in disabled:
83a94fe @rainyday Moved disabled commands around.
rainyday authored
16 if command not in disabled_comm:
4d0d730 @rainyday Don't show disabled commands.
rainyday authored
17 if func.__doc__ is not None:
18 if func in funcs:
19 if len(funcs[func]) < len(command):
20 funcs[func] = command
21 else:
a24da5f @rainyday Changed help to not display commands from disabled plugins.
rainyday authored
22 funcs[func] = command
60be1e7 @rmmh fix help plugin
authored
23
24 commands = dict((value, key) for key, value in funcs.iteritems())
c183032 Fix unintentional changes to plugin directory structure.
Hamled authored
25
1dd86ba @rmmh change calling convention
authored
26 if not inp:
60be1e7 @rmmh fix help plugin
authored
27 pm('available commands: ' + ' '.join(sorted(commands)))
c183032 Fix unintentional changes to plugin directory structure.
Hamled authored
28 else:
60be1e7 @rmmh fix help plugin
authored
29 if inp in commands:
30 pm(commands[inp].__doc__)
Something went wrong with that request. Please try again.