From 825ba114cb941c930869496eeee6c834068a2684 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Sat, 14 Sep 2024 16:38:45 +0800 Subject: [PATCH] Added a feature to make juicers way less generous for loser users --- KfChatDotNetBot/Commands/JuiceCommand.cs | 5 +++-- KfChatDotNetBot/Settings/BuiltIn.cs | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/KfChatDotNetBot/Commands/JuiceCommand.cs b/KfChatDotNetBot/Commands/JuiceCommand.cs index 0ca5dcb..3983099 100644 --- a/KfChatDotNetBot/Commands/JuiceCommand.cs +++ b/KfChatDotNetBot/Commands/JuiceCommand.cs @@ -13,7 +13,7 @@ public class JuiceCommand : ICommand public List Patterns => [new Regex("^juiceme")]; public string HelpText => "Get juice!"; public bool HideFromHelp => false; - public UserRight RequiredRight => UserRight.Guest; + public UserRight RequiredRight => UserRight.Loser; public TimeSpan Timeout => TimeSpan.FromSeconds(10); public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) { @@ -21,9 +21,10 @@ public class JuiceCommand : ICommand // 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 Helpers.GetMultipleValues([BuiltIn.Keys.JuiceAmount, BuiltIn.Keys.JuiceCooldown]); + var juicerSettings = await Helpers.GetMultipleValues([BuiltIn.Keys.JuiceAmount, BuiltIn.Keys.JuiceCooldown, BuiltIn.Keys.JuiceLoserDivision]); 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 (lastJuicer.Count == 0) { diff --git a/KfChatDotNetBot/Settings/BuiltIn.cs b/KfChatDotNetBot/Settings/BuiltIn.cs index 84f34a0..2357499 100644 --- a/KfChatDotNetBot/Settings/BuiltIn.cs +++ b/KfChatDotNetBot/Settings/BuiltIn.cs @@ -479,6 +479,16 @@ public static class BuiltIn Default = "10", IsSecret = false, CacheDuration = TimeSpan.FromHours(1) + }, + new BuiltInSettingsModel + { + Key = Keys.JuiceLoserDivision, + Regex = @"\d+", + Description = "Amount to divide the juice by if the user's rack is Loser", + Default = "5", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1) + }, new BuiltInSettingsModel { Key = Keys.CrackedZalgoFuckUpMode, @@ -541,6 +551,7 @@ public static class BuiltIn public static string TwitchShillRestreamOnCommercial = "Twitch.ShillRestreamOnCommercial"; public static string KiwiFarmsInactivityTimeout = "KiwiFarms.InactivityTimeout"; public static string KiwiFarmsPingInterval = "KiwiFarms.PingInterval"; + public static string JuiceLoserDivision = "Juice.LoserDivision"; public static string CrackedZalgoFuckUpMode = "Cracked.ZalgoFuckUpMode"; public static string CrackedZalgoFuckUpPosition = "Cracked.ZalgoFuckUpPosition"; }