diff --git a/src/bot.clj b/src/bot.clj index 47d7aa2..a4013b2 100644 --- a/src/bot.clj +++ b/src/bot.clj @@ -6,10 +6,13 @@ [game] [irclj.core])) +(defn keywordise-game [game] + (when (string? game) + (keyword (str/lower-case game)))) + (defn sorted-players-of-game [state game] (->> game - (str/lower-case) - (keyword) + (keywordise-game) (game/get-players-of-game state) (sort))) @@ -51,7 +54,7 @@ (let [message-parts (str/split message #"\s") command (if-let [x (first message-parts)] (str/lower-case x) "") game (second message-parts) - game-keyword (when game (keyword (str/lower-case game)))] + game-keyword (keywordise-game game)] {:command command :game game :game-keyword game-keyword})) diff --git a/test/bot_test.clj b/test/bot_test.clj index e21ab55..6d8a470 100644 --- a/test/bot_test.clj +++ b/test/bot_test.clj @@ -9,6 +9,10 @@ :quasi-rts #{"abc" "123"} :imaginary-rpg #{"xyz" "abc"}}}) +(deftest keywordise-game-test + (is (= :quasi-rts + (keywordise-game "Quasi-RTS")))) + (deftest match-string-test (is (= '"Anyone ready for quasi-Rts? 123 abc" (match-string :state test-state :game "quasi-Rts"))))