X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=app%2FHttp%2FControllers%2FChannelController.php;h=f1f3cdbeb4038da5cc8b12a7dc9b2b6060645ea2;hb=e49b130505f5712075dca2ff990e5a63fc90ce3c;hp=da1f5ef76590166b5e9cf1827ce93cf2c8240421;hpb=51a752c7cce2465043dfb3d63a0152b64765b167;p=alttp.git diff --git a/app/Http/Controllers/ChannelController.php b/app/Http/Controllers/ChannelController.php index da1f5ef..f1f3cdb 100644 --- a/app/Http/Controllers/ChannelController.php +++ b/app/Http/Controllers/ChannelController.php @@ -47,10 +47,28 @@ class ChannelController extends Controller { throw new \Exception('channel has no twitch chat set'); } $validatedData = $request->validate([ + 'bot_nick' => 'string', 'text' => 'string|required', ]); $this->authorize('editRestream', $channel); - TwitchBotCommand::chat($channel->twitch_chat, $validatedData['text'], $request->user()); + $nick = empty($validatedData['bot_nick']) ? 'localhorsttv' : $validatedData['bot_nick']; + TwitchBotCommand::chat($channel->twitch_chat, $validatedData['text'], $request->user(), $nick); + return $channel->toJson(); + } + + public function chatSettings(Request $request, Channel $channel) { + if (!$channel->twitch_chat) { + throw new \Exception('channel has no twitch chat set'); + } + $validatedData = $request->validate([ + 'wait_msgs_min' => 'integer|min:1', + 'wait_msgs_max' => 'integer', + 'wait_time_min' => 'integer', + 'wait_time_max' => 'integer', + ]); + $this->authorize('editRestream', $channel); + $channel->chat_settings = $validatedData; + $channel->save(); return $channel->toJson(); } @@ -58,10 +76,18 @@ class ChannelController extends Controller { if (!$channel->twitch_chat) { throw new \Exception('channel has no twitch chat set'); } + $validatedData = $request->validate([ + 'bot_nick' => 'string', + ]); $this->authorize('editRestream', $channel); - $channel->join = true; + $nick = empty($validatedData['bot_nick']) ? 'localhorsttv' : $validatedData['bot_nick']; + if ($nick == 'localhorsttv') { + $channel->join = true; + } else if ($nick == 'horstiebot') { + $channel->chat = true; + } $channel->save(); - TwitchBotCommand::join($channel->twitch_chat, $request->user()); + TwitchBotCommand::join($channel->twitch_chat, $request->user(), $nick); return $channel->toJson(); } @@ -69,10 +95,18 @@ class ChannelController extends Controller { if (!$channel->twitch_chat) { throw new \Exception('channel has no twitch chat set'); } + $validatedData = $request->validate([ + 'bot_nick' => 'string', + ]); $this->authorize('editRestream', $channel); - $channel->join = false; + $nick = empty($validatedData['bot_nick']) ? 'localhorsttv' : $validatedData['bot_nick']; + if ($nick == 'localhorsttv') { + $channel->join = false; + } else if ($nick == 'horstiebot') { + $channel->chat = false; + } $channel->save(); - TwitchBotCommand::part($channel->twitch_chat, $request->user()); + TwitchBotCommand::part($channel->twitch_chat, $request->user(), $nick); return $channel->toJson(); }