]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/ChatCommand.php
better classification
[alttp.git] / app / TwitchBot / ChatCommand.php
index feea8abf92386c0a6cd1fa1cee66bd55dfeb95c0..f2e11b61dd4bda83c4eb89652eb9aed7aa4fb34e 100644 (file)
@@ -12,6 +12,21 @@ abstract class ChatCommand {
                        case 'crew':
                                $cmd = new CrewCommand();
                                break;
+                       case 'guessing-cancel':
+                               $cmd = new GuessingCancelCommand();
+                               break;
+                       case 'guessing-leaderboard':
+                               $cmd = new GuessingLeaderboardCommand();
+                               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 +39,33 @@ 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 $this->channel->listAnd($entries);
+       }
+
        protected function messageChannel($str) {
+               if (empty($str)) return;
                $msg = IRCMessage::privmsg($this->channel->twitch_chat, $str);
                $this->bot->sendIRCMessage($msg);
        }