diff --git a/KfChatDotNetBot/Commands/Kasino/KasinoUserCommands.cs b/KfChatDotNetBot/Commands/Kasino/KasinoUserCommands.cs index 80b8ab0..0e16d8c 100644 --- a/KfChatDotNetBot/Commands/Kasino/KasinoUserCommands.cs +++ b/KfChatDotNetBot/Commands/Kasino/KasinoUserCommands.cs @@ -268,4 +268,36 @@ public class AbandonKasinoCommand : ICommand await db.SaveChangesAsync(ctx); await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, Kasino account with ID {gambler.Id} has been marked as abandoned.", true); } +} + +[KasinoCommand] +public class PocketWatchCommand : ICommand +{ + public List Patterns => [ + new Regex(@"^pocketwatch (?\d+)", RegexOptions.IgnoreCase), + ]; + public string? HelpText => "Check a user's balance"; + public UserRight RequiredRight => UserRight.Loser; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + public RateLimitOptionsModel? RateLimitOptions => null; + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, + CancellationToken ctx) + { + await using var db = new ApplicationDbContext(); + var targetUser = await db.Users.FirstOrDefaultAsync(u => u.KfId == int.Parse(arguments["user_id"].Value), ctx); + if (targetUser == null) + { + await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, the user ID you gave doesn't exist.", true); + return; + } + + var targetGambler = await Money.GetGamblerEntityAsync(targetUser.Id, ct: ctx); + if (targetGambler == null) + { + await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, this user is excluded from the kasino", true); + return; + } + + await botInstance.SendChatMessageAsync($"{user.FormatUsername()}, {targetUser.KfUsername} has {await targetGambler.Balance.FormatKasinoCurrencyAsync()}", true); + } } \ No newline at end of file