3 namespace App\TwitchBot;
5 use App\Models\Channel;
7 abstract class ChatCommand {
9 public static function create(TwitchBot $bot, Channel $channel, $config) {
11 switch ($config['command']) {
13 $cmd = new CrewCommand();
16 $cmd = new RunnerCommand();
19 throw new \Exception('command '.$str.' not found');
22 $cmd->channel = $channel;
23 $cmd->config = $config;
27 public abstract function execute($args);
29 protected function getBooleanConfig($name, $default = false) {
30 return array_key_exists($name, $this->config) ? $this->config[$name] : $default;
33 protected function messageChannel($str) {
34 $msg = IRCMessage::privmsg($this->channel->twitch_chat, $str);
35 $this->bot->sendIRCMessage($msg);