]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/TwitchBotCommand.php
exclude 0 scores from leaderboard calculation
[alttp.git] / app / Models / TwitchBotCommand.php
index f2b35e30657d42a1f57fc66eb9bc437df83233ea..716b8d5841cd1c2c628d6ddff5b1b0b623567c4f 100644 (file)
@@ -11,23 +11,40 @@ class TwitchBotCommand extends Model
 {
        use HasFactory;
 
-       public static function join($channel) {
+       public static function chat($channel, $text, User $user = null, $nick = 'localhorsttv') {
+               $cmd = new TwitchBotCommand();
+               $cmd->command = 'chat';
+               $cmd->parameters = [
+                       'channel' => $channel,
+                       'text' => $text,
+               ];
+               $cmd->status = 'pending';
+               $cmd->user()->associate($user);
+               $cmd->bot_nick = $nick;
+               $cmd->save();
+       }
+
+       public static function join($channel, User $user = null, $nick = 'localhorsttv') {
                $cmd = new TwitchBotCommand();
                $cmd->command = 'join';
                $cmd->parameters = [
                        'channel' => $channel,
                ];
                $cmd->status = 'pending';
+               $cmd->user()->associate($user);
+               $cmd->bot_nick = $nick;
                $cmd->save();
        }
 
-       public static function part($channel) {
+       public static function part($channel, User $user = null, $nick = 'localhorsttv') {
                $cmd = new TwitchBotCommand();
                $cmd->command = 'part';
                $cmd->parameters = [
                        'channel' => $channel,
                ];
                $cmd->status = 'pending';
+               $cmd->user()->associate($user);
+               $cmd->bot_nick = $nick;
                $cmd->save();
        }