3 namespace App\TwitchBot;
5 class GuessingSolveCommand extends ChatCommand {
7 public function execute($args) {
8 if (!$this->channel->hasActiveGuessing()) {
9 $msg = $this->channel->getGuessingSetting('not_active_message');
10 $this->messageChannel($msg);
13 if (empty($args) || !$this->channel->isValidGuess($args)) {
14 $msg = $this->channel->getGuessingSetting('invalid_solution_message');
15 $this->messageChannel($msg);
18 $winners = $this->channel->solveGuessing($args);
20 foreach ($winners as $winner) {
21 if ($winner->score > 0) {
22 $names[] = $winner->uname;
26 $msg = $this->channel->getGuessingSetting('no_winners_message');
27 $this->messageChannel($msg);
29 $msg = $this->channel->getGuessingSetting('winners_message');
30 $msg = str_replace('{names}', $this->listAnd($names), $msg);
31 $this->messageChannel($msg);
33 $this->channel->clearGuessing();