From adf38b9c53c142913aa28e19a46cba40d09cda42 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Fri, 2 May 2025 12:41:40 -0500 Subject: [PATCH] Configurable delays for the Pig Cube self destruct feature --- KfChatDotNetBot/Commands/ImageCommands.cs | 8 +++--- KfChatDotNetBot/Settings/BuiltIn.cs | 33 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/KfChatDotNetBot/Commands/ImageCommands.cs b/KfChatDotNetBot/Commands/ImageCommands.cs index 8e99371..8623c3c 100644 --- a/KfChatDotNetBot/Commands/ImageCommands.cs +++ b/KfChatDotNetBot/Commands/ImageCommands.cs @@ -148,7 +148,8 @@ public class GetRandomImage : ICommand if (!await images.AnyAsync(ctx)) return; var settings = await Helpers.GetMultipleValues([ BuiltIn.Keys.BotImageRandomSliceDivideBy, BuiltIn.Keys.BotImagePigCubeSelfDestruct, - BuiltIn.Keys.BotImageInvertedCubeUrl + BuiltIn.Keys.BotImageInvertedCubeUrl, BuiltIn.Keys.BotImagePigCubeSelfDestructMin, + BuiltIn.Keys.BotImagePigCubeSelfDestructMax, BuiltIn.Keys.BotImageInvertedPigCubeSelfDestructDelay ]); var divideBy = settings[BuiltIn.Keys.BotImageRandomSliceDivideBy].ToType(); var limit = 1; @@ -185,8 +186,9 @@ public class GetRandomImage : ICommand } var timeToDeletionMsec = image.Url == settings[BuiltIn.Keys.BotImageInvertedCubeUrl].Value - ? 5000 - : new Random().Next(5 * 1000, 15 * 1000); + ? settings[BuiltIn.Keys.BotImageInvertedPigCubeSelfDestructDelay].ToType() + : new Random().Next(settings[BuiltIn.Keys.BotImagePigCubeSelfDestructMin].ToType(), + settings[BuiltIn.Keys.BotImagePigCubeSelfDestructMax].ToType()); logger.Info($"Deleting pig cube in {timeToDeletionMsec}ms"); await Task.Delay(timeToDeletionMsec, ctx); await botInstance.KfClient.DeleteMessageAsync(msg.ChatMessageId.Value); diff --git a/KfChatDotNetBot/Settings/BuiltIn.cs b/KfChatDotNetBot/Settings/BuiltIn.cs index c6f5eae..e7dac15 100644 --- a/KfChatDotNetBot/Settings/BuiltIn.cs +++ b/KfChatDotNetBot/Settings/BuiltIn.cs @@ -804,6 +804,36 @@ public static class BuiltIn IsSecret = false, CacheDuration = TimeSpan.FromHours(1), ValueType = SettingValueType.Text + }, + new BuiltInSettingsModel + { + Key = Keys.BotImagePigCubeSelfDestructMin, + Regex = @"\d+", + Description = "Min value for the Pig Cube self destruct Random.Next() in milliseconds", + Default = "5000", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1), + ValueType = SettingValueType.Text + }, + new BuiltInSettingsModel + { + Key = Keys.BotImagePigCubeSelfDestructMax, + Regex = @"\d+", + Description = "Max value for the Pig Cube self destruct Random.Next() in milliseconds", + Default = "15000", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1), + ValueType = SettingValueType.Text + }, + new BuiltInSettingsModel + { + Key = Keys.BotImageInvertedPigCubeSelfDestructDelay, + Regex = @"\d+", + Description = "Value in milliseconds for how long the bot should wait before self destructing the inverted pig cube", + Default = "5000", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1), + ValueType = SettingValueType.Text } ]; @@ -878,5 +908,8 @@ public static class BuiltIn public static string BotImagePigCubeSelfDestruct = "Bot.Image.PigCubeSelfDestruct"; public static string BotImageInvertedCubeUrl = "Bot.Image.InvertedCubeUrl"; public static string JuiceAutoDeleteMsgDelay = "Juice.AutoDeleteMsgDelay"; + public static string BotImagePigCubeSelfDestructMin = "Bot.Image.PigCubeSelfDestructMin"; + public static string BotImagePigCubeSelfDestructMax = "Bot.Image.PigCubeSelfDestructMax"; + public static string BotImageInvertedPigCubeSelfDestructDelay = "Bot.Image.InvertedPigCubeSelfDestructDelay"; } } \ No newline at end of file