Forgive input errors for kasino games when rate limiting

This commit is contained in:
barelyprofessional
2026-02-27 00:20:09 -06:00
parent 1337db31b3
commit 72e5115548
13 changed files with 76 additions and 20 deletions

View File

@@ -94,6 +94,7 @@ public class BlackjackCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -102,6 +103,7 @@ public class BlackjackCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true,
autoDeleteAfter: cleanupDelay); autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -236,6 +238,7 @@ public class BlackjackCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you don't have an active blackjack game. Start one with !bj <amount>", $"{user.FormatUsername()}, you don't have an active blackjack game. Start one with !bj <amount>",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -245,6 +248,7 @@ public class BlackjackCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your game data is corrupted. Please start a new game.", $"{user.FormatUsername()}, your game data is corrupted. Please start a new game.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
activeWager.IsComplete = true; activeWager.IsComplete = true;
await _dbContext.SaveChangesAsync(ctx); await _dbContext.SaveChangesAsync(ctx);
return; return;
@@ -284,6 +288,7 @@ public class BlackjackCommand : ICommand
$"{user.FormatUsername()}, game error: no cards left in deck. Game forfeited.", $"{user.FormatUsername()}, game error: no cards left in deck. Game forfeited.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
await ForfeitGame(botInstance, user, gambler, wager, cleanupDelay, ctx); await ForfeitGame(botInstance, user, gambler, wager, cleanupDelay, ctx);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -418,6 +423,7 @@ public class BlackjackCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you can only split with two cards of the same rank.", $"{user.FormatUsername()}, you can only split with two cards of the same rank.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -427,6 +433,7 @@ public class BlackjackCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you can only split once per game.", $"{user.FormatUsername()}, you can only split once per game.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -436,6 +443,7 @@ public class BlackjackCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you don't have enough balance to split.", $"{user.FormatUsername()}, you don't have enough balance to split.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -445,6 +453,7 @@ public class BlackjackCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, not enough cards in deck to split.", $"{user.FormatUsername()}, not enough cards in deck to split.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }

View File

@@ -57,6 +57,7 @@ public class CoinflipCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, not enough arguments. !coinflip <wager> <heads|tails>", $"{user.FormatUsername()}, not enough arguments. !coinflip <wager> <heads|tails>",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -65,6 +66,7 @@ public class CoinflipCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, not enough arguments. !coinflip <wager> <heads|tails>", $"{user.FormatUsername()}, not enough arguments. !coinflip <wager> <heads|tails>",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -75,6 +77,7 @@ public class CoinflipCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your wager must be greater than zero.", $"{user.FormatUsername()}, your wager must be greater than zero.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -87,6 +90,7 @@ public class CoinflipCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
var rolled = Money.GetRandomDouble(gambler); 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] " + $"{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()}", $"You won {await effect.FormatKasinoCurrencyAsync()} and your balance is now {await newBalance.FormatKasinoCurrencyAsync()}",
true, autoDeleteAfter: cleanupDelay); 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); // lost
await Task.Delay(1500, ctx); 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($"[IMG]{coinflipAnimationURL}[/IMG]", true, autoDeleteAfter: cleanupDelay);
await botInstance.SendChatMessageAsync( await Task.Delay(1500, ctx);
$"{user.FormatUsername()}, you [B][COLOR={colors[BuiltIn.Keys.KiwiFarmsRedColor].Value}]LOST![/COLOR][/B] " +
$"Your balance is now {await newBalance.FormatKasinoCurrencyAsync()}", newBalance = await Money.NewWagerAsync(gambler.Id, wager, -wager, WagerGame.CoinFlip, ct: ctx);
true, autoDeleteAfter: cleanupDelay); 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) private static string GetCoinFlipAnimationUrl(string choiceStr, bool isJacky = false)

View File

@@ -53,6 +53,7 @@ public class DiceCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, not enough arguments. !dice <wager>", $"{user.FormatUsername()}, not enough arguments. !dice <wager>",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
var wager = Convert.ToDecimal(amount.Value); var wager = Convert.ToDecimal(amount.Value);
@@ -64,6 +65,7 @@ public class DiceCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -72,6 +74,7 @@ public class DiceCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true,
autoDeleteAfter: cleanupDelay); autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }

View File

@@ -45,6 +45,7 @@ public class GuessWhatNumberCommand : ICommand
if (!arguments.TryGetValue("amount", out var amount)) if (!arguments.TryGetValue("amount", out var amount))
{ {
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !guess <wager> <number between 1 and 10>", true, autoDeleteAfter: cleanupDelay); await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !guess <wager> <number between 1 and 10>", true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -53,6 +54,7 @@ public class GuessWhatNumberCommand : ICommand
if (guess is < 1 or > 10) if (guess is < 1 or > 10)
{ {
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, your guess must be between 1 and 10", true, autoDeleteAfter: cleanupDelay); await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, your guess must be between 1 and 10", true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx); var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx);
@@ -71,6 +73,7 @@ public class GuessWhatNumberCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true,
autoDeleteAfter: cleanupDelay); autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }

View File

@@ -66,6 +66,7 @@ public class KenoCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, not enough arguments. !keno <wager> <number between 1 and 10>, or !keno <wager> and 10 will be selected automatically", $"{user.FormatUsername()}, not enough arguments. !keno <wager> <number between 1 and 10>, or !keno <wager> and 10 will be selected automatically",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -90,6 +91,7 @@ public class KenoCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -98,6 +100,7 @@ public class KenoCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true,
autoDeleteAfter: cleanupDelay); autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -105,6 +108,7 @@ public class KenoCommand : ICommand
{ {
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you can only pick numbers from 1 - 10", await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you can only pick numbers from 1 - 10",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }

View File

@@ -85,12 +85,14 @@ public class LambchopCommand : ICommand
if (!arguments.TryGetValue("amount", out var amount)) if (!arguments.TryGetValue("amount", out var amount))
{ {
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !lambchop <wager> <number between 1 and {FIELD_LENGTH}>", true, autoDeleteAfter: cleanupDelay); await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !lambchop <wager> <number between 1 and {FIELD_LENGTH}>", true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
var targetTile = arguments["targetTile"].Success ? Convert.ToInt32(arguments["targetTile"].Value) : FIELD_LENGTH; var targetTile = arguments["targetTile"].Success ? Convert.ToInt32(arguments["targetTile"].Value) : FIELD_LENGTH;
if (targetTile is < 1 or > 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); await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, Please choose a target tile between 1 and {FIELD_LENGTH}", true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
var wager = Convert.ToDecimal(amount.Value); var wager = Convert.ToDecimal(amount.Value);
@@ -102,6 +104,7 @@ public class LambchopCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -110,6 +113,7 @@ public class LambchopCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true,
autoDeleteAfter: cleanupDelay); autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }

View File

@@ -59,6 +59,7 @@ public class LimboCommand : ICommand
{ {
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !limbo <wager>", await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !limbo <wager>",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
var wager = Convert.ToDecimal(amount.Value); var wager = Convert.ToDecimal(amount.Value);
@@ -70,6 +71,7 @@ public class LimboCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -78,6 +80,7 @@ public class LimboCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true,
autoDeleteAfter: cleanupDelay); autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -92,6 +95,7 @@ public class LimboCommand : ICommand
{ {
//cancel the game if user does not choose a correct number //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); await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you must choose a number greater than 1", true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
decimal newBalance; decimal newBalance;

View File

@@ -96,11 +96,10 @@ public class MinesCommand : ICommand
await KasinoMines.Cashout(KasinoMines.ActiveGames[gambler.Id]); await KasinoMines.Cashout(KasinoMines.ActiveGames[gambler.Id]);
return; return;
} }
else
{ await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you don't have a game running to cash out.", true, autoDeleteAfter: cleanupDelay);
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, you don't have a game running to cash out.", true, autoDeleteAfter: cleanupDelay); RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
}
} }
//check if user has an existing game already //check if user has an existing game already
@@ -119,6 +118,7 @@ public class MinesCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, not enough arguments(bet+). !mines <bet> <board size> <number of mines> <picks> to play simple mines. !mines <bet> <board size> <number of mines> <betString> for advanced mines. Tool: {ToolUrl}", $"{user.FormatUsername()}, not enough arguments(bet+). !mines <bet> <board size> <number of mines> <picks> to play simple mines. !mines <bet> <board size> <number of mines> <betString> for advanced mines. Tool: {ToolUrl}",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
decimal wager = Convert.ToDecimal(bet.Value); decimal wager = Convert.ToDecimal(bet.Value);
@@ -126,6 +126,7 @@ public class MinesCommand : ICommand
{ {
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance is too low. Balance: {gambler.Balance.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay); $"{user.FormatUsername()}, your balance is too low. Balance: {gambler.Balance.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -133,6 +134,7 @@ public class MinesCommand : ICommand
{ {
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to bet something to play mines.", true, autoDeleteAfter: cleanupDelay); $"{user.FormatUsername()}, you have to bet something to play mines.", true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
if (!arguments.TryGetValue("size", out var size) || !arguments.TryGetValue("mines", out var mines)) if (!arguments.TryGetValue("size", out var size) || !arguments.TryGetValue("mines", out var mines))
@@ -140,6 +142,7 @@ public class MinesCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, not enough arguments(mines and or size+). !mines <bet> <board size> <number of mines> <picks> to play simple mines. !mines <bet> <board size> <number of mines> <betString> for advanced mines. Tool: {ToolUrl}", $"{user.FormatUsername()}, not enough arguments(mines and or size+). !mines <bet> <board size> <number of mines> <picks> to play simple mines. !mines <bet> <board size> <number of mines> <betString> for advanced mines. Tool: {ToolUrl}",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; 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 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); 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( 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); $"{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( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, not enough arguments(picks or betstring). !mines <bet> <board size> <number of mines> <picks> to play simple mines. !mines <bet> <board size> <number of mines> <betString> for advanced mines. Tool: {ToolUrl}", $"{user.FormatUsername()}, not enough arguments(picks or betstring). !mines <bet> <board size> <number of mines> <picks> to play simple mines. !mines <bet> <board size> <number of mines> <betString> for advanced mines. Tool: {ToolUrl}",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
int boardSize = Convert.ToInt32(size.Value); int boardSize = Convert.ToInt32(size.Value);
if (boardSize < 2 || boardSize > 8) if (boardSize < 2 || boardSize > 8)
{ {
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, board size must be between 2 and 9.",true, autoDeleteAfter: cleanupDelay); await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, board size must be between 2 and 9.",true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
int minesCount = Convert.ToInt32(mines.Value); int minesCount = Convert.ToInt32(mines.Value);
if (minesCount < 1 || minesCount > (boardSize * boardSize) - 1) 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); 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; return;
} }
//at this point all valid values so good to continue making the game //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) 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); 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; return;
} }
} }
@@ -232,6 +239,7 @@ public class MinesCommand : ICommand
{ {
await botInstance.SendChatMessageAsync( 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); $"{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; return;
} }
foreach (Match match in matches) foreach (Match match in matches)
@@ -255,7 +263,7 @@ public class MinesCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you already have a game running. !mines <picks> to reveal more spaces, !mines cashout to cash out, !mines <bet string> to place precise picks. Tool: {ToolUrl}", $"{user.FormatUsername()}, you already have a game running. !mines <picks> to reveal more spaces, !mines cashout to cash out, !mines <bet string> to place precise picks. Tool: {ToolUrl}",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }

View File

@@ -68,6 +68,7 @@ public class Planes : ICommand
{ {
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !planes <wager>", await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !planes <wager>",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
var wager = Convert.ToDecimal(amount.Value); var wager = Convert.ToDecimal(amount.Value);
@@ -79,6 +80,7 @@ public class Planes : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -87,6 +89,7 @@ public class Planes : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true,
autoDeleteAfter: cleanupDelay); autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }

View File

@@ -143,6 +143,7 @@ public class PlinkoCommand : ICommand
{ {
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you can only play with 1 - 10 balls at a time", true, autoDeleteAfter: cleanupDelay); $"{user.FormatUsername()}, you can only play with 1 - 10 balls at a time", true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
if (gambler.Balance < wager * numberOfBalls) if (gambler.Balance < wager * numberOfBalls)
@@ -150,6 +151,7 @@ public class PlinkoCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -158,6 +160,7 @@ public class PlinkoCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true,
autoDeleteAfter: cleanupDelay); autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }

View File

@@ -120,6 +120,7 @@ public class RouletteCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, invalid syntax. Use: !roulette <amount> <bet>", $"{user.FormatUsername()}, invalid syntax. Use: !roulette <amount> <bet>",
true, autoDeleteAfter: TimeSpan.FromSeconds(10)); true, autoDeleteAfter: TimeSpan.FromSeconds(10));
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -144,6 +145,7 @@ public class RouletteCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: TimeSpan.FromSeconds(10)); true, autoDeleteAfter: TimeSpan.FromSeconds(10));
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -152,6 +154,7 @@ public class RouletteCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true,
autoDeleteAfter: TimeSpan.FromSeconds(10)); autoDeleteAfter: TimeSpan.FromSeconds(10));
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -162,6 +165,7 @@ public class RouletteCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, invalid bet. Valid bets: 0-36, red/black, odd/even, low/high, 1st12/2nd12/3rd12, col1/col2/col3", $"{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)); true, autoDeleteAfter: TimeSpan.FromSeconds(10));
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }

View File

@@ -65,6 +65,7 @@ public class SlotsCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you need to bet something to play. !slots [bet]", $"{user.FormatUsername()}, you need to bet something to play. !slots [bet]",
true, autoDeleteAfter: TimeSpan.FromSeconds(30)); true, autoDeleteAfter: TimeSpan.FromSeconds(30));
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -75,6 +76,7 @@ public class SlotsCommand : ICommand
if (spins < 1 || spins > 10) if (spins < 1 || spins > 10)
{ {
await botInstance.SendChatMessageAsync($"{user.FormatUsername()} you can only do between 1 and 10 spins.", true, autoDeleteAfter: TimeSpan.FromSeconds(30)); await botInstance.SendChatMessageAsync($"{user.FormatUsername()} you can only do between 1 and 10 spins.", true, autoDeleteAfter: TimeSpan.FromSeconds(30));
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -82,6 +84,7 @@ public class SlotsCommand : ICommand
var wager = Convert.ToDecimal(amount.Value); var wager = Convert.ToDecimal(amount.Value);
if (wager < (decimal)0.01){ if (wager < (decimal)0.01){
await botInstance.SendChatMessageAsync($"{user.FormatUsername()} you must bet a minimum of $0.01 KKK", true, autoDeleteAfter: TimeSpan.FromSeconds(30)); await botInstance.SendChatMessageAsync($"{user.FormatUsername()} you must bet a minimum of $0.01 KKK", true, autoDeleteAfter: TimeSpan.FromSeconds(30));
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx); var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx);
@@ -92,6 +95,7 @@ public class SlotsCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: TimeSpan.FromSeconds(30)); true, autoDeleteAfter: TimeSpan.FromSeconds(30));
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }

View File

@@ -84,6 +84,7 @@ public class WheelCommand : ICommand
if (!arguments.TryGetValue("amount", out var amount)) if (!arguments.TryGetValue("amount", out var amount))
{ {
await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !wheel <wager> <difficulty: low, medium, high>", true, autoDeleteAfter: cleanupDelay); await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, not enough arguments. !wheel <wager> <difficulty: low, medium, high>", true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx); 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")) 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); await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, unrecognized difficulty selection, please choose between: low, medium, high", true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -102,6 +104,7 @@ public class WheelCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.", $"{user.FormatUsername()}, your balance of {await gambler.Balance.FormatKasinoCurrencyAsync()} isn't enough for this wager.",
true, autoDeleteAfter: cleanupDelay); true, autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }
@@ -110,6 +113,7 @@ public class WheelCommand : ICommand
await botInstance.SendChatMessageAsync( await botInstance.SendChatMessageAsync(
$"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true, $"{user.FormatUsername()}, you have to wager more than {await wager.FormatKasinoCurrencyAsync()}", true,
autoDeleteAfter: cleanupDelay); autoDeleteAfter: cleanupDelay);
RateLimitService.RemoveMostRecentEntry(user, this);
return; return;
} }