Merge pull request #132 from rootcoma/answer_spaces
Allow multiple spaces, and leading/trailing spaces in answers
This commit is contained in:
commit
600506feda
|
|
@ -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
|
||||
|
|
@ -1275,6 +1279,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
|
||||
|
|
|
|||
Loading…
Reference in New Issue