public async Task GetPlayerSummariesAsync_Should_Succeed() { List <ulong> steamIds = new List <ulong>() { 76561198050013009 }; var response = await steamInterface.GetPlayerSummariesAsync(steamIds.AsReadOnly()); Assert.NotNull(response); Assert.NotNull(response.Data); }
/// <summary> /// Processes the users in the <see cref="usersDic"/> dictionary and matches them based on the method parameters. /// </summary> /// <param name="username">The username.</param> /// <param name="similarityThreshold">The profile picture similarity threshold.</param> /// <param name="compareUsername">if set to <c>true</c> usernames will be compared.</param> /// <param name="caseSensitiveUsername">if set to <c>true</c> will compare usernames with case sensitivity enabled.</param> /// <param name="compareAkaNames">if set to <c>true</c> will compare to users other names.</param> /// <param name="comparePfp">if set to <c>true</c> will compare profile pictures.</param> /// <param name="compareImage">The image to which to compare to.</param> /// <param name="userStatusSelectedIndex">Index of the <see cref="userStatusComboBox"/> control.</param> /// <param name="checkIngame">if set to <c>true</c> will check if user is ingame and if game matches <see cref="ingameId"/>.</param> /// <param name="ingameId">The game ID to compare to.</param> /// <param name="checkRecentGames">if set to <c>true</c> will check users recently played games.</param> /// <param name="recentGamesList">The recent games list to compare to.</param> private async Task processUsers(string username, int similarityThreshold, bool compareUsername, bool caseSensitiveUsername, bool compareAkaNames, bool comparePfp, Image compareImage, int userStatusSelectedIndex, bool checkIngame, string ingameId, bool checkRecentGames, List <string> recentGamesList) { status = Status.ProcessingUsers; if (!usersDic.ContainsKey(username)) { // Nothing to check return; } List <ulong> steamApiUsersQueue = new List <ulong>(); foreach (User user in usersDic[username]) { // Username text comparison if (compareUsername) { bool foundMatch = false; if (caseSensitiveUsername) { if (string.Equals(username, user.Username) || (user.CustomId && string.Equals(username, user.Id))) { foundMatch = true; } } else { if (string.Equals(username, user.Username, StringComparison.CurrentCultureIgnoreCase) || (user.CustomId && string.Equals(username, user.Id, StringComparison.CurrentCultureIgnoreCase))) { foundMatch = true; } } // Compare to other names the user goes by if (compareAkaNames) { foreach (string akaName in user.OtherNames) { if (caseSensitiveUsername) { if (string.Equals(akaName, user.Username)) { foundMatch = true; } } else { if (string.Equals(akaName, user.Username, StringComparison.CurrentCultureIgnoreCase)) { foundMatch = true; } } } } // No username match, continue on if (!foundMatch) { usersProcessed++; continue; } } // Profile picture comparison if (comparePfp) { double similarity = getImageSimilarityPercentage(compareImage, user.ProfilePic); if (similarity < similarityThreshold) { usersProcessed++; continue; } } // If no Steam API key then we finish here without continuing further on string userUrl = user.CustomId ? "https://steamcommunity.com/id/" + user.Id : "https://steamcommunity.com/profiles/" + user.Id; if (webInterfaceFactory == null) { foundUserUrls.Add(userUrl); usersProcessed++; continue; } // If true further processing needs to happen, so we add all ID's // to a list to coalesce requests which saves time and API requests if (userStatusSelectedIndex != 0 || checkIngame || checkRecentGames) { if (user.SteamId == 0) { user.SteamId = await getSteamIdVanityAsync(user.Id).ConfigureAwait(false); } steamApiUsersQueue.Add(user.SteamId); } } // GetPlayerSummaries has a limit of 100 steam Ids so the list needs to be split while (steamApiUsersQueue.Count > 0) { var tempSteamQueue = steamApiUsersQueue.Take(100).ToList(); IReadOnlyCollection <PlayerSummaryModel> playerSummaries = null; while (playerSummaries == null) { try { var playerSummariesResponse = await steamInterface.GetPlayerSummariesAsync(tempSteamQueue).ConfigureAwait(false); playerSummaries = playerSummariesResponse.Data; } catch { } } foreach (var playerSummary in playerSummaries) { // User status comparison // Offline state value is 0 while userStatusComboBox SelectedIndex will be 1 for offline // so we subtract 1 to align the values if (userStatusSelectedIndex != 0 && (int)playerSummary.UserStatus != (userStatusSelectedIndex - 1)) { usersProcessed++; continue; } // User in game if (checkIngame && playerSummary.PlayingGameId != ingameId) { usersProcessed++; continue; } // User recent games played if (checkRecentGames) { RecentlyPlayedGamesResultModel recentlyPlayedGameResult = null; while (true) { try { var playerRecentlyPlayedResponse = await playerService.GetRecentlyPlayedGamesAsync(playerSummary.SteamId).ConfigureAwait(false); recentlyPlayedGameResult = playerRecentlyPlayedResponse.Data; break; } catch { } } List <string> recentlyPlayedList = new List <string>(); foreach (var recentGame in recentlyPlayedGameResult.RecentlyPlayedGames) { recentlyPlayedList.Add(recentGame.AppId.ToString()); } if (!recentGamesList.All(i => recentlyPlayedList.Contains(i))) { usersProcessed++; continue; } } foundUserUrls.Add(playerSummary.ProfileUrl); } steamApiUsersQueue = steamApiUsersQueue.Skip(100).ToList(); } }