Rewrite of the help output. now it will PM you

This commit is contained in:
Luke Robles 2017-09-02 00:56:34 -04:00
parent 73c1bc1fd6
commit 50605eb589
2 changed files with 33 additions and 24 deletions

View File

@ -105,8 +105,9 @@ async def on_message(message):
await client.send_message(message.channel, excuse.get_excuse())
if message.content.startswith('!help'):
await client.send_message(message.channel, "ok {}, check your private messages".format(message.author.mention))
await client.send_message(
message.channel,
message.author,
help_methods.parse_message(message.content)
)

View File

@ -10,56 +10,64 @@ def get_help_message(method):
supported_methods = {
'8ball': [
'Ask dragon bot a question and it will give you an 8ball response',
'\n\nUsage: !8ball Will I win the lottery tomorrow?'
'\nUsage: !8ball Will I win the lottery tomorrow?'
],
'decide': [
'Dragon-bot will help make the tough decisions for you',
'\n\n!decide option 1 or option 2.\n\nIf thre is only',
'one option, it will give you a yes or no'
' If there is only one option, it will give you a yes or no',
'\nUsage: !decide cake or pie\n!decide should I do my homework'
],
'define': [
'Returns a definiton of a word from urban dictionary',
'\n\nUsage: !define loli'
'\nUsage: !define loli'
],
'docker': [
'Two supported actions: logs and restart\n\nlogs: Shows you the',
'Two supported actions: logs and restart\nlogs: Shows you the',
'last X number of lines from the minecraft server. If no number',
'is specified, defaults to 10.\n\nrestart: will restart the min',
'ecraft server if something is fucky'
' is specified, defaults to 10.\nrestart: will restart the min',
'ecraft server.'
],
'excuse': [
'Generates a random excuse you can give your boss'],
'Generates a random excuse you can give your boss',
'\nUsage: !excuse'
],
'help': [
'Prints out a list of everything dragon-bot can do'
'Shows you this message'
],
'lewd': [
'Returns a URL for a lewd image.',
'Can only be used in NSFW channels'
'Can only be used in NSFW channels.',
'\nUsage: !lewd'
],
'purge': [
'Deletes the last 20 messages you sent from the channel you',
'typed purge in, unless otherwise specified. eg. !purge 8'
'By default, will delete your last 20 messages. You can override this',
' with your own number. \nUsage: !purge or !purge 15'
],
'wallpaper': [
'Returns the URL for a 4k wallpaper. You can enter',
'a search term as well, for example, !wallpaper, or',
', !wallpaper flowers. Supports multiple tags.'
'a search term as well. Supports multiple search terms as well',
'\nUsage: !wallpaper flowers or !wallpaper mountain flowers sky '
],
'message': [
'You can ask me a question directly and I will do my best to answer it.',
'\nUsage:\n\n@dragon-bot what is the capital of France?\n@dragon-bot 94*37',
'\n@dragon-bot how many calories in a bottle of wine?'
'\nUsage: @dragon-bot what is the capital of France?'
]
}
# Print out every help method
if method == 'show_all':
count = len(supported_methods)
keys = ', '.join(supported_methods.keys())
message = "I currently have `{}` methods,\n\n```{}```\n\nYou can get in formation about a specific method by typing !help <method>".format(count, keys)
# Might be a better way to do this, but build a list of method : description
build_message = []
for key, value in supported_methods.items():
build_message.append("\n{} : {}\n".format(key, ' '.join(supported_methods[key])))
# Join every element of the list with a space
message = ' '.join(build_message)
else:
message = ' '.join(supported_methods[method])
return message
# Join key : value of the help method they passed in
message = "{} : {}".format(method, ' '.join(supported_methods[method]))
# Return the message wrapped in css formatting so we get pretty colors
return "```css\n{}\n```".format(message)
def parse_message(message):
if len(message.split()) > 1:
@ -68,6 +76,6 @@ def parse_message(message):
explanation = get_help_message(method)
except KeyError:
return "I can't help you with that"
return "```{}```".format(explanation)
return "```css\n{}\n```".format(explanation)
return get_help_message('show_all')