From c04763079a9b800a12a7ee1bf7b5c077f0e5f962 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Sat, 18 Oct 2025 03:44:18 -0500 Subject: [PATCH] Removed juiceme --- KfChatDotNetBot/Commands/JuiceCommand.cs | 58 ------------------------ 1 file changed, 58 deletions(-) diff --git a/KfChatDotNetBot/Commands/JuiceCommand.cs b/KfChatDotNetBot/Commands/JuiceCommand.cs index af8e84e..ca7a8ec 100644 --- a/KfChatDotNetBot/Commands/JuiceCommand.cs +++ b/KfChatDotNetBot/Commands/JuiceCommand.cs @@ -9,64 +9,6 @@ using Microsoft.EntityFrameworkCore; namespace KfChatDotNetBot.Commands; -public class JuiceCommand : ICommand -{ - public List Patterns => [new Regex("^juiceme")]; - public string HelpText => "Get juice!"; - public bool HideFromHelp => false; - public UserRight RequiredRight => UserRight.Loser; - public TimeSpan Timeout => TimeSpan.FromSeconds(60); - public RateLimitOptionsModel? RateLimitOptions => null; - public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) - { - await using var db = new ApplicationDbContext(); - // Have to attach the entity because it is coming from another DB context - // https://stackoverflow.com/questions/52718652/ef-core-sqlite-sqlite-error-19-unique-constraint-failed - db.Users.Attach(user); - var juicerSettings = await SettingsProvider.GetMultipleValuesAsync([ - BuiltIn.Keys.JuiceAmount, BuiltIn.Keys.JuiceCooldown, BuiltIn.Keys.JuiceLoserDivision, - BuiltIn.Keys.GambaSeshDetectEnabled, BuiltIn.Keys.JuiceAllowedWhileStreaming, - BuiltIn.Keys.TwitchBossmanJackUsername, BuiltIn.Keys.JuiceAutoDeleteMsgDelay, - BuiltIn.Keys.TwitchGraphQlPersistedCurrentlyLive - ]); - var cooldown = juicerSettings[BuiltIn.Keys.JuiceCooldown].ToType(); - var amount = juicerSettings[BuiltIn.Keys.JuiceAmount].ToType(); - if (user.UserRight == UserRight.Loser) amount /= juicerSettings[BuiltIn.Keys.JuiceLoserDivision].ToType(); - var lastJuicer = (await db.Juicers.Where(j => j.User == user).ToListAsync(ctx)).OrderByDescending(j => j.JuicedAt).Take(1).ToList(); - if (!botInstance.GambaSeshPresent && juicerSettings[BuiltIn.Keys.GambaSeshDetectEnabled].ToBoolean()) - { - await botInstance.SendChatMessageAsync("Looks like GambaSesh isn't here. If he is, get him to say something then try again.", true); - return; - } - - if (!juicerSettings[BuiltIn.Keys.JuiceAllowedWhileStreaming].ToBoolean() && juicerSettings[BuiltIn.Keys.TwitchGraphQlPersistedCurrentlyLive].ToBoolean()) - { - await botInstance.SendChatMessageAsync( - $"No juicers permitted while {juicerSettings[BuiltIn.Keys.TwitchBossmanJackUsername].Value} is live!", true); - return; - } - - if (lastJuicer.Count == 0 || (lastJuicer[0].JuicedAt.AddSeconds(cooldown) - DateTimeOffset.UtcNow).TotalSeconds <= 0) - { - TimeSpan? autoDeleteAfter = null; - if (juicerSettings[BuiltIn.Keys.JuiceAutoDeleteMsgDelay].Value != null) - { - autoDeleteAfter = - TimeSpan.FromSeconds(juicerSettings[BuiltIn.Keys.JuiceAutoDeleteMsgDelay].ToType()); - } - await botInstance.SendChatMessageAsync($"!juice {message.Author.Id} {amount}", true, autoDeleteAfter: autoDeleteAfter); - await db.Juicers.AddAsync(new JuicerDbModel - { Amount = amount, User = user, JuicedAt = DateTimeOffset.UtcNow }, ctx); - await db.SaveChangesAsync(ctx); - return; - } - - var secondsRemaining = lastJuicer[0].JuicedAt.AddSeconds(cooldown) - DateTimeOffset.UtcNow; - - await botInstance.SendChatMessageAsync($"You gotta wait {secondsRemaining.Humanize(precision: 2, minUnit: TimeUnit.Second)} for another juicer", true); - } -} - public class JuiceStatsCommand : ICommand { public List Patterns => [