diff --git a/KfChatDotNetBot/Commands/Kasino/RainCommand.cs b/KfChatDotNetBot/Commands/Kasino/RainCommand.cs index 35a5438..eabf0c8 100644 --- a/KfChatDotNetBot/Commands/Kasino/RainCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/RainCommand.cs @@ -3,6 +3,7 @@ using KfChatDotNetBot.Extensions; using KfChatDotNetBot.Models; using KfChatDotNetBot.Models.DbModels; using KfChatDotNetBot.Services; +using KfChatDotNetBot.Settings; using KfChatDotNetWsClient.Models.Events; namespace KfChatDotNetBot.Commands.Kasino; @@ -23,6 +24,22 @@ public class RainCommand : ICommand public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) { + var settings = await SettingsProvider.GetMultipleValuesAsync([ + BuiltIn.Keys.KasinoGameDisabledMessageCleanupDelay, BuiltIn.Keys.KasinoRainCountdownDuration, + BuiltIn.Keys.KasinoRainEnabled + ]); + + // Check if rain is enabled + var rainEnabled = (settings[BuiltIn.Keys.KasinoRainEnabled]).ToBoolean(); + if (!rainEnabled) + { + var gameDisabledCleanupDelay= TimeSpan.FromMilliseconds(settings[BuiltIn.Keys.KasinoGameDisabledMessageCleanupDelay].ToType()); + await botInstance.SendChatMessageAsync( + $"{user.FormatUsername()}, rain is currently disabled.", + true, autoDeleteAfter: gameDisabledCleanupDelay); + return; + } + var cleanupDelay = TimeSpan.FromSeconds(30); if (botInstance.BotServices.KasinoRain == null || !botInstance.BotServices.KasinoRain.IsInitialized()) { @@ -116,7 +133,8 @@ public class RainCommand : ICommand RainAmount = decAmount, PayoutWhen = DateTimeOffset.MaxValue }; - var timer = 60; + var rainCountdown = settings[BuiltIn.Keys.KasinoRainCountdownDuration].ToType(); + var timer = rainCountdown; var msg = await botInstance.SendChatMessageAsync( $"🌧️🌧️ {user.FormatUsername()} is making it rain with {await decAmount.FormatKasinoCurrencyAsync()}! Type [ditto]!rain[/ditto] in the next {timer} seconds to join.", true); @@ -128,7 +146,7 @@ public class RainCommand : ICommand // Wait to set a real payout deadline only when chyat echoes the message out of fairness // (and also so the timer doesn't overlap with the payout deadline) - rain.PayoutWhen = DateTimeOffset.UtcNow.AddSeconds(60); + rain.PayoutWhen = DateTimeOffset.UtcNow.AddSeconds(rainCountdown); await botInstance.BotServices.KasinoRain.SaveRainState(rain); while (timer > 0) { diff --git a/KfChatDotNetBot/Settings/BuiltIn.cs b/KfChatDotNetBot/Settings/BuiltIn.cs index 441483e..ca79686 100644 --- a/KfChatDotNetBot/Settings/BuiltIn.cs +++ b/KfChatDotNetBot/Settings/BuiltIn.cs @@ -540,17 +540,16 @@ public static class BuiltIn public static string KasinoRouletteEnabled = "Kasino.Roulette.Enabled"; [BuiltInSetting("Roulette countdown duration in seconds", SettingValueType.Text, "120", WholeNumberRegex)] public static string KasinoRouletteCountdownDuration = "Kasino.Roulette.CountdownDuration"; + [BuiltInSetting("Whether rain is enabled", SettingValueType.Boolean, "true", BooleanRegex)] + public static string KasinoRainEnabled = "Kasino.Rain.Enabled"; + [BuiltInSetting("Rain countdown duration in seconds", SettingValueType.Text, "60", WholeNumberRegex)] + public static string KasinoRainCountdownDuration = "Kasino.Rain.CountdownDuration"; [BuiltInSetting("Whether Xeet posting is enabled", SettingValueType.Boolean, "true", BooleanRegex)] public static string XeetEnabled = "Xeet.Enabled"; [BuiltInSetting("Maximum video duration in seconds for Xeet embeds", SettingValueType.Text, "120", WholeNumberRegex)] public static string XeetMaxVideoDurationSeconds = "Xeet.MaxVideoDurationSeconds"; [BuiltInSetting("Connection string for bot's Redis", SettingValueType.Text)] public static string BotRedisConnectionString = "Bot.RedisConnectionString"; - [BuiltInSetting("Whether to automatically rehost images when they're added", SettingValueType.Boolean, "true", - BooleanRegex)] - public static string BotImageRehostEnabled = "Bot.Image.RehostEnabled"; - [BuiltInSetting("Domain to look for when determining whether to rehost", SettingValueType.Text, "i.ddos.lgbt")] - public static string BotImageRehostDomain = "Bot.Image.RehostDomain"; [BuiltInSetting("Array of cookies as a shitty hack to get Rainbet going", SettingValueType.Array, "[]")] public static string RainbetCookies = "Rainbet.Cookies"; [BuiltInSetting("Bossman's super secret user ID", SettingValueType.Text, "b5d4b169-2160-4b18-8865-6fe5dffa5c49")]