mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 19:28:54 -05:00
parent
2da943bfd0
commit
89daba4711
@ -16,7 +16,7 @@ DEFAULTS = {"MAX_SCORE" : 10,
|
|||||||
"BOT_PLAYS" : False,
|
"BOT_PLAYS" : False,
|
||||||
"REVEAL_ANSWER": True}
|
"REVEAL_ANSWER": True}
|
||||||
|
|
||||||
TriviaLine = namedtuple("Question", "question answers")
|
TriviaLine = namedtuple("TriviaLine", "question answers")
|
||||||
|
|
||||||
|
|
||||||
class Trivia:
|
class Trivia:
|
||||||
@ -284,17 +284,32 @@ class TriviaSession():
|
|||||||
await self.bot.say(box(t, lang="diff"))
|
await self.bot.say(box(t, lang="diff"))
|
||||||
|
|
||||||
async def check_answer(self, message):
|
async def check_answer(self, message):
|
||||||
if message.author.id != self.bot.user.id:
|
if message.author == self.bot.user:
|
||||||
self.timeout = time.perf_counter()
|
return
|
||||||
if self.current_line is not None:
|
elif self.current_line is None:
|
||||||
for answer in self.current_line.answers:
|
return
|
||||||
if answer.lower() in message.content.lower():
|
|
||||||
self.current_line = None
|
self.timeout = time.perf_counter()
|
||||||
self.status = "correct answer"
|
has_guessed = False
|
||||||
self.scores[message.author] += 1
|
|
||||||
msg = "You got it {}! **+1** to you!".format(message.author.name)
|
for answer in self.current_line.answers:
|
||||||
await self.bot.send_message(message.channel, msg)
|
answer = answer.lower()
|
||||||
return True
|
guess = message.content.lower()
|
||||||
|
if " " not in answer: # Exact matching, issue #331
|
||||||
|
guess = guess.split(" ")
|
||||||
|
for word in guess:
|
||||||
|
if word == answer:
|
||||||
|
has_guessed = True
|
||||||
|
else: # The answer has spaces, we can't be as strict
|
||||||
|
if answer in guess:
|
||||||
|
has_guessed = True
|
||||||
|
|
||||||
|
if has_guessed:
|
||||||
|
self.current_line = None
|
||||||
|
self.status = "correct answer"
|
||||||
|
self.scores[message.author] += 1
|
||||||
|
msg = "You got it {}! **+1** to you!".format(message.author.name)
|
||||||
|
await self.bot.send_message(message.channel, msg)
|
||||||
|
|
||||||
|
|
||||||
def check_folders():
|
def check_folders():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user