Skip to content

Commit

Permalink
Only allow single bot for PlayerProfile requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Mar 5, 2024
1 parent 6997ce7 commit 117acca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CS2Interface/CS/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ private void OnGCMessage(SteamGameCoordinator.MessageCallback callback) {
return;
}

#if DEBUG
Bot.ArchiLogger.LogGenericDebug(String.Format("Message Received: {0}", callback.EMsg));
#endif

OnGCMessageRecieved?.Invoke(callback);

var messageMap = new Dictionary<uint, Action<IPacketGCMsg>> {
Expand Down
22 changes: 11 additions & 11 deletions CS2Interface/IPC/Api/CS2InterfaceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,24 @@ public async Task<ActionResult<GenericResponse>> InspectItem(
return Ok(new GenericResponse<InspectItem>(true, item));
}

[HttpGet("{botNames:required}/PlayerProfile/{steamID:required}")]
[SwaggerOperation (Summary = "Get a CS2 player profile")]
[HttpGet("{botName:required}/PlayerProfile/{steamID:required}")]
[SwaggerOperation (Summary = "Get a friend's CS2 player profile")]
[ProducesResponseType(typeof(GenericResponse<CMsgGCCStrike15_v2_PlayersProfile>), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.GatewayTimeout)]
public async Task<ActionResult<GenericResponse>> PlayerProfile([FromRoute] string botNames, [FromRoute] ulong steamID) {
if (string.IsNullOrEmpty(botNames)) {
throw new ArgumentNullException(nameof(botNames));
public async Task<ActionResult<GenericResponse>> PlayerProfile([FromRoute] string botName, [FromRoute] ulong steamID) {
if (string.IsNullOrEmpty(botName)) {
throw new ArgumentNullException(nameof(botName));
}

HashSet<Bot>? bots = Bot.GetBots(botNames);
if ((bots == null) || (bots.Count == 0)) {
return BadRequest(new GenericResponse(false, string.Format(Strings.BotNotFound, botNames)));
Bot? bot = Bot.GetBot(botName);
if (bot == null) {
return BadRequest(new GenericResponse(false, string.Format(Strings.BotNotFound, botName)));
}

(Bot? bot, Client? client, string status) = ClientHandler.GetAvailableClient(bots);
if (bot == null || client == null) {
return BadRequest(new GenericResponse(false, status));
(Client? client, string client_status) = ClientHandler.ClientHandlers[bot.BotName].GetClient();
if (client == null) {
return BadRequest(new GenericResponse(false, client_status));
}

CMsgGCCStrike15_v2_PlayersProfile player;
Expand Down

0 comments on commit 117acca

Please sign in to comment.