mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
rain control (#98)
This commit is contained in:
committed by
GitHub
parent
9f9bdee61d
commit
c065bf513b
@@ -3,6 +3,7 @@ using KfChatDotNetBot.Extensions;
|
|||||||
using KfChatDotNetBot.Models;
|
using KfChatDotNetBot.Models;
|
||||||
using KfChatDotNetBot.Models.DbModels;
|
using KfChatDotNetBot.Models.DbModels;
|
||||||
using KfChatDotNetBot.Services;
|
using KfChatDotNetBot.Services;
|
||||||
|
using KfChatDotNetBot.Settings;
|
||||||
using KfChatDotNetWsClient.Models.Events;
|
using KfChatDotNetWsClient.Models.Events;
|
||||||
namespace KfChatDotNetBot.Commands.Kasino;
|
namespace KfChatDotNetBot.Commands.Kasino;
|
||||||
|
|
||||||
@@ -23,6 +24,22 @@ public class RainCommand : ICommand
|
|||||||
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments,
|
||||||
CancellationToken ctx)
|
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);
|
var cleanupDelay = TimeSpan.FromSeconds(30);
|
||||||
if (botInstance.BotServices.KasinoRain == null || !botInstance.BotServices.KasinoRain.IsInitialized())
|
if (botInstance.BotServices.KasinoRain == null || !botInstance.BotServices.KasinoRain.IsInitialized())
|
||||||
{
|
{
|
||||||
@@ -116,7 +133,8 @@ public class RainCommand : ICommand
|
|||||||
RainAmount = decAmount,
|
RainAmount = decAmount,
|
||||||
PayoutWhen = DateTimeOffset.MaxValue
|
PayoutWhen = DateTimeOffset.MaxValue
|
||||||
};
|
};
|
||||||
var timer = 60;
|
var rainCountdown = settings[BuiltIn.Keys.KasinoRainCountdownDuration].ToType<int>();
|
||||||
|
var timer = rainCountdown;
|
||||||
var msg = await botInstance.SendChatMessageAsync(
|
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.",
|
$"🌧️🌧️ {user.FormatUsername()} is making it rain with {await decAmount.FormatKasinoCurrencyAsync()}! Type [ditto]!rain[/ditto] in the next {timer} seconds to join.",
|
||||||
true);
|
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
|
// 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)
|
// (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);
|
await botInstance.BotServices.KasinoRain.SaveRainState(rain);
|
||||||
while (timer > 0)
|
while (timer > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -540,17 +540,16 @@ public static class BuiltIn
|
|||||||
public static string KasinoRouletteEnabled = "Kasino.Roulette.Enabled";
|
public static string KasinoRouletteEnabled = "Kasino.Roulette.Enabled";
|
||||||
[BuiltInSetting("Roulette countdown duration in seconds", SettingValueType.Text, "120", WholeNumberRegex)]
|
[BuiltInSetting("Roulette countdown duration in seconds", SettingValueType.Text, "120", WholeNumberRegex)]
|
||||||
public static string KasinoRouletteCountdownDuration = "Kasino.Roulette.CountdownDuration";
|
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)]
|
[BuiltInSetting("Whether Xeet posting is enabled", SettingValueType.Boolean, "true", BooleanRegex)]
|
||||||
public static string XeetEnabled = "Xeet.Enabled";
|
public static string XeetEnabled = "Xeet.Enabled";
|
||||||
[BuiltInSetting("Maximum video duration in seconds for Xeet embeds", SettingValueType.Text, "120", WholeNumberRegex)]
|
[BuiltInSetting("Maximum video duration in seconds for Xeet embeds", SettingValueType.Text, "120", WholeNumberRegex)]
|
||||||
public static string XeetMaxVideoDurationSeconds = "Xeet.MaxVideoDurationSeconds";
|
public static string XeetMaxVideoDurationSeconds = "Xeet.MaxVideoDurationSeconds";
|
||||||
[BuiltInSetting("Connection string for bot's Redis", SettingValueType.Text)]
|
[BuiltInSetting("Connection string for bot's Redis", SettingValueType.Text)]
|
||||||
public static string BotRedisConnectionString = "Bot.RedisConnectionString";
|
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, "[]")]
|
[BuiltInSetting("Array of cookies as a shitty hack to get Rainbet going", SettingValueType.Array, "[]")]
|
||||||
public static string RainbetCookies = "Rainbet.Cookies";
|
public static string RainbetCookies = "Rainbet.Cookies";
|
||||||
[BuiltInSetting("Bossman's super secret user ID", SettingValueType.Text, "b5d4b169-2160-4b18-8865-6fe5dffa5c49")]
|
[BuiltInSetting("Bossman's super secret user ID", SettingValueType.Text, "b5d4b169-2160-4b18-8865-6fe5dffa5c49")]
|
||||||
|
|||||||
Reference in New Issue
Block a user