rain control (#98)

This commit is contained in:
CrackmaticSoftware
2026-03-12 02:12:23 +01:00
committed by GitHub
parent 9f9bdee61d
commit c065bf513b
2 changed files with 24 additions and 7 deletions

View File

@@ -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<int>());
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<int>();
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)
{

View File

@@ -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")]