diff --git a/Code/irc/dict_puzzle.py b/Code/irc/dict_puzzle.py index 1185d50..1d9c443 100644 --- a/Code/irc/dict_puzzle.py +++ b/Code/irc/dict_puzzle.py @@ -32,4 +32,15 @@ def get_anagram(maxlen = 6): if anagram != word: break puzzle = "Unscramble the following word: '" + anagram + "'" - return [word, puzzle] + + # Anagrams can have multiple answers, so we provide a check function that accepts all possibilities + def answer_checker(guess): + # Check for exact match + if guess == word: + return True + # Bail out early if they didn't even use all the same letters + if sorted(guess) != sorted(word): + return False + # Ok, gotta actually check if it's a word now + return any(guess == item for item in get_wordlist()) + return [answer_checker, puzzle] diff --git a/Code/irc/tildebot.py b/Code/irc/tildebot.py index fea86a1..6bbe838 100755 --- a/Code/irc/tildebot.py +++ b/Code/irc/tildebot.py @@ -146,7 +146,7 @@ def challenge_response(channel, user, name, time, msg): print(msg); if(challenges.has_key(user)): answer, bonus = challenges[user] - if(msg.lower() == str(answer).lower() or msg == p.number_to_words(answer)): + if((callable(answer) and answer(msg.lower())) or (msg.lower() == str(answer).lower() or msg == p.number_to_words(answer))): give_tilde(channel, user, name, time, True, bonus); else: give_tilde(channel, user, name, time, False, 0);