]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/GuessingSolveCommand.php
better classification
[alttp.git] / app / TwitchBot / GuessingSolveCommand.php
index 57ee5f840424640a7f54e9031a650dfc44700ecb..e825791d374040d3c19b5bc641c403b55da8d818 100644 (file)
@@ -6,29 +6,18 @@ class GuessingSolveCommand extends ChatCommand {
 
        public function execute($args) {
                if (!$this->channel->hasActiveGuessing()) {
-                       $this->messageChannel('Channel has no active guessing game');
+                       $msg = $this->channel->getGuessingSetting('not_active_message');
+                       $this->messageChannel($msg);
                        return;
                }
-               if (empty($args)) {
-                       $this->messageChannel('Please provide a solution to the guessing game');
-                       return;
-               }
-               if (!$this->channel->isValidGuess($args)) {
-                       $this->messageChannel('Please provide a valid solution to the guessing game');
+               if (empty($args) || !$this->channel->isValidGuess($args)) {
+                       $msg = $this->channel->getGuessingSetting('invalid_solution_message');
+                       $this->messageChannel($msg);
                        return;
                }
                $winners = $this->channel->solveGuessing($args);
-               $names = [];
-               foreach ($winners as $winner) {
-                       if ($winner->score > 0) {
-                               $names[] = $winner->uname;
-                       }
-               }
-               if (empty($names)) {
-                       $this->messageChannel('nobody wins :(');
-               } else {
-                       $this->messageChannel('Congrats '.$this->listAnd($names));
-               }
+               $msg = $this->channel->listGuessingWinners($winners);
+               $this->messageChannel($msg);
                $this->channel->clearGuessing();
        }