+<?php
+
+namespace App\TwitchBotCommands;
+
+use App\Models\Channel;
+use App\Models\ChatBotLog;
+use App\Models\TwitchBotCommand;
+use App\TwitchBot\IRCMessage;
+use App\TwitchBot\TwitchBot;
+use React\Promise\Promise;
+
+class AdlibChatCommand extends BaseCommand {
+
+ public function __construct(TwitchBot $bot, TwitchBotCommand $cmd) {
+ parent::__construct($bot, $cmd);
+ }
+
+ public function execute() {
+ return new Promise(function($resolve) {
+ $channel = Channel::findOrFail($this->getParameter('channel'));
+ $db = $this->bot->getChatlibDatabase($channel);
+ $text = $db->generate();
+ $this->bot->sendIRCMessage(IRCMessage::privmsg($channel->twitch_chat, $text));
+ $log = new ChatBotLog();
+ $log->channel()->associate($channel);
+ $log->text = $text;
+ $log->user()->associate($this->getExecutingUser());
+ $log->category = 'adlib';
+ $log->save();
+ $resolve();
+ });
+ }
+
+}