Allow multiple spaces, and leading/trailing spaces in answers

This commit is contained in:
rootcoma 2013-11-16 10:06:17 -08:00
parent 2a27a540df
commit 03a563adfb
1 changed files with 9 additions and 0 deletions

View File

@ -817,14 +817,18 @@ class TriviaTime(callbacks.Plugin):
attempt = ircutils.toLower(msg.args[1])
attempt = self.removeAccents(attempt)
attempt = self.removeExtraSpaces(attempt)
# was a correct answer guessed?
for ans in self.alternativeAnswers:
normalizedAns = self.removeAccents(ircutils.toLower(ans))
normalizedAns = self.removeExtraSpaces(ircutils.toLower(ans))
if normalizedAns == attempt and normalizedAns not in self.guessedAnswers:
correctAnswerFound = True
correctAnswer = ans
for ans in self.answers:
normalizedAns = self.removeAccents(ircutils.toLower(ans))
normalizedAns = self.removeExtraSpaces(ircutils.toLower(ans))
if normalizedAns == attempt and normalizedAns not in self.guessedAnswers:
correctAnswerFound = True
correctAnswer = ans
@ -1263,6 +1267,11 @@ class TriviaTime(callbacks.Plugin):
text = text.replace(a,b)
return text
def removeExtraSpaces(self, text):
text = text.strip()
text = ' '.join(text.split())
return text
def repeatQuestion(self):
if self.questionRepeated == True:
return