]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/ChannelController.php
add twitch chat comand
[alttp.git] / app / Http / Controllers / ChannelController.php
index f6840f87f837f27e94dc36d4dad096d8d4a4ba17..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');