mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-16 02:52:44 -04:00
Toggle between active gambler stats and all stats
This commit is contained in:
@@ -22,6 +22,8 @@ public class LegitCheckCommand : ICommand
|
|||||||
public List<Regex> Patterns =>
|
public List<Regex> Patterns =>
|
||||||
[
|
[
|
||||||
new Regex(@"^legitcheck (?<user_id>\d+)$", RegexOptions.IgnoreCase),
|
new Regex(@"^legitcheck (?<user_id>\d+)$", RegexOptions.IgnoreCase),
|
||||||
|
new Regex(@"^legitcheck (?<user_id>\d+) all$", RegexOptions.IgnoreCase),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public string? HelpText => "Check a user's kasino RTP statistics";
|
public string? HelpText => "Check a user's kasino RTP statistics";
|
||||||
@@ -45,6 +47,7 @@ public class LegitCheckCommand : ICommand
|
|||||||
|
|
||||||
var targetUserId = int.Parse(arguments["user_id"].Value);
|
var targetUserId = int.Parse(arguments["user_id"].Value);
|
||||||
var targetUser = await db.Users.FirstOrDefaultAsync(u => u.KfId == targetUserId, ctx);
|
var targetUser = await db.Users.FirstOrDefaultAsync(u => u.KfId == targetUserId, ctx);
|
||||||
|
var isAll = message.MessageRaw.EndsWith(" all");
|
||||||
|
|
||||||
if (targetUser == null)
|
if (targetUser == null)
|
||||||
{
|
{
|
||||||
@@ -55,10 +58,26 @@ public class LegitCheckCommand : ICommand
|
|||||||
|
|
||||||
// A user can have multiple gambler entities (e.g., if they abandoned an account or got reset).
|
// A user can have multiple gambler entities (e.g., if they abandoned an account or got reset).
|
||||||
// We want to aggregate stats across ALL their gambler entities for a complete picture.
|
// We want to aggregate stats across ALL their gambler entities for a complete picture.
|
||||||
var gamblerIds = await db.Gamblers
|
List<int> gamblerIds = [];
|
||||||
.Where(g => g.User.Id == targetUser.Id)
|
if (isAll)
|
||||||
.Select(g => g.Id)
|
{
|
||||||
.ToListAsync(ctx);
|
gamblerIds = await db.Gamblers
|
||||||
|
.Where(g => g.User.Id == targetUser.Id)
|
||||||
|
.Select(g => g.Id)
|
||||||
|
.ToListAsync(ctx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var gambler = await Money.GetGamblerEntityAsync(user.Id, ct: ctx);
|
||||||
|
if (gambler == null)
|
||||||
|
{
|
||||||
|
await botInstance.SendChatMessageAsync(
|
||||||
|
$"{user.FormatUsername()}, {targetUser.KfUsername} has never played at the kasino.", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gamblerIds.Add(gambler.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (gamblerIds.Count == 0)
|
if (gamblerIds.Count == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user