Fixing decidee lgoic and shortening excuse logic

This commit is contained in:
Luke Robles 2017-08-16 19:55:16 -07:00
parent 530bfc506c
commit fcf39f1ed8
3 changed files with 15 additions and 13 deletions

View File

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

View File

@ -175,10 +175,13 @@ async def on_message(message):
# await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted))) # await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted)))
if message.content.startswith('!decide'): if message.content.startswith('!decide'):
await client.send_message(message.channel, await client.send_message(
"{} {}".format(message.author.mention, message.channel,
decide_method.get_decide_choice(message.content))) "{} {}".format(
message.author.mention,
decide.decide(message.content)
)
)
if message.content.startswith('!cleanup') and message.author.id == '144986109804412928': if message.content.startswith('!cleanup') and message.author.id == '144986109804412928':

View File

@ -1,7 +1,6 @@
import random, requests import random, requests
def get_excuse(): def get_excuse():
excuses = requests.get( url = ("https://gist.githubusercontent.com/AndrewBrinker/6763cdd5d79d6e" \
'https://gist.githubusercontent.com/AndrewBrinker/6763cdd5d79d6e3eaa3f/raw/624b946ebcca71ac76b74afa5ea41280540c1b97/excuses.txt' "3eaa3f/raw/624b946ebcca71ac76b74afa5ea41280540c1b97/excuses.txt")
).text.split("\n") return random.choice(requests.get(url).text.split("\n"))
return random.choice(excuses)