]> git.localhorst.tv Git - alttp.git/blob - app/TwitchBot/CrewCommand.php
first simple twitch commands
[alttp.git] / app / TwitchBot / CrewCommand.php
1 <?php
2
3 namespace App\TwitchBot;
4
5 class CrewCommand extends ChatCommand {
6
7         public function execute($args) {
8                 $episode = $this->channel->getCurrentEpisode();
9                 if (!$episode) return;
10                 $links = [];
11                 foreach ($episode->crew as $crew) {
12                         $link = $crew->getStreamLink();
13                         if (empty($link)) {
14                                 $link = $crew->getName();
15                         }
16                         if (!empty($link)) {
17                                 if (!isset($links[$crew->role])) {
18                                         $links[$crew->role] = [];
19                                 }
20                                 $links[$crew->role][] = $link;
21                         }
22                 }
23                 $parts = [];
24                 if (!empty($links['commentary']) && $this->getBooleanConfig('commentary', true)) {
25                         $parts[] = 'Kommentar: '.implode(' ', $links['commentary']);
26                 }
27                 if (!empty($links['tracking']) && $this->getBooleanConfig('tracking', true)) {
28                         $parts[] = 'Tracking: '.implode(' ', $links['tracking']);
29                 }
30                 if (!empty($links['setup']) && $this->getBooleanConfig('setup', false)) {
31                         $parts[] = 'Setup: '.implode(' ', $links['setup']);
32                 }
33                 if (!empty($parts)) {
34                         $message = implode(' ', $parts);
35                         $this->messageChannel($message);
36                 }
37         }
38
39 }
40
41 ?>