Merged in decide (pull request #23)

moving decide into it s own module

Approved-by: Luke Robles <lukelrobles@gmail.com>
This commit is contained in:
Tyler Hodapp 2017-08-17 02:26:25 +00:00
commit 530bfc506c
2 changed files with 17 additions and 8 deletions

11
app/decide.py Normal file
View File

@ -0,0 +1,11 @@
import random
import help_methods
def get_decide_choice(decide):
choices = decide.replace('!decide', '' ).lstrip().split(' or ')
if len(choices) > 1:
return random.choice(choices)
elif '' in choices:
return help_methods.get_help_message('decide')
else:
return random.choice(["yes", "no"])

View File

@ -3,6 +3,7 @@ import sys
import requests
import os
import decide
import eight_ball
import excuse
import define_word
@ -174,14 +175,11 @@ async def on_message(message):
# await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted)))
if message.content.startswith('!decide'):
choices = message.content.replace('!decide', '').lstrip().split(' or ')
if len(choices) > 1:
####### debug ###########
# await client.send_message(message.channel, "I see {} choices, {}".format(len(choices), 'and '.join(choices)))
print("{} has initated a decide between {}".format(message.author, choices))
await client.send_message(message.channel, "{} {}".format(message.author.mention, random.choice(choices)))
else:
await client.send_message(message.channel, "{} {}".format(message.author.mention, random.choice(['yes', 'no'])))
await client.send_message(message.channel,
"{} {}".format(message.author.mention,
decide_method.get_decide_choice(message.content)))
if message.content.startswith('!cleanup') and message.author.id == '144986109804412928':
def is_bot(m):