From 3c70fea2bace0fbddef63d64e62b4a51f683a4ab Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Tue, 25 Nov 2025 00:54:11 -0600 Subject: [PATCH] Added admin commands for everything but abandon and close. Changed selection time weighted payout to a property instead of having different types --- .../Commands/Kasino/KasinoEventCommands.cs | 367 ++++++++++++++++++ KfChatDotNetBot/Models/MoneyModels.cs | 8 +- KfChatDotNetBot/Services/Money.cs | 8 + KfChatDotNetBot/Settings/BuiltIn.cs | 13 + 4 files changed, 392 insertions(+), 4 deletions(-) create mode 100644 KfChatDotNetBot/Commands/Kasino/KasinoEventCommands.cs diff --git a/KfChatDotNetBot/Commands/Kasino/KasinoEventCommands.cs b/KfChatDotNetBot/Commands/Kasino/KasinoEventCommands.cs new file mode 100644 index 0000000..9db968f --- /dev/null +++ b/KfChatDotNetBot/Commands/Kasino/KasinoEventCommands.cs @@ -0,0 +1,367 @@ +using System.Text.RegularExpressions; +using Humanizer; +using KfChatDotNetBot.Extensions; +using KfChatDotNetBot.Models; +using KfChatDotNetBot.Models.DbModels; +using KfChatDotNetBot.Services; +using KfChatDotNetBot.Settings; +using KfChatDotNetWsClient.Models.Events; + +namespace KfChatDotNetBot.Commands.Kasino; + +public class KasinoNewEventCommand : ICommand +{ + public List Patterns => + [ + new Regex("^kasino event new$", RegexOptions.IgnoreCase), + new Regex(@"^kasino event new (?\w+)$", RegexOptions.IgnoreCase), + new Regex(@"^kasino event new (?\w+) (?.+)$", RegexOptions.IgnoreCase), + ]; + + public string? HelpText => "Create a new kasino event"; + public UserRight RequiredRight => UserRight.TrueAndHonest; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public RateLimitOptionsModel? RateLimitOptions => null; + + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, + CancellationToken ctx) + { + var settings = await SettingsProvider.GetMultipleValuesAsync([ + BuiltIn.Keys.KasinoEventWeightWinAgainstSelectionTime, BuiltIn.Keys.KasinoEventData, + BuiltIn.Keys.KasinoEventTextLengthLimit + ]); + if (!arguments.TryGetValue("type", out var type)) + { + await botInstance.SendChatMessageAsync( + $"{user.FormatUsername()}, not enough arguments. !kasino event new ", + true, autoDeleteAfter: TimeSpan.FromSeconds(60)); + return; + } + + if (!arguments.TryGetValue("description", out var description)) + { + await botInstance.SendChatMessageAsync( + $"{user.FormatUsername()}, not enough arguments. !kasino event new ", + true, autoDeleteAfter: TimeSpan.FromSeconds(60)); + return; + } + + if (description.Length > settings[BuiltIn.Keys.KasinoEventTextLengthLimit].ToType()) + { + await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, your event description / text with a length of " + + $"{description.Length} characters exceeds the limit of " + + $"{settings[BuiltIn.Keys.KasinoEventTextLengthLimit].ToType()} " + + $"characters", true); + return; + } + + var useTimeWeightedPayout = settings[BuiltIn.Keys.KasinoEventWeightWinAgainstSelectionTime].ToBoolean(); + KasinoEventType eventType; + var guide = string.Empty; + if (type.Value.Equals("win-lose", StringComparison.CurrentCultureIgnoreCase)) + { + eventType = KasinoEventType.WinLose; + guide = "Add option: !kasino event {EventId} options add|new [br]" + + "Remove option: !kasino event {EventId} options del|remove