]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/ChatCommand.php
simple guessing game
[alttp.git] / app / TwitchBot / ChatCommand.php
index feea8abf92386c0a6cd1fa1cee66bd55dfeb95c0..d03f7829e2704923f3b72780a8b3f1fd12596fb2 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,12 +37,31 @@ 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) {
+               return Arr::join($entries, ', ', ' and ');
+       }
+
        protected function messageChannel($str) {
                $msg = IRCMessage::privmsg($this->channel->twitch_chat, $str);
                $this->bot->sendIRCMessage($msg);