From 72e5115548dbe38f73a467f50a0d955ce9d5d8a8 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Fri, 27 Feb 2026 00:20:09 -0600 Subject: [PATCH] Forgive input errors for kasino games when rate limiting --- .../Commands/Kasino/BlackjackCommand.cs | 9 ++++++ .../Commands/Kasino/CoinflipCommand.cs | 29 ++++++++++--------- .../Commands/Kasino/DiceCommand.cs | 3 ++ .../Commands/Kasino/GuessWhatNumberCommand.cs | 3 ++ .../Commands/Kasino/KenoCommand.cs | 4 +++ .../Commands/Kasino/LambchopCommand.cs | 4 +++ .../Commands/Kasino/LimboCommand.cs | 4 +++ .../Commands/Kasino/MinesCommand.cs | 22 +++++++++----- .../Commands/Kasino/PlanesCommand.cs | 3 ++ .../Commands/Kasino/PlinkoCommand.cs | 3 ++ .../Commands/Kasino/RouletteCommand.cs | 4 +++ .../Commands/Kasino/SlotsCommand.cs | 4 +++ .../Commands/Kasino/WheelCommand.cs | 4 +++ 13 files changed, 76 insertions(+), 20 deletions(-) diff --git a/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs b/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs index a9b3291..1b01f5d 100644 --- a/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/BlackjackCommand.cs @@ -94,6 +94,7 @@ public class BlackjackCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -102,6 +103,7 @@ public class BlackjackCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -236,6 +238,7 @@ public class BlackjackCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you don't have an active blackjack game. Start one with !bj ", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -245,6 +248,7 @@ public class BlackjackCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your game data is corrupted. Please start a new game.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); activeWager.IsComplete = true; await _dbContext.SaveChangesAsync(ctx); return; @@ -284,6 +288,7 @@ public class BlackjackCommand : ICommand $"{user.FormatUsername()}, game error: no cards left in deck. Game forfeited.", true, autoDeleteAfter: cleanupDelay); await ForfeitGame(botInstance, user, gambler, wager, cleanupDelay, ctx); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -418,6 +423,7 @@ public class BlackjackCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you can only split with two cards of the same rank.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -427,6 +433,7 @@ public class BlackjackCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you can only split once per game.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -436,6 +443,7 @@ public class BlackjackCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you don't have enough balance to split.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -445,6 +453,7 @@ public class BlackjackCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, not enough cards in deck to split.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } diff --git a/KfChatDotNetBot/Commands/Kasino/CoinflipCommand.cs b/KfChatDotNetBot/Commands/Kasino/CoinflipCommand.cs index be59c5b..8e15c91 100644 --- a/KfChatDotNetBot/Commands/Kasino/CoinflipCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/CoinflipCommand.cs @@ -57,6 +57,7 @@ public class CoinflipCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, not enough arguments. !coinflip ", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -65,6 +66,7 @@ public class CoinflipCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, not enough arguments. !coinflip ", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -75,6 +77,7 @@ public class CoinflipCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your wager must be greater than zero.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -87,6 +90,7 @@ public class CoinflipCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } var rolled = Money.GetRandomDouble(gambler); @@ -111,22 +115,21 @@ public class CoinflipCommand : ICommand $"{user.FormatUsername()}, you [B][COLOR={colors[BuiltIn.Keys.KiwiFarmsGreenColor].Value}]WON![/COLOR][/B] " + $"You won {await effect.FormatKasinoCurrencyAsync()} and your balance is now {await newBalance.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + return; } - else - { - // lost - bool isJacky = rolled > 0.5; // would've won without house edge - var coinflipAnimationURL = GetCoinFlipAnimationUrl("heads" == choiceStr ? "tails" : "heads", isJacky); - await botInstance.SendChatMessageAsync($"[IMG]{coinflipAnimationURL}[/IMG]", true, autoDeleteAfter: cleanupDelay); - await Task.Delay(1500, ctx); + // lost + bool isJacky = rolled > 0.5; // would've won without house edge + var coinflipAnimationURL = GetCoinFlipAnimationUrl("heads" == choiceStr ? "tails" : "heads", isJacky); - newBalance = await Money.NewWagerAsync(gambler.Id, wager, -wager, WagerGame.CoinFlip, ct: ctx); - await botInstance.SendChatMessageAsync( - $"{user.FormatUsername()}, you [B][COLOR={colors[BuiltIn.Keys.KiwiFarmsRedColor].Value}]LOST![/COLOR][/B] " + - $"Your balance is now {await newBalance.FormatKasinoCurrencyAsync()}", - true, autoDeleteAfter: cleanupDelay); - } + await botInstance.SendChatMessageAsync($"[IMG]{coinflipAnimationURL}[/IMG]", true, autoDeleteAfter: cleanupDelay); + await Task.Delay(1500, ctx); + + newBalance = await Money.NewWagerAsync(gambler.Id, wager, -wager, WagerGame.CoinFlip, ct: ctx); + await botInstance.SendChatMessageAsync( + $"{user.FormatUsername()}, you [B][COLOR={colors[BuiltIn.Keys.KiwiFarmsRedColor].Value}]LOST![/COLOR][/B] " + + $"Your balance is now {await newBalance.FormatKasinoCurrencyAsync()}", + true, autoDeleteAfter: cleanupDelay); } private static string GetCoinFlipAnimationUrl(string choiceStr, bool isJacky = false) diff --git a/KfChatDotNetBot/Commands/Kasino/DiceCommand.cs b/KfChatDotNetBot/Commands/Kasino/DiceCommand.cs index d989cd1..724b6aa 100644 --- a/KfChatDotNetBot/Commands/Kasino/DiceCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/DiceCommand.cs @@ -53,6 +53,7 @@ public class DiceCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, not enough arguments. !dice ", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } var wager = Convert.ToDecimal(amount.Value); @@ -64,6 +65,7 @@ public class DiceCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -72,6 +74,7 @@ public class DiceCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } diff --git a/KfChatDotNetBot/Commands/Kasino/GuessWhatNumberCommand.cs b/KfChatDotNetBot/Commands/Kasino/GuessWhatNumberCommand.cs index 6964a11..ec2620a 100644 --- a/KfChatDotNetBot/Commands/Kasino/GuessWhatNumberCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/GuessWhatNumberCommand.cs @@ -45,6 +45,7 @@ public class GuessWhatNumberCommand : ICommand if (!arguments.TryGetValue("amount", out var amount)) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !guess ", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -53,6 +54,7 @@ public class GuessWhatNumberCommand : ICommand if (guess is < 1 or > 10) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, your guess must be between 1 and 10", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx); @@ -71,6 +73,7 @@ public class GuessWhatNumberCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } diff --git a/KfChatDotNetBot/Commands/Kasino/KenoCommand.cs b/KfChatDotNetBot/Commands/Kasino/KenoCommand.cs index 391312e..a948a10 100644 --- a/KfChatDotNetBot/Commands/Kasino/KenoCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/KenoCommand.cs @@ -66,6 +66,7 @@ public class KenoCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, not enough arguments. !keno , or !keno and 10 will be selected automatically", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -90,6 +91,7 @@ public class KenoCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -98,6 +100,7 @@ public class KenoCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -105,6 +108,7 @@ public class KenoCommand : ICommand { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you can only pick numbers from 1 - 10", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } diff --git a/KfChatDotNetBot/Commands/Kasino/LambchopCommand.cs b/KfChatDotNetBot/Commands/Kasino/LambchopCommand.cs index 01a1419..e3cb28e 100644 --- a/KfChatDotNetBot/Commands/Kasino/LambchopCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/LambchopCommand.cs @@ -85,12 +85,14 @@ public class LambchopCommand : ICommand if (!arguments.TryGetValue("amount", out var amount)) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !lambchop ", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } var targetTile = arguments["targetTile"].Success ? Convert.ToInt32(arguments["targetTile"].Value) : FIELD_LENGTH; if (targetTile is < 1 or > FIELD_LENGTH) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, Please choose a target tile between 1 and {FIELD_LENGTH}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } var wager = Convert.ToDecimal(amount.Value); @@ -102,6 +104,7 @@ public class LambchopCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -110,6 +113,7 @@ public class LambchopCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } diff --git a/KfChatDotNetBot/Commands/Kasino/LimboCommand.cs b/KfChatDotNetBot/Commands/Kasino/LimboCommand.cs index 17dbb83..c76e86a 100644 --- a/KfChatDotNetBot/Commands/Kasino/LimboCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/LimboCommand.cs @@ -59,6 +59,7 @@ public class LimboCommand : ICommand { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !limbo ", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } var wager = Convert.ToDecimal(amount.Value); @@ -70,6 +71,7 @@ public class LimboCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -78,6 +80,7 @@ public class LimboCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -92,6 +95,7 @@ public class LimboCommand : ICommand { //cancel the game if user does not choose a correct number await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you must choose a number greater than 1", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } decimal newBalance; diff --git a/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs b/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs index 2d045ea..07d1be5 100644 --- a/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs @@ -96,11 +96,10 @@ public class MinesCommand : ICommand await KasinoMines.Cashout(KasinoMines.ActiveGames[gambler.Id]); return; } - else - { - await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you don't have a game running to cash out.", true, autoDeleteAfter: cleanupDelay); - return; - } + + await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you don't have a game running to cash out.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); + return; } //check if user has an existing game already @@ -119,6 +118,7 @@ public class MinesCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, not enough arguments(bet+). !mines to play simple mines. !mines for advanced mines. Tool: {ToolUrl}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } decimal wager = Convert.ToDecimal(bet.Value); @@ -126,6 +126,7 @@ public class MinesCommand : ICommand { await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance is too low. Balance: {gambler.Balance.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -133,6 +134,7 @@ public class MinesCommand : ICommand { await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to bet something to play mines.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } if (!arguments.TryGetValue("size", out var size) || !arguments.TryGetValue("mines", out var mines)) @@ -140,6 +142,7 @@ public class MinesCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, not enough arguments(mines and or size+). !mines to play simple mines. !mines for advanced mines. Tool: {ToolUrl}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -152,7 +155,7 @@ public class MinesCommand : ICommand else if (arguments.TryGetValue("betString", out var betString)) //if they are using precise picks manually or from the tool to select specific squares to reveal { var matches = Regex.Matches(message.Message, BetPattern); - if (matches.Count == 0 || matches == null) //if invalid bet string + if (matches.Count == 0) //if invalid bet string { await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, invalid bet string. Example: !mines 100 10 10 1,3 1,5 2,6 - or use the tool: {ToolUrl}", true, autoDeleteAfter: cleanupDelay); @@ -168,18 +171,21 @@ public class MinesCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, not enough arguments(picks or betstring). !mines to play simple mines. !mines for advanced mines. Tool: {ToolUrl}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } int boardSize = Convert.ToInt32(size.Value); if (boardSize < 2 || boardSize > 8) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, board size must be between 2 and 9.",true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } int minesCount = Convert.ToInt32(mines.Value); if (minesCount < 1 || minesCount > (boardSize * boardSize) - 1) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, number of mines must be between 1 and {boardSize * boardSize - 1}(size^2 - 1).",true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } //at this point all valid values so good to continue making the game @@ -196,6 +202,7 @@ public class MinesCommand : ICommand if (game.BetsPlaced.Contains(coord) || coord.r < 0 || coord.r > game.Size || coord.c < 0 || coord.c > game.Size) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you can't place duplicate or invalid bets. Use the tool: {ToolUrl}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } } @@ -232,6 +239,7 @@ public class MinesCommand : ICommand { await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, invalid bet string. Example: !mines 100 10 10 1,3 1,5 2,6 - or use the tool: {ToolUrl}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } foreach (Match match in matches) @@ -255,7 +263,7 @@ public class MinesCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you already have a game running. !mines to reveal more spaces, !mines cashout to cash out, !mines to place precise picks. Tool: {ToolUrl}", true, autoDeleteAfter: cleanupDelay); - + RateLimitService.RemoveMostRecentEntry(user, this); return; } diff --git a/KfChatDotNetBot/Commands/Kasino/PlanesCommand.cs b/KfChatDotNetBot/Commands/Kasino/PlanesCommand.cs index c198fc9..18ed19c 100644 --- a/KfChatDotNetBot/Commands/Kasino/PlanesCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/PlanesCommand.cs @@ -68,6 +68,7 @@ public class Planes : ICommand { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !planes ", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } var wager = Convert.ToDecimal(amount.Value); @@ -79,6 +80,7 @@ public class Planes : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -87,6 +89,7 @@ public class Planes : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } diff --git a/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs b/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs index 944ad73..6615655 100644 --- a/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/PlinkoCommand.cs @@ -143,6 +143,7 @@ public class PlinkoCommand : ICommand { await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you can only play with 1 - 10 balls at a time", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } if (gambler.Balance < wager * numberOfBalls) @@ -150,6 +151,7 @@ public class PlinkoCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -158,6 +160,7 @@ public class PlinkoCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } diff --git a/KfChatDotNetBot/Commands/Kasino/RouletteCommand.cs b/KfChatDotNetBot/Commands/Kasino/RouletteCommand.cs index 5ed7e54..f102f26 100644 --- a/KfChatDotNetBot/Commands/Kasino/RouletteCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/RouletteCommand.cs @@ -120,6 +120,7 @@ public class RouletteCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, invalid syntax. Use: !roulette ", true, autoDeleteAfter: TimeSpan.FromSeconds(10)); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -144,6 +145,7 @@ public class RouletteCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: TimeSpan.FromSeconds(10)); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -152,6 +154,7 @@ public class RouletteCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: TimeSpan.FromSeconds(10)); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -162,6 +165,7 @@ public class RouletteCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, invalid bet. Valid bets: 0-36, red/black, odd/even, low/high, 1st12/2nd12/3rd12, col1/col2/col3", true, autoDeleteAfter: TimeSpan.FromSeconds(10)); + RateLimitService.RemoveMostRecentEntry(user, this); return; } diff --git a/KfChatDotNetBot/Commands/Kasino/SlotsCommand.cs b/KfChatDotNetBot/Commands/Kasino/SlotsCommand.cs index ca460e9..c041455 100644 --- a/KfChatDotNetBot/Commands/Kasino/SlotsCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/SlotsCommand.cs @@ -65,6 +65,7 @@ public class SlotsCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you need to bet something to play. !slots [bet]", true, autoDeleteAfter: TimeSpan.FromSeconds(30)); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -75,6 +76,7 @@ public class SlotsCommand : ICommand if (spins < 1 || spins > 10) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()} you can only do between 1 and 10 spins.", true, autoDeleteAfter: TimeSpan.FromSeconds(30)); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -82,6 +84,7 @@ public class SlotsCommand : ICommand var wager = Convert.ToDecimal(amount.Value); if (wager < (decimal)0.01){ await botInstance.SendChatMessageAsync($"{user.FormatUsername()} you must bet a minimum of $0.01 KKK", true, autoDeleteAfter: TimeSpan.FromSeconds(30)); + RateLimitService.RemoveMostRecentEntry(user, this); return; } var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx); @@ -92,6 +95,7 @@ public class SlotsCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: TimeSpan.FromSeconds(30)); + RateLimitService.RemoveMostRecentEntry(user, this); return; } diff --git a/KfChatDotNetBot/Commands/Kasino/WheelCommand.cs b/KfChatDotNetBot/Commands/Kasino/WheelCommand.cs index 4aa0128..9a03eae 100644 --- a/KfChatDotNetBot/Commands/Kasino/WheelCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/WheelCommand.cs @@ -84,6 +84,7 @@ public class WheelCommand : ICommand if (!arguments.TryGetValue("amount", out var amount)) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !wheel ", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx); @@ -93,6 +94,7 @@ public class WheelCommand : ICommand if (difficulty.ToLower() is not ("l" or "low" or "m" or "medium" or "h" or "high")) { await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, unrecognized difficulty selection, please choose between: low, medium, high", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -102,6 +104,7 @@ public class WheelCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; } @@ -110,6 +113,7 @@ public class WheelCommand : ICommand await botInstance.SendChatMessageAsync( $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); + RateLimitService.RemoveMostRecentEntry(user, this); return; }