From 21c8803eb98206c88f96122d8c2f5a6515299c36 Mon Sep 17 00:00:00 2001 From: alogindtractor <251821224+A-Log-In-D-Tractor@users.noreply.github.com> Date: Mon, 9 Feb 2026 07:00:45 -0800 Subject: [PATCH] fix board size, some fixes to auto cashout from cursor (#75) * cursor fixes cursor fixes * Improve cashout condition validation Refactor cashout condition to check for success and non-empty value. * cursor cursor * Update BotServices.cs * Update board size limit from 10 to 9 Update board size limit from 10 to 9 81 characters instead of 100 12 bytes per character per powershell, down from 1200 bytes to 972 * Implement message deletion for active games Added logic to delete messages associated with active games. --- KfChatDotNetBot/Commands/Kasino/MinesCommand.cs | 7 ++++--- KfChatDotNetBot/Services/BotServices.cs | 2 +- KfChatDotNetBot/Services/KasinoMines.cs | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs b/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs index 3be2485..e251802 100644 --- a/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs +++ b/KfChatDotNetBot/Commands/Kasino/MinesCommand.cs @@ -80,7 +80,8 @@ public class MinesCommand : ICommand return; } bool cashout = false; - if (arguments.TryGetValue("cashout", out var cashOut)||message.Message.Contains("cashout")) cashout = true; + if (arguments.TryGetValue("cashout", out var cashOut) && cashOut.Success && !string.IsNullOrWhiteSpace(cashOut.Value)) + cashout = true; if (!Regex.IsMatch(message.Message, @"\d") && cashout) //if the message has no ints its a cashout attempt { @@ -173,9 +174,9 @@ public class MinesCommand : ICommand return; } int boardSize = Convert.ToInt32(size.Value); - if (boardSize < 2 || boardSize > 10) + if (boardSize < 2 || boardSize > 9) { - await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, board size must be between 2 and 10.",true, autoDeleteAfter: cleanupDelay); + await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, board size must be between 2 and 9.",true, autoDeleteAfter: cleanupDelay); return; } int minesCount = Convert.ToInt32(mines.Value); diff --git a/KfChatDotNetBot/Services/BotServices.cs b/KfChatDotNetBot/Services/BotServices.cs index fb0e687..bf56e28 100644 --- a/KfChatDotNetBot/Services/BotServices.cs +++ b/KfChatDotNetBot/Services/BotServices.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.Text.Json; using Humanizer; using KfChatDotNetBot.Extensions; using KfChatDotNetBot.Models; diff --git a/KfChatDotNetBot/Services/KasinoMines.cs b/KfChatDotNetBot/Services/KasinoMines.cs index b01fa04..90bfbb5 100644 --- a/KfChatDotNetBot/Services/KasinoMines.cs +++ b/KfChatDotNetBot/Services/KasinoMines.cs @@ -101,9 +101,10 @@ public class KasinoMines for (int r = 0; r < Size; r++) { await Task.Delay(100); - revealedSpace = false; + for (int c = 0; c < Size; c++) { + revealedSpace = false; foreach (var bet in BetsPlaced) { if (bet.r == r && bet.c == c) revealedSpace = true; @@ -150,6 +151,7 @@ public class KasinoMines await Task.Delay(TimeSpan.FromSeconds(10)); await _kfChatBot.KfClient.DeleteMessageAsync(msg.ChatMessageId!.Value); + LastMessageId = 0; (int vertical, int horizontal) DistanceFromMine((int r, int c) coord) { @@ -291,6 +293,8 @@ public class KasinoMines public async Task RemoveGame(int gamblerId) { await GetSavedGames(gamblerId); + //attempt to delete the message if its there + if (ActiveGames[gamblerId].LastMessageId != 0) _kfChatBot.KfClient.DeleteMessage(ActiveGames[gamblerId].LastMessageId); ActiveGames?.Remove(gamblerId); await SaveActiveGames(gamblerId); }