diff --git a/BoosterCreator/BoosterCreator.csproj b/BoosterCreator/BoosterCreator.csproj index 732a315..0687402 100644 --- a/BoosterCreator/BoosterCreator.csproj +++ b/BoosterCreator/BoosterCreator.csproj @@ -3,7 +3,7 @@ net8.0 Out - 2.0.0.0 + 2.0.0.1 enable latest diff --git a/BoosterCreator/BoosterHandler.cs b/BoosterCreator/BoosterHandler.cs index 774c01f..38188c6 100644 --- a/BoosterCreator/BoosterHandler.cs +++ b/BoosterCreator/BoosterHandler.cs @@ -15,6 +15,7 @@ using System.Text.Json.Serialization; using System.Text.Json; using ArchiSteamFarm.Helpers.Json; +using System.Collections.ObjectModel; namespace BoosterCreator { internal sealed class BoosterHandler : IDisposable { @@ -85,7 +86,7 @@ private async Task AutoBooster() { uint tradableGooAmount = uint.Parse(gooAmounts[1].Value); uint unTradableGooAmount = uint.Parse(gooAmounts[2].Value); - IEnumerable? enumerableBoosters = info.Value.ToJsonObject>(); + IEnumerable? enumerableBoosters = info.Value.ToJsonObject>(); if (enumerableBoosters == null) { bot.ArchiLogger.LogNullError(enumerableBoosters); return Commands.FormatBotResponse(bot, string.Format(Strings.ErrorParsingObject, nameof(enumerableBoosters))); @@ -108,7 +109,13 @@ private async Task AutoBooster() { continue; } Steam.BoosterInfo bi = boosterInfos[gameID.Key]; - if (gooAmount < bi.Price) { + + if (!uint.TryParse(bi.Price, out uint gemPrice)) { + response.AppendLine(Commands.FormatBotResponse(bot, "Failed to create booster from " + gameID.Key.ToString())); + continue; + } + + if (gooAmount < gemPrice) { response.AppendLine(Commands.FormatBotResponse(bot, "Not enough gems to create booster from " + gameID.Key.ToString())); //If we have not enough gems - wait 8 hours, just in case gems will be added to account later bot.ArchiLogger.LogGenericInfo(Commands.FormatBotResponse(bot, "Not enough gems to create booster from " + gameID.Key.ToString())); @@ -154,10 +161,11 @@ private async Task AutoBooster() { uint nTp; if (unTradableGooAmount > 0) { - nTp = tradableGooAmount > bi.Price ? (uint) 1 : 3; + nTp = tradableGooAmount > gemPrice ? (uint) 1 : 3; } else { nTp = 2; } + Steam.BoostersResponse? result = await WebRequest.CreateBooster(bot, bi.AppID, bi.Series, nTp).ConfigureAwait(false); if (result?.Result?.Result != EResult.OK) { response.AppendLine(Commands.FormatBotResponse(bot, "Failed to create booster from " + gameID.Key.ToString())); @@ -169,8 +177,9 @@ private async Task AutoBooster() { } continue; } - gooAmount = result.GooAmount; - tradableGooAmount = result.TradableGooAmount; + + gooAmount = uint.Parse(result.GooAmount!); + tradableGooAmount = uint.Parse(result.TradableGooAmount!); unTradableGooAmount = result.UntradableGooAmount; response.AppendLine(Commands.FormatBotResponse(bot, "Successfuly created booster from " + gameID.Key.ToString())); bot.ArchiLogger.LogGenericInfo(Commands.FormatBotResponse(bot, "Successfuly created booster from " + gameID.Key.ToString())); diff --git a/BoosterCreator/Json.cs b/BoosterCreator/Json.cs index 1a1df66..2c8aa6f 100644 --- a/BoosterCreator/Json.cs +++ b/BoosterCreator/Json.cs @@ -2,9 +2,9 @@ using System.Text.Json.Serialization; using ArchiSteamFarm.Helpers.Json; using SteamKit2; -#pragma warning disable 649 + namespace BoosterCreator { - internal static class Steam { + internal class Steam { internal class EResultResponse { [JsonInclude] [JsonPropertyName("success")] @@ -34,20 +34,19 @@ internal sealed class BoosterInfo { [JsonInclude] [JsonPropertyName("price")] [JsonRequired] - internal uint Price { get; private init; } + internal string Price { get; private init; } [JsonInclude] [JsonPropertyName("unavailable")] - [JsonRequired] internal bool Unavailable { get; private init; } [JsonInclude] [JsonPropertyName("available_at_time")] - [JsonRequired] internal string AvailableAtTime { get; private init; } [JsonConstructor] private BoosterInfo() { + Price = ""; Name = ""; AvailableAtTime = ""; } @@ -58,12 +57,12 @@ internal sealed class BoostersResponse { [JsonInclude] [JsonPropertyName("goo_amount")] [JsonRequired] - internal uint GooAmount { get; private init; } + internal string? GooAmount { get; private init; } [JsonInclude] [JsonPropertyName("tradable_goo_amount")] [JsonRequired] - internal uint TradableGooAmount { get; private init; } + internal string? TradableGooAmount { get; private init; } [JsonInclude] [JsonPropertyName("untradable_goo_amount")]