Skip to content

Commit

Permalink
Discord bot (#92)
Browse files Browse the repository at this point in the history
* навалил кучу в админ апи (не работает)

* вернул как было + добавил роут для бана

* ban update

* update server api
  • Loading branch information
Sh1ntra authored Sep 24, 2024
1 parent 54fc039 commit 892b0d6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Content.Server/Administration/ServerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void IPostInjectInit.PostInject()
RegisterActorHandler(HttpMethod.Get, "/admin/info", InfoHandler);
RegisterHandler(HttpMethod.Get, "/admin/game_rules", GetGameRules);
RegisterHandler(HttpMethod.Get, "/admin/presets", GetPresets);
RegisterHandler(HttpMethod.Get, "/admin/getckey", ActionGetCkey);

// Post
RegisterActorHandler(HttpMethod.Post, "/admin/actions/round/start", ActionRoundStart);
Expand Down Expand Up @@ -497,6 +498,22 @@ await context.RespondJsonAsync(new GameruleResponse
GameRules = gameRules
});
}
/// <summary>
/// Returns a user ckey by NetUserId.
/// </summary>
private async Task ActionGetCkey(IStatusHandlerContext context)
{
var body = await ReadJson<GetCkeyActionBody>(context);
if (body == null)
return;

var data = await _locator.LookupIdAsync(new NetUserId(body.UserUid));

if (data != null)
await context.RespondJsonAsync(data.Username);
else
await context.RespondErrorAsync(HttpStatusCode.BadRequest);
}


/// <summary>
Expand Down Expand Up @@ -668,6 +685,11 @@ private sealed class KickActionBody
public string? Reason { get; init; }
}

private sealed class GetCkeyActionBody
{
public required Guid UserUid { get; init; }
}

private sealed class BanActionBody
{
public int Minutes { get; init; }
Expand Down

0 comments on commit 892b0d6

Please sign in to comment.