]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/CrewCommand.php
first simple twitch commands
[alttp.git] / app / TwitchBot / CrewCommand.php
diff --git a/app/TwitchBot/CrewCommand.php b/app/TwitchBot/CrewCommand.php
new file mode 100644 (file)
index 0000000..2fd0426
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+namespace App\TwitchBot;
+
+class CrewCommand extends ChatCommand {
+
+       public function execute($args) {
+               $episode = $this->channel->getCurrentEpisode();
+               if (!$episode) return;
+               $links = [];
+               foreach ($episode->crew as $crew) {
+                       $link = $crew->getStreamLink();
+                       if (empty($link)) {
+                               $link = $crew->getName();
+                       }
+                       if (!empty($link)) {
+                               if (!isset($links[$crew->role])) {
+                                       $links[$crew->role] = [];
+                               }
+                               $links[$crew->role][] = $link;
+                       }
+               }
+               $parts = [];
+               if (!empty($links['commentary']) && $this->getBooleanConfig('commentary', true)) {
+                       $parts[] = 'Kommentar: '.implode(' ', $links['commentary']);
+               }
+               if (!empty($links['tracking']) && $this->getBooleanConfig('tracking', true)) {
+                       $parts[] = 'Tracking: '.implode(' ', $links['tracking']);
+               }
+               if (!empty($links['setup']) && $this->getBooleanConfig('setup', false)) {
+                       $parts[] = 'Setup: '.implode(' ', $links['setup']);
+               }
+               if (!empty($parts)) {
+                       $message = implode(' ', $parts);
+                       $this->messageChannel($message);
+               }
+       }
+
+}
+
+?>