]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/ChannelController.php
track twitch token expiration
[alttp.git] / app / Http / Controllers / ChannelController.php
index 622276b9c4e56bde9d3e7ac4aea421cb8e558dd8..15213b412f675481ca86d854a4ecbf1579f0dfc6 100644 (file)
@@ -60,11 +60,24 @@ class ChannelController extends Controller {
                ]);
                $this->authorize('editRestream', $channel);
                $nick = empty($validatedData['bot_nick']) ? 'localhorsttv' : $validatedData['bot_nick'];
-               $text = empty($validatedData['category']) ? $validatedData['text'] : $channel->randomOfClass($validatedData['category']);
-               TwitchBotCommand::chat($channel->twitch_chat, $text, $request->user(), $nick);
+               if (empty($validatedData['category'])) {
+                       TwitchBotCommand::chat($channel->twitch_chat, $validatedData['text'], $request->user(), $nick);
+               } else {
+                       TwitchBotCommand::randomChat($channel, $validatedData['category'], $request->user(), $nick);
+               }
                return $this->sendChannel($channel);
        }
 
+       public function chatBotLog(Request $request, Channel $channel) {
+               $this->authorize('editRestream', $channel);
+               $log = $channel->chat_bot_logs()
+                       ->with('origin')
+                       ->orderBy('created_at', 'DESC')
+                       ->limit(150)
+                       ->get();
+               return $log->values()->toJson();
+       }
+
        public function chatSettings(Request $request, Channel $channel) {
                if (!$channel->twitch_chat) {
                        throw new \Exception('channel has no twitch chat set');