From 3903ef0dfb9e5d82076b5ca5676ec112eab09bb6 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Thu, 6 May 2021 18:07:01 +0200 Subject: [PATCH] Misc --- ArchiSteamFarm.sln.DotSettings | 10 +++--- ArchiSteamFarm/ArchiWebHandler.cs | 54 +++++++++++++++---------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/ArchiSteamFarm.sln.DotSettings b/ArchiSteamFarm.sln.DotSettings index af6b0ecfa..0b40dbd04 100644 --- a/ArchiSteamFarm.sln.DotSettings +++ b/ArchiSteamFarm.sln.DotSettings @@ -7,7 +7,7 @@ True True ExplicitlyExcluded - CF84911C-2C4C-4195-8AF3-ABBB6D3DE9AA/d:www + SOLUTION True SUGGESTION @@ -178,7 +178,7 @@ SUGGESTION SUGGESTION SUGGESTION - HINT + WARNING WARNING WARNING WARNING @@ -205,6 +205,8 @@ SUGGESTION SUGGESTION SUGGESTION + HINT + HINT SUGGESTION SUGGESTION SUGGESTION @@ -222,13 +224,13 @@ WARNING WARNING WARNING - DO_NOT_SHOW + WARNING WARNING SUGGESTION SUGGESTION SUGGESTION WARNING - DO_NOT_SHOW + HINT SUGGESTION SUGGESTION WARNING diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index 5c1ba55cd..2ae2a2d60 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -55,14 +55,14 @@ namespace ArchiSteamFarm { internal const ushort MaxItemsInSingleInventoryRequest = 5000; - private const string IEconService = "IEconService"; - private const string IPlayerService = "IPlayerService"; - private const string ISteamApps = "ISteamApps"; - private const string ISteamUserAuth = "ISteamUserAuth"; - private const string ITwoFactorService = "ITwoFactorService"; + private const string EconService = "IEconService"; + private const string PlayerService = "IPlayerService"; + private const string SteamAppsService = "ISteamApps"; private const string SteamCommunityHost = "steamcommunity.com"; private const string SteamHelpHost = "help.steampowered.com"; private const string SteamStoreHost = "store.steampowered.com"; + private const string SteamUserAuthService = "ISteamUserAuth"; + private const string TwoFactorService = "ITwoFactorService"; private static readonly ConcurrentDictionary CachedCardCountsForGame = new(); @@ -303,16 +303,16 @@ namespace ArchiSteamFarm { KeyValue? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { - using WebAPI.AsyncInterface iPlayerService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(IPlayerService); + using WebAPI.AsyncInterface playerService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(PlayerService); - iPlayerService.Timeout = WebBrowser.Timeout; + playerService.Timeout = WebBrowser.Timeout; try { response = await WebLimitRequest( WebAPI.DefaultBaseAddress.Host, // ReSharper disable once AccessToDisposedClosure - async () => await iPlayerService.CallAsync( + async () => await playerService.CallAsync( HttpMethod.Get, "GetOwnedGames", args: new Dictionary(4, StringComparer.Ordinal) { { "include_appinfo", 1 }, { "key", steamApiKey! }, @@ -1432,16 +1432,16 @@ namespace ArchiSteamFarm { KeyValue? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { - using WebAPI.AsyncInterface iEconService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(IEconService); + using WebAPI.AsyncInterface econService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(EconService); - iEconService.Timeout = WebBrowser.Timeout; + econService.Timeout = WebBrowser.Timeout; try { response = await WebLimitRequest( WebAPI.DefaultBaseAddress.Host, // ReSharper disable once AccessToDisposedClosure - async () => await iEconService.CallAsync( + async () => await econService.CallAsync( HttpMethod.Post, "DeclineTradeOffer", args: new Dictionary(2, StringComparer.Ordinal) { { "key", steamApiKey! }, { "tradeofferid", tradeID } @@ -1487,16 +1487,16 @@ namespace ArchiSteamFarm { KeyValue? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { - using WebAPI.AsyncInterface iEconService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(IEconService); + using WebAPI.AsyncInterface econService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(EconService); - iEconService.Timeout = WebBrowser.Timeout; + econService.Timeout = WebBrowser.Timeout; try { response = await WebLimitRequest( WebAPI.DefaultBaseAddress.Host, // ReSharper disable once AccessToDisposedClosure - async () => await iEconService.CallAsync( + async () => await econService.CallAsync( HttpMethod.Get, "GetTradeOffers", args: new Dictionary(5, StringComparer.Ordinal) { { "active_only", 1 }, { "get_descriptions", 1 }, @@ -1649,16 +1649,16 @@ namespace ArchiSteamFarm { KeyValue? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { - using WebAPI.AsyncInterface iSteamApps = Bot.SteamConfiguration.GetAsyncWebAPIInterface(ISteamApps); + using WebAPI.AsyncInterface steamAppsService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(SteamAppsService); - iSteamApps.Timeout = WebBrowser.Timeout; + steamAppsService.Timeout = WebBrowser.Timeout; try { response = await WebLimitRequest( WebAPI.DefaultBaseAddress.Host, // ReSharper disable once AccessToDisposedClosure - async () => await iSteamApps.CallAsync(HttpMethod.Get, "GetAppList", 2).ConfigureAwait(false) + async () => await steamAppsService.CallAsync(HttpMethod.Get, "GetAppList", 2).ConfigureAwait(false) ).ConfigureAwait(false); } catch (TaskCanceledException e) { Bot.ArchiLogger.LogGenericDebuggingException(e); @@ -1877,16 +1877,16 @@ namespace ArchiSteamFarm { KeyValue? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { - using WebAPI.AsyncInterface iTwoFactorService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(ITwoFactorService); + using WebAPI.AsyncInterface twoFactorService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(TwoFactorService); - iTwoFactorService.Timeout = WebBrowser.Timeout; + twoFactorService.Timeout = WebBrowser.Timeout; try { response = await WebLimitRequest( WebAPI.DefaultBaseAddress.Host, // ReSharper disable once AccessToDisposedClosure - async () => await iTwoFactorService.CallAsync(HttpMethod.Post, "QueryTime").ConfigureAwait(false) + async () => await twoFactorService.CallAsync(HttpMethod.Post, "QueryTime").ConfigureAwait(false) ).ConfigureAwait(false); } catch (TaskCanceledException e) { Bot.ArchiLogger.LogGenericDebuggingException(e); @@ -1990,16 +1990,16 @@ namespace ArchiSteamFarm { KeyValue? response = null; for (byte i = 0; (i < WebBrowser.MaxTries) && (response == null); i++) { - using WebAPI.AsyncInterface iEconService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(IEconService); + using WebAPI.AsyncInterface econService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(EconService); - iEconService.Timeout = WebBrowser.Timeout; + econService.Timeout = WebBrowser.Timeout; try { response = await WebLimitRequest( WebAPI.DefaultBaseAddress.Host, // ReSharper disable once AccessToDisposedClosure - async () => await iEconService.CallAsync(HttpMethod.Get, "GetTradeHoldDurations", args: arguments).ConfigureAwait(false) + async () => await econService.CallAsync(HttpMethod.Get, "GetTradeHoldDurations", args: arguments).ConfigureAwait(false) ).ConfigureAwait(false); } catch (TaskCanceledException e) { Bot.ArchiLogger.LogGenericDebuggingException(e); @@ -2159,22 +2159,22 @@ namespace ArchiSteamFarm { byte[] encryptedLoginKey = CryptoHelper.SymmetricEncrypt(loginKey, sessionKey); // We're now ready to send the data to Steam API - Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.LoggingIn, ISteamUserAuth)); + Bot.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.LoggingIn, SteamUserAuthService)); KeyValue? response; // We do not use usual retry pattern here as webAPIUserNonce is valid only for a single request // Even during timeout, webAPIUserNonce is most likely already invalid // Instead, the caller is supposed to ask for new webAPIUserNonce and call Init() again on failure - using (WebAPI.AsyncInterface iSteamUserAuth = Bot.SteamConfiguration.GetAsyncWebAPIInterface(ISteamUserAuth)) { - iSteamUserAuth.Timeout = WebBrowser.Timeout; + using (WebAPI.AsyncInterface steamUserAuthService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(SteamUserAuthService)) { + steamUserAuthService.Timeout = WebBrowser.Timeout; try { response = await WebLimitRequest( WebAPI.DefaultBaseAddress.Host, // ReSharper disable once AccessToDisposedClosure - async () => await iSteamUserAuth.CallAsync( + async () => await steamUserAuthService.CallAsync( HttpMethod.Post, "AuthenticateUser", args: new Dictionary(3, StringComparer.Ordinal) { { "encrypted_loginkey", encryptedLoginKey }, { "sessionkey", encryptedSessionKey },