Skip to content

Commit

Permalink
Add basic alts command
Browse files Browse the repository at this point in the history
  • Loading branch information
svr333 committed Nov 11, 2023
1 parent 0b7d230 commit 50eef47
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/AdvancedBot.Core/AdvancedBot.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="3.10.0" />
<PackageReference Include="GL.Net" Version="0.4.6" />
<PackageReference Include="GL.Net" Version="0.4.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="LiteDB" Version="5.0.13" />
<PackageReference Include="Humanizer" Version="2.14.1" />
Expand Down
25 changes: 25 additions & 0 deletions src/AdvancedBot.Core/Commands/Modules/TelemetryModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<EmbedField>();

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);
}
}
}
1 change: 1 addition & 0 deletions src/AdvancedBot.Core/Entities/Enums/LogAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ public enum LogAction
ForceStopWar = 24,
AddEmulate = 25,
RemoveEmulate = 26,
GetAccounts = 27,
}
}
1 change: 1 addition & 0 deletions src/AdvancedBot.Core/Services/LogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 11 additions & 3 deletions src/AdvancedBot.Core/Services/ModerationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,27 +479,35 @@ public async Task<ModResult> ForceEndWarStagingAsync(ulong discordId, string all
public async Task<ModResult<List<BattleLog>>> 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<List<BattleLog>>(result, ModResultType.Success);
}

public async Task<ModResult<List<Gift>>> 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<List<Gift>>(result, ModResultType.Success);
}

public async Task<ModResult<List<Login>>> 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<List<Login>>(result, ModResultType.Success);
}

public async Task<ModResult<Dictionary<string, Dictionary<string, int>>>> GetPossibleAlts(ulong discordId, uint userId)
{
var result = await _gl.Api.GetFingerprint(userId.ToString());
await _logs.LogGameActionAsync(LogAction.GetAccounts, discordId, userId);

return new ModResult<Dictionary<string, Dictionary<string, int>>>(result, ModResultType.Success);
}

private void OnBanTimer(object sender, ElapsedEventArgs e)
{
var bans = _storage.GetTempbans();
Expand Down

0 comments on commit 50eef47

Please sign in to comment.