mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Configurable delays for the Pig Cube self destruct feature
This commit is contained in:
@@ -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<int>();
|
||||
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<int>()
|
||||
: new Random().Next(settings[BuiltIn.Keys.BotImagePigCubeSelfDestructMin].ToType<int>(),
|
||||
settings[BuiltIn.Keys.BotImagePigCubeSelfDestructMax].ToType<int>());
|
||||
logger.Info($"Deleting pig cube in {timeToDeletionMsec}ms");
|
||||
await Task.Delay(timeToDeletionMsec, ctx);
|
||||
await botInstance.KfClient.DeleteMessageAsync(msg.ChatMessageId.Value);
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user