diff --git a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs index 32c8445e72342..f952697774483 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs @@ -308,6 +308,14 @@ public async IAsyncEnumerable GetInventoryAsync(ulong steamID = 0, uint a return null; } + // Extra entry for format + Dictionary arguments = new(5, StringComparer.Ordinal) { + { "include_appinfo", 1 }, + { "key", steamApiKey! }, + { "skip_unvetted_apps", "0" }, + { "steamid", steamID } + }; + KeyValue? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { @@ -319,15 +327,9 @@ public async IAsyncEnumerable GetInventoryAsync(ulong steamID = 0, uint a response = await WebLimitRequest( WebAPI.DefaultBaseAddress, + // TODO: Remove this ToDictionary() call after https://github.com/SteamRE/SteamKit/pull/992 is released // ReSharper disable once AccessToDisposedClosure - async () => await playerService.CallAsync( - HttpMethod.Get, "GetOwnedGames", args: new Dictionary(4, StringComparer.Ordinal) { - { "include_appinfo", 1 }, - { "key", steamApiKey! }, - { "skip_unvetted_apps", "0" }, - { "steamid", steamID } - } - ).ConfigureAwait(false) + async () => await playerService.CallAsync(HttpMethod.Get, "GetOwnedGames", args: arguments.ToDictionary(kv => kv.Key, kv => kv.Value)).ConfigureAwait(false) ).ConfigureAwait(false); } catch (TaskCanceledException e) { Bot.ArchiLogger.LogGenericDebuggingException(e); @@ -1423,6 +1425,12 @@ internal async Task DeclineTradeOffer(ulong tradeID) { return false; } + // Extra entry for format + Dictionary arguments = new(3, StringComparer.Ordinal) { + { "key", steamApiKey! }, + { "tradeofferid", tradeID } + }; + KeyValue? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { @@ -1434,13 +1442,9 @@ internal async Task DeclineTradeOffer(ulong tradeID) { response = await WebLimitRequest( WebAPI.DefaultBaseAddress, + // TODO: Remove this ToDictionary() call after https://github.com/SteamRE/SteamKit/pull/992 is released // ReSharper disable once AccessToDisposedClosure - async () => await econService.CallAsync( - HttpMethod.Post, "DeclineTradeOffer", args: new Dictionary(2, StringComparer.Ordinal) { - { "key", steamApiKey! }, - { "tradeofferid", tradeID } - } - ).ConfigureAwait(false) + async () => await econService.CallAsync(HttpMethod.Post, "DeclineTradeOffer", args: arguments.ToDictionary(kv => kv.Key, kv => kv.Value)).ConfigureAwait(false) ).ConfigureAwait(false); } catch (TaskCanceledException e) { Bot.ArchiLogger.LogGenericDebuggingException(e); @@ -1478,6 +1482,15 @@ internal async Task DeclineTradeOffer(ulong tradeID) { return null; } + // Extra entry for format + Dictionary arguments = new(6, StringComparer.Ordinal) { + { "active_only", 1 }, + { "get_descriptions", 1 }, + { "get_received_offers", 1 }, + { "key", steamApiKey! }, + { "time_historical_cutoff", uint.MaxValue } + }; + KeyValue? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { @@ -1489,16 +1502,9 @@ internal async Task DeclineTradeOffer(ulong tradeID) { response = await WebLimitRequest( WebAPI.DefaultBaseAddress, + // TODO: Remove this ToDictionary() call after https://github.com/SteamRE/SteamKit/pull/992 is released // ReSharper disable once AccessToDisposedClosure - async () => await econService.CallAsync( - HttpMethod.Get, "GetTradeOffers", args: new Dictionary(5, StringComparer.Ordinal) { - { "active_only", 1 }, - { "get_descriptions", 1 }, - { "get_received_offers", 1 }, - { "key", steamApiKey! }, - { "time_historical_cutoff", uint.MaxValue } - } - ).ConfigureAwait(false) + async () => await econService.CallAsync(HttpMethod.Get, "GetTradeOffers", args: arguments).ConfigureAwait(false) ).ConfigureAwait(false); } catch (TaskCanceledException e) { Bot.ArchiLogger.LogGenericDebuggingException(e); @@ -1964,7 +1970,8 @@ internal async Task GetServerTime() { return null; } - Dictionary arguments = new(!string.IsNullOrEmpty(tradeToken) ? 3 : 2, StringComparer.Ordinal) { + // Extra entry for format + Dictionary arguments = new(!string.IsNullOrEmpty(tradeToken) ? 4 : 3, StringComparer.Ordinal) { { "key", steamApiKey! }, { "steamid_target", steamID } }; @@ -1984,8 +1991,9 @@ internal async Task GetServerTime() { response = await WebLimitRequest( WebAPI.DefaultBaseAddress, + // TODO: Remove this ToDictionary() call after https://github.com/SteamRE/SteamKit/pull/992 is released // ReSharper disable once AccessToDisposedClosure - async () => await econService.CallAsync(HttpMethod.Get, "GetTradeHoldDurations", args: arguments).ConfigureAwait(false) + async () => await econService.CallAsync(HttpMethod.Get, "GetTradeHoldDurations", args: arguments.ToDictionary(kv => kv.Key, kv => kv.Value)).ConfigureAwait(false) ).ConfigureAwait(false); } catch (TaskCanceledException e) { Bot.ArchiLogger.LogGenericDebuggingException(e); @@ -2144,6 +2152,13 @@ internal async Task Init(ulong steamID, EUniverse universe, string webAPIU // AES encrypt our login key with our session key byte[] encryptedLoginKey = CryptoHelper.SymmetricEncrypt(loginKey, sessionKey); + // Extra entry for format + Dictionary arguments = new(4, StringComparer.Ordinal) { + { "encrypted_loginkey", encryptedLoginKey }, + { "sessionkey", encryptedSessionKey }, + { "steamid", steamID } + }; + // We're now ready to send the data to Steam API Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.LoggingIn, SteamUserAuthService)); @@ -2160,13 +2175,7 @@ internal async Task Init(ulong steamID, EUniverse universe, string webAPIU WebAPI.DefaultBaseAddress, // ReSharper disable once AccessToDisposedClosure - async () => await steamUserAuthService.CallAsync( - HttpMethod.Post, "AuthenticateUser", args: new Dictionary(3, StringComparer.Ordinal) { - { "encrypted_loginkey", encryptedLoginKey }, - { "sessionkey", encryptedSessionKey }, - { "steamid", steamID } - } - ).ConfigureAwait(false) + async () => await steamUserAuthService.CallAsync(HttpMethod.Post, "AuthenticateUser", args: arguments).ConfigureAwait(false) ).ConfigureAwait(false); } catch (TaskCanceledException e) { Bot.ArchiLogger.LogGenericDebuggingException(e);