From 03a563adfbd90c2bbdb840271ff9d616ecfda031 Mon Sep 17 00:00:00 2001 From: rootcoma Date: Sat, 16 Nov 2013 10:06:17 -0800 Subject: [PATCH] Allow multiple spaces, and leading/trailing spaces in answers --- plugin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugin.py b/plugin.py index 7d7408e..fcff624 100644 --- a/plugin.py +++ b/plugin.py @@ -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