]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/ChannelController.php
add twitch chat comand
[alttp.git] / app / Http / Controllers / ChannelController.php
index 904cb8ff81ebc0833fc7912aeae96a10edae2ef5..da1f5ef76590166b5e9cf1827ce93cf2c8240421 100644 (file)
@@ -42,6 +42,18 @@ class ChannelController extends Controller {
                return $channel->toJson();
        }
 
+       public function chat(Request $request, Channel $channel) {
+               if (!$channel->twitch_chat) {
+                       throw new \Exception('channel has no twitch chat set');
+               }
+               $validatedData = $request->validate([
+                       'text' => 'string|required',
+               ]);
+               $this->authorize('editRestream', $channel);
+               TwitchBotCommand::chat($channel->twitch_chat, $validatedData['text'], $request->user());
+               return $channel->toJson();
+       }
+
        public function join(Request $request, Channel $channel) {
                if (!$channel->twitch_chat) {
                        throw new \Exception('channel has no twitch chat set');
@@ -49,7 +61,7 @@ class ChannelController extends Controller {
                $this->authorize('editRestream', $channel);
                $channel->join = true;
                $channel->save();
-               TwitchBotCommand::join($channel->twitch_chat);
+               TwitchBotCommand::join($channel->twitch_chat, $request->user());
                return $channel->toJson();
        }
 
@@ -60,7 +72,7 @@ class ChannelController extends Controller {
                $this->authorize('editRestream', $channel);
                $channel->join = false;
                $channel->save();
-               TwitchBotCommand::part($channel->twitch_chat);
+               TwitchBotCommand::part($channel->twitch_chat, $request->user());
                return $channel->toJson();
        }