]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/ChatCommand.php
guessing game settings
[alttp.git] / app / TwitchBot / ChatCommand.php
index feea8abf92386c0a6cd1fa1cee66bd55dfeb95c0..8e6fbe1e7f1fa9c7b1c09b2e6e1552417c9079df 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\TwitchBot;
 
 use App\Models\Channel;
+use Illuminate\Support\Arr;
 
 abstract class ChatCommand {
 
@@ -12,6 +13,18 @@ abstract class ChatCommand {
                        case 'crew':
                                $cmd = new CrewCommand();
                                break;
+                       case 'guessing-cancel':
+                               $cmd = new GuessingCancelCommand();
+                               break;
+                       case 'guessing-solve':
+                               $cmd = new GuessingSolveCommand();
+                               break;
+                       case 'guessing-start':
+                               $cmd = new GuessingStartCommand();
+                               break;
+                       case 'guessing-stop':
+                               $cmd = new GuessingStopCommand();
+                               break;
                        case 'runner':
                                $cmd = new RunnerCommand();
                                break;
@@ -24,13 +37,37 @@ abstract class ChatCommand {
                return $cmd;
        }
 
+       public function checkAccess(IRCMessage $msg) {
+               $restrict = $this->getStringConfig('restrict', 'none');
+               if ($restrict == 'owner') {
+                       return $msg->isOwner();
+               }
+               if ($restrict == 'mod') {
+                       return $msg->isMod();
+               }
+               return true;
+       }
+
        public abstract function execute($args);
 
        protected function getBooleanConfig($name, $default = false) {
                return array_key_exists($name, $this->config) ? $this->config[$name] : $default;
        }
 
+       protected function getStringConfig($name, $default = '') {
+               return array_key_exists($name, $this->config) ? $this->config[$name] : $default;
+       }
+
+       protected function listAnd($entries) {
+               $lang = empty($this->channels->languages) ? 'en' : $this->channel->languages[0];
+               if ($lang == 'de') {
+                       return Arr::join($entries, ', ', ' und ');
+               }
+               return Arr::join($entries, ', ', ' and ');
+       }
+
        protected function messageChannel($str) {
+               if (empty($str)) return;
                $msg = IRCMessage::privmsg($this->channel->twitch_chat, $str);
                $this->bot->sendIRCMessage($msg);
        }