Support using docstrings as command help
This commit is contained in:
parent
3f2e5ca712
commit
ebc77fa501
2 changed files with 7 additions and 3 deletions
|
@ -179,8 +179,12 @@ class Module(object):
|
|||
if command in self.events.on("received").on(
|
||||
"command").get_children():
|
||||
hooks = self.events.on("received.command").on(command).get_hooks()
|
||||
if hooks and "help" in hooks[0].kwargs:
|
||||
event["stdout"].write("%s: %s" % (command, hooks[0].kwargs["help"]))
|
||||
kwargs = hooks[0].kwargs
|
||||
help = hooks[0].kwargs.get("help", None
|
||||
) or hooks[0].function.__doc__
|
||||
|
||||
if help:
|
||||
event["stdout"].write("%s: %s" % (command, help.strip()))
|
||||
else:
|
||||
event["stderr"].write("No help available for %s" % command)
|
||||
else:
|
||||
|
|
|
@ -94,7 +94,7 @@ class ModuleManager(object):
|
|||
hooks = getattr(attribute, BITBOT_HOOKS_MAGIC)
|
||||
for hook in hooks:
|
||||
context_events.on(hook["event"]).hook(attribute,
|
||||
**hook["kwargs"])
|
||||
docstring=attribute.__doc__, **hook["kwargs"])
|
||||
|
||||
module_object._context = context
|
||||
module_object._import_name = name
|
||||
|
|
Loading…
Reference in a new issue