Add response function with tests to list games

Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
This commit is contained in:
Sebastian Crane 2022-02-09 21:46:07 +00:00
parent 083d51a879
commit f891299236
2 changed files with 10 additions and 0 deletions

View File

@ -41,6 +41,12 @@
game
"!"))
(defn list-games-string [state _ _]
(str "Games with a list of players: "
(str/join
", "
(sort (map name (game/get-games state))))))
(defn split-message [message]
(let [message-parts (str/split message #"\s")
command (if-let [x (first message-parts)] (str/lower-case x) "")

View File

@ -25,6 +25,10 @@
(is (= "Removed abc from the list of players for hypothetical-shooter!"
(remove-player-string nil "hypothetical-shooter" "abc"))))
(deftest list-games-string-test
(is (= "Games with a list of players: hypothetical-shooter, imaginary-rpg, quasi-rts"
(list-games-string test-state nil nil))))
(deftest split-message-test
(is (= {:command "!match" :game "Quasi-Rts" :game-keyword :quasi-rts}
(split-message "!match Quasi-Rts "))))