moves decide into a module, fixes #11
This commit is contained in:
parent
cf13693f91
commit
bbb8a1556c
18
app/decide_method.py
Normal file
18
app/decide_method.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
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"])
|
@ -3,6 +3,7 @@ import sys
|
|||||||
import requests
|
import requests
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import decide_method
|
||||||
import eight_ball
|
import eight_ball
|
||||||
import define_word
|
import define_word
|
||||||
import help_methods
|
import help_methods
|
||||||
@ -26,7 +27,7 @@ async def on_ready():
|
|||||||
print("\n********************************")
|
print("\n********************************")
|
||||||
|
|
||||||
await client.change_presence(game=discord.Game(name='Type !help to see how to use me'))
|
await client.change_presence(game=discord.Game(name='Type !help to see how to use me'))
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print("\nPress control+c to exit the bot")
|
print("\nPress control+c to exit the bot")
|
||||||
print("Followed by control+d or by typing")
|
print("Followed by control+d or by typing")
|
||||||
@ -176,14 +177,11 @@ 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'):
|
||||||
choices = message.content.replace('!decide', '').lstrip().split(' or ')
|
await client.send_message(message.channel,
|
||||||
if len(choices) > 1:
|
"{} {}".format(message.author.mention,
|
||||||
####### debug ###########
|
decide_method.get_decide_choice(message.content)))
|
||||||
# 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'])))
|
|
||||||
|
|
||||||
if message.content.startswith('!cleanup') and message.author.id == '144986109804412928':
|
if message.content.startswith('!cleanup') and message.author.id == '144986109804412928':
|
||||||
def is_bot(m):
|
def is_bot(m):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user