From 50eef47425d91c2ce0c46fdde6538b79917f4e04 Mon Sep 17 00:00:00 2001 From: svr333 Date: Sat, 11 Nov 2023 15:22:44 +0100 Subject: [PATCH] Add basic alts command --- src/AdvancedBot.Core/AdvancedBot.Core.csproj | 2 +- .../Commands/Modules/TelemetryModule.cs | 25 +++++++++++++++++++ .../Entities/Enums/LogAction.cs | 1 + src/AdvancedBot.Core/Services/LogService.cs | 1 + .../Services/ModerationService.cs | 14 ++++++++--- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/AdvancedBot.Core/AdvancedBot.Core.csproj b/src/AdvancedBot.Core/AdvancedBot.Core.csproj index ffb24ab..ff8cd84 100644 --- a/src/AdvancedBot.Core/AdvancedBot.Core.csproj +++ b/src/AdvancedBot.Core/AdvancedBot.Core.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/AdvancedBot.Core/Commands/Modules/TelemetryModule.cs b/src/AdvancedBot.Core/Commands/Modules/TelemetryModule.cs index 80f81c9..b63d591 100644 --- a/src/AdvancedBot.Core/Commands/Modules/TelemetryModule.cs +++ b/src/AdvancedBot.Core/Commands/Modules/TelemetryModule.cs @@ -59,5 +59,30 @@ public async Task LoginsAsync(uint userId) var result = await ModService.GetLoginsTelemetry(Context.User.Id, userId); await SendResponseMessage(result.Message, false); } + + [SlashCommand("accounts", "Shows information about linked accounts to this user")] + public async Task GetPossibleAltsAsync(uint userId) + { + var result = await ModService.GetPossibleAlts(Context.User.Id, userId); + var user = await GLService.GetUserProfileAsync(userId.ToString()); + + var fields = new List(); + + for (int i = 0; i < result.Output.Count; i++) + { + var trackerKey = result.Output.ElementAt(i).Key; + var trackerResult = result.Output.ElementAt(i).Value; + + fields.Add(new EmbedFieldBuilder() { Name = "Fingerprint Id", Value = trackerKey }.Build()); + fields.AddRange(trackerResult.OrderByDescending(x => x.Value).Select(x => new EmbedFieldBuilder() { Name = $"Id: {x.Key}", Value = $"Times 'logged in': {x.Value}"}.Build())); + } + + var templateEmbed = new EmbedBuilder() + { + Title = $"Possible Connections to {user.User.Name} ({userId})" + }; + + await SendPaginatedMessageAsync(fields, null, templateEmbed); + } } } diff --git a/src/AdvancedBot.Core/Entities/Enums/LogAction.cs b/src/AdvancedBot.Core/Entities/Enums/LogAction.cs index 0ec313f..3e945c9 100644 --- a/src/AdvancedBot.Core/Entities/Enums/LogAction.cs +++ b/src/AdvancedBot.Core/Entities/Enums/LogAction.cs @@ -29,5 +29,6 @@ public enum LogAction ForceStopWar = 24, AddEmulate = 25, RemoveEmulate = 26, + GetAccounts = 27, } } diff --git a/src/AdvancedBot.Core/Services/LogService.cs b/src/AdvancedBot.Core/Services/LogService.cs index 7fb7b4b..4264490 100644 --- a/src/AdvancedBot.Core/Services/LogService.cs +++ b/src/AdvancedBot.Core/Services/LogService.cs @@ -76,6 +76,7 @@ public Embed GetEmbedForLog(Log log, User victim) case LogAction.EnableMaintenance: case LogAction.AddEmulate: case LogAction.RemoveEmulate: + case LogAction.GetAccounts: default: break; case LogAction.Ban: diff --git a/src/AdvancedBot.Core/Services/ModerationService.cs b/src/AdvancedBot.Core/Services/ModerationService.cs index a526438..39aeebc 100644 --- a/src/AdvancedBot.Core/Services/ModerationService.cs +++ b/src/AdvancedBot.Core/Services/ModerationService.cs @@ -479,7 +479,7 @@ public async Task ForceEndWarStagingAsync(ulong discordId, string all public async Task>> GetBattleLogTelemetry(ulong discordId, uint userId) { var result = await _gl.Api.GetBattlelogTelemetry(userId.ToString()); - await _logs.LogGameActionAsync(LogAction.GetTelemetry, discordId, 0, "BattleLogs"); + await _logs.LogGameActionAsync(LogAction.GetTelemetry, discordId, userId, "BattleLogs"); return new ModResult>(result, ModResultType.Success); } @@ -487,7 +487,7 @@ public async Task>> GetBattleLogTelemetry(ulong discor public async Task>> GetGiftsTelemetry(ulong discordId, uint userId) { var result = await _gl.Api.GetGiftsTelemetry(userId.ToString()); - await _logs.LogGameActionAsync(LogAction.GetTelemetry, discordId, 0, "Gifts"); + await _logs.LogGameActionAsync(LogAction.GetTelemetry, discordId, userId, "Gifts"); return new ModResult>(result, ModResultType.Success); } @@ -495,11 +495,19 @@ public async Task>> GetGiftsTelemetry(ulong discordId, uint public async Task>> GetLoginsTelemetry(ulong discordId, uint userId) { var result = await _gl.Api.GetLoginsTelemetry(userId.ToString()); - await _logs.LogGameActionAsync(LogAction.GetTelemetry, discordId, 0, "Gifts"); + await _logs.LogGameActionAsync(LogAction.GetTelemetry, discordId, userId, "Gifts"); return new ModResult>(result, ModResultType.Success); } + public async Task>>> GetPossibleAlts(ulong discordId, uint userId) + { + var result = await _gl.Api.GetFingerprint(userId.ToString()); + await _logs.LogGameActionAsync(LogAction.GetAccounts, discordId, userId); + + return new ModResult>>(result, ModResultType.Success); + } + private void OnBanTimer(object sender, ElapsedEventArgs e) { var bans = _storage.GetTempbans();