mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-31 01:34:29 +00:00
Improve logging of api calls
This commit is contained in:
@@ -52,6 +52,9 @@ internal static class MobileAuthenticatorWebHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string endpoint = "AddAuthenticator";
|
||||||
|
HttpMethod method = HttpMethod.Post;
|
||||||
|
|
||||||
CTwoFactor_AddAuthenticator_Request request = new() {
|
CTwoFactor_AddAuthenticator_Request request = new() {
|
||||||
authenticator_time = Utilities.GetUnixTime(),
|
authenticator_time = Utilities.GetUnixTime(),
|
||||||
authenticator_type = 1,
|
authenticator_type = 1,
|
||||||
@@ -74,12 +77,16 @@ internal static class MobileAuthenticatorWebHandler {
|
|||||||
await Task.Delay(ArchiWebHandler.WebLimiterDelay).ConfigureAwait(false);
|
await Task.Delay(ArchiWebHandler.WebLimiterDelay).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Debugging.IsUserDebugging) {
|
||||||
|
bot.ArchiLogger.LogGenericDebug($"{method} {bot.SteamConfiguration.WebAPIBaseAddress}{TwoFactorService}/{endpoint}");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = await ArchiWebHandler.WebLimitRequest(
|
response = await ArchiWebHandler.WebLimitRequest(
|
||||||
WebAPI.DefaultBaseAddress,
|
bot.SteamConfiguration.WebAPIBaseAddress,
|
||||||
|
|
||||||
// ReSharper disable once AccessToDisposedClosure
|
// ReSharper disable once AccessToDisposedClosure
|
||||||
async () => await twoFactorService.CallProtobufAsync<CTwoFactor_AddAuthenticator_Response, CTwoFactor_AddAuthenticator_Request>(HttpMethod.Post, "AddAuthenticator", request, extraArgs: arguments).ConfigureAwait(false)
|
async () => await twoFactorService.CallProtobufAsync<CTwoFactor_AddAuthenticator_Response, CTwoFactor_AddAuthenticator_Request>(method, endpoint, request, extraArgs: arguments).ConfigureAwait(false)
|
||||||
).ConfigureAwait(false);
|
).ConfigureAwait(false);
|
||||||
} catch (TaskCanceledException e) {
|
} catch (TaskCanceledException e) {
|
||||||
bot.ArchiLogger.LogGenericDebuggingException(e);
|
bot.ArchiLogger.LogGenericDebuggingException(e);
|
||||||
@@ -113,6 +120,9 @@ internal static class MobileAuthenticatorWebHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string endpoint = "FinalizeAddAuthenticator";
|
||||||
|
HttpMethod method = HttpMethod.Post;
|
||||||
|
|
||||||
CTwoFactor_FinalizeAddAuthenticator_Request request = new() {
|
CTwoFactor_FinalizeAddAuthenticator_Request request = new() {
|
||||||
activation_code = activationCode,
|
activation_code = activationCode,
|
||||||
authenticator_code = authenticatorCode,
|
authenticator_code = authenticatorCode,
|
||||||
@@ -135,12 +145,16 @@ internal static class MobileAuthenticatorWebHandler {
|
|||||||
await Task.Delay(ArchiWebHandler.WebLimiterDelay).ConfigureAwait(false);
|
await Task.Delay(ArchiWebHandler.WebLimiterDelay).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Debugging.IsUserDebugging) {
|
||||||
|
bot.ArchiLogger.LogGenericDebug($"{method} {bot.SteamConfiguration.WebAPIBaseAddress}{TwoFactorService}/{endpoint}");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = await ArchiWebHandler.WebLimitRequest(
|
response = await ArchiWebHandler.WebLimitRequest(
|
||||||
WebAPI.DefaultBaseAddress,
|
bot.SteamConfiguration.WebAPIBaseAddress,
|
||||||
|
|
||||||
// ReSharper disable once AccessToDisposedClosure
|
// ReSharper disable once AccessToDisposedClosure
|
||||||
async () => await twoFactorService.CallProtobufAsync<CTwoFactor_FinalizeAddAuthenticator_Response, CTwoFactor_FinalizeAddAuthenticator_Request>(HttpMethod.Post, "FinalizeAddAuthenticator", request, extraArgs: arguments).ConfigureAwait(false)
|
async () => await twoFactorService.CallProtobufAsync<CTwoFactor_FinalizeAddAuthenticator_Response, CTwoFactor_FinalizeAddAuthenticator_Request>(method, endpoint, request, extraArgs: arguments).ConfigureAwait(false)
|
||||||
).ConfigureAwait(false);
|
).ConfigureAwait(false);
|
||||||
} catch (TaskCanceledException e) {
|
} catch (TaskCanceledException e) {
|
||||||
bot.ArchiLogger.LogGenericDebuggingException(e);
|
bot.ArchiLogger.LogGenericDebuggingException(e);
|
||||||
|
|||||||
@@ -491,9 +491,9 @@ public sealed class ArchiWebHandler : IDisposable {
|
|||||||
|
|
||||||
string queryString = string.Join('&', arguments.Select(static argument => $"{argument.Key}={HttpUtility.UrlEncode(argument.Value.ToString())}"));
|
string queryString = string.Join('&', arguments.Select(static argument => $"{argument.Key}={HttpUtility.UrlEncode(argument.Value.ToString())}"));
|
||||||
|
|
||||||
Uri request = new(WebAPI.DefaultBaseAddress, $"/{EconService}/GetTradeOffers/v1?{queryString}");
|
Uri request = new(Bot.SteamConfiguration.WebAPIBaseAddress, $"/{EconService}/GetTradeOffers/v1?{queryString}");
|
||||||
|
|
||||||
TradeOffersResponse? response = (await WebLimitRequest(WebAPI.DefaultBaseAddress, async () => await WebBrowser.UrlGetToJsonObject<APIWrappedResponse<TradeOffersResponse>>(request).ConfigureAwait(false)).ConfigureAwait(false))?.Content?.Response;
|
TradeOffersResponse? response = (await WebLimitRequest(Bot.SteamConfiguration.WebAPIBaseAddress, async () => await WebBrowser.UrlGetToJsonObject<APIWrappedResponse<TradeOffersResponse>>(request).ConfigureAwait(false)).ConfigureAwait(false))?.Content?.Response;
|
||||||
|
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries));
|
Bot.ArchiLogger.LogGenericWarning(Strings.FormatErrorRequestFailedTooManyTimes(WebBrowser.MaxTries));
|
||||||
@@ -1597,6 +1597,9 @@ public sealed class ArchiWebHandler : IDisposable {
|
|||||||
internal HttpClient GenerateDisposableHttpClient() => WebBrowser.GenerateDisposableHttpClient();
|
internal HttpClient GenerateDisposableHttpClient() => WebBrowser.GenerateDisposableHttpClient();
|
||||||
|
|
||||||
internal async Task<HashSet<uint>?> GetAppList() {
|
internal async Task<HashSet<uint>?> GetAppList() {
|
||||||
|
const string endpoint = "GetAppList";
|
||||||
|
HttpMethod method = HttpMethod.Get;
|
||||||
|
|
||||||
using WebAPI.AsyncInterface steamAppsService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(SteamAppsService);
|
using WebAPI.AsyncInterface steamAppsService = Bot.SteamConfiguration.GetAsyncWebAPIInterface(SteamAppsService);
|
||||||
|
|
||||||
steamAppsService.Timeout = WebBrowser.Timeout;
|
steamAppsService.Timeout = WebBrowser.Timeout;
|
||||||
@@ -1608,12 +1611,16 @@ public sealed class ArchiWebHandler : IDisposable {
|
|||||||
await Task.Delay(WebLimiterDelay).ConfigureAwait(false);
|
await Task.Delay(WebLimiterDelay).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Debugging.IsUserDebugging) {
|
||||||
|
Bot.ArchiLogger.LogGenericDebug($"{method} {Bot.SteamConfiguration.WebAPIBaseAddress}{SteamAppsService}/{endpoint}");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = await WebLimitRequest(
|
response = await WebLimitRequest(
|
||||||
WebAPI.DefaultBaseAddress,
|
Bot.SteamConfiguration.WebAPIBaseAddress,
|
||||||
|
|
||||||
// ReSharper disable once AccessToDisposedClosure
|
// ReSharper disable once AccessToDisposedClosure
|
||||||
async () => await steamAppsService.CallAsync(HttpMethod.Get, "GetAppList", 2).ConfigureAwait(false)
|
async () => await steamAppsService.CallAsync(method, endpoint, 2).ConfigureAwait(false)
|
||||||
).ConfigureAwait(false);
|
).ConfigureAwait(false);
|
||||||
} catch (TaskCanceledException e) {
|
} catch (TaskCanceledException e) {
|
||||||
Bot.ArchiLogger.LogGenericDebuggingException(e);
|
Bot.ArchiLogger.LogGenericDebuggingException(e);
|
||||||
@@ -1703,6 +1710,9 @@ public sealed class ArchiWebHandler : IDisposable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string endpoint = "GetTradeHoldDurations";
|
||||||
|
HttpMethod method = HttpMethod.Get;
|
||||||
|
|
||||||
Dictionary<string, object?> arguments = new(!string.IsNullOrEmpty(tradeToken) ? 3 : 2, StringComparer.Ordinal) {
|
Dictionary<string, object?> arguments = new(!string.IsNullOrEmpty(tradeToken) ? 3 : 2, StringComparer.Ordinal) {
|
||||||
{ "access_token", accessToken },
|
{ "access_token", accessToken },
|
||||||
{ "steamid_target", steamID }
|
{ "steamid_target", steamID }
|
||||||
@@ -1723,12 +1733,16 @@ public sealed class ArchiWebHandler : IDisposable {
|
|||||||
await Task.Delay(WebLimiterDelay).ConfigureAwait(false);
|
await Task.Delay(WebLimiterDelay).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Debugging.IsUserDebugging) {
|
||||||
|
Bot.ArchiLogger.LogGenericDebug($"{method} {Bot.SteamConfiguration.WebAPIBaseAddress}{EconService}/{endpoint}");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = await WebLimitRequest(
|
response = await WebLimitRequest(
|
||||||
WebAPI.DefaultBaseAddress,
|
Bot.SteamConfiguration.WebAPIBaseAddress,
|
||||||
|
|
||||||
// ReSharper disable once AccessToDisposedClosure
|
// ReSharper disable once AccessToDisposedClosure
|
||||||
async () => await econService.CallAsync(HttpMethod.Get, "GetTradeHoldDurations", args: arguments).ConfigureAwait(false)
|
async () => await econService.CallAsync(method, endpoint, args: arguments).ConfigureAwait(false)
|
||||||
).ConfigureAwait(false);
|
).ConfigureAwait(false);
|
||||||
} catch (TaskCanceledException e) {
|
} catch (TaskCanceledException e) {
|
||||||
Bot.ArchiLogger.LogGenericDebuggingException(e);
|
Bot.ArchiLogger.LogGenericDebuggingException(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user