diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 497d3d256b3ff..d593ae906c20a 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -750,17 +750,29 @@ internal static async Task ResponseRedeem(string botName, string message return await bot.ResponseRedeem(message, validate).ConfigureAwait(false); } - internal async Task ResponseAddLicense(uint gameID) { - if (gameID == 0) { + internal async Task ResponseAddLicense(HashSet gameIDs) { + if (gameIDs == null || gameIDs.Count == 0) { return null; } - var result = await SteamApps.RequestFreeLicense(gameID); - return "Result: " + result.Result + " | Granted apps: " + string.Join(", ", result.GrantedApps) + " " + string.Join(", ", result.GrantedPackages); + StringBuilder result = new StringBuilder(); + foreach (uint gameID in gameIDs) { + SteamApps.FreeLicenseCallback callback; + try { + callback = await SteamApps.RequestFreeLicense(gameID); + } catch (Exception e) { + Logging.LogGenericException(e); + continue; + } + + result.AppendLine("Result: " + callback.Result + " | Granted apps: " + string.Join(", ", callback.GrantedApps) + " " + string.Join(", ", callback.GrantedPackages)); + } + + return result.ToString(); } - internal static async Task ResponseAddLicense(string botName, string game) { - if (string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(game)) { + internal static async Task ResponseAddLicense(string botName, string games) { + if (string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) { return null; } @@ -769,12 +781,22 @@ internal static async Task ResponseAddLicense(string botName, string gam return "Couldn't find any bot named " + botName + "!"; } - uint gameID; - if (!uint.TryParse(game, out gameID)) { - return "Couldn't parse game as a number!"; + string[] gameIDs = games.Split(','); + + HashSet gamesToRedeem = new HashSet(); + foreach (string game in gameIDs) { + uint gameID; + if (!uint.TryParse(game, out gameID)) { + continue; + } + gamesToRedeem.Add(gameID); + } + + if (gamesToRedeem.Count == 0) { + return "Couldn't parse any games given!"; } - return await bot.ResponseAddLicense(gameID).ConfigureAwait(false); + return await bot.ResponseAddLicense(gamesToRedeem).ConfigureAwait(false); } internal async Task ResponsePlay(HashSet gameIDs) {