Add option to only list commands to !help

This commit is contained in:
Joscha 2016-05-24 21:29:22 +02:00
parent d87c61cd6c
commit ff454a2e13

View file

@ -48,8 +48,10 @@ class Bot():
bot_specific=False) bot_specific=False)
self.add_command("help", self.help_command, "Show help information about the bot.", self.add_command("help", self.help_command, "Show help information about the bot.",
("!help @bot [ -s | <command> ]\n" ("!help @bot [ -s | -c | <command> ]\n"
"-s : general syntax help\n\n" "-s : general syntax help\n"
"-c : only list the commands\n"
"<command> : any command from !help @bot -c\n\n"
"Shows detailed help for a command if you specify a command name.\n" "Shows detailed help for a command if you specify a command name.\n"
"Shows a list of commands and short description if no arguments are given.")) "Shows a list of commands and short description if no arguments are given."))
@ -64,7 +66,7 @@ class Bot():
"people. Since the Great UI Change, this is no longer necessary as\n" "people. Since the Great UI Change, this is no longer necessary as\n"
"bots and people are displayed separately.")) "bots and people are displayed separately."))
self.add_command("restart", self.restart_command, "Restart the bot (shorthand for !kill -r).", self.add_command("restart", self.restart_command, "Restart the bot (shorthand for !kill @bot -r).",
("!restart @bot\n\n" ("!restart @bot\n\n"
"Restart the bot.\n" "Restart the bot.\n"
"Short for !kill @bot -r")) "Short for !kill @bot -r"))
@ -476,18 +478,24 @@ class Bot():
msg += "\n\n" + self.helptexts[command] msg += "\n\n" + self.helptexts[command]
elif "s" in flags: # detailed syntax help elif "s" in flags: # detailed syntax help
msg = "SYNTAX HELP PLACEHOLDER" msg = ("SYNTAX HELP PLACEHOLDER")
else: # just list all commands else: # just list all commands
msg = self.bot_description msg = ""
msg += "\n\nThis bot supports the following commands:"
if not "c" in flags:
msg += self.bot_description + "\n\n"
msg += "This bot supports the following commands:"
for command in sorted(self.helptexts): for command in sorted(self.helptexts):
helptext = self.helptexts[command] helptext = self.helptexts[command]
msg += "\n!{} - {}".format(command, helptext) msg += "\n!{} - {}".format(command, helptext)
if not "c" in flags:
msg += ("\n\nFor help on the command syntax, try: !help @{0} -s\n" msg += ("\n\nFor help on the command syntax, try: !help @{0} -s\n"
"For detailed help on a command, try: !help @{0} <command>") "For detailed help on a command, try: !help @{0} <command>\n"
"(Hint: Most commands have extra functionality, which is\n"
"listed in their detailed help.)")
msg = msg.format(self.mentionable()) msg = msg.format(self.mentionable())
self.room.send_message(msg, parent=message.id) self.room.send_message(msg, parent=message.id)