From ebc77fa5016a7f204779b0291ec2b6f1cc5596d4 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 26 Sep 2018 15:58:16 +0100 Subject: Support using docstrings as command help --- modules/commands.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/commands.py b/modules/commands.py index 02787791..74f70e1d 100644 --- a/modules/commands.py +++ b/modules/commands.py @@ -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: -- cgit v1.3.1-10-gc9f91