mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Add logic for inventory rate-limiting
This commit is contained in:
@@ -156,6 +156,34 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task<(bool Success, T Result)> UrlGetToJsonResultWithSuccessRetry<T>(string request, string referer = null) {
|
||||
if (string.IsNullOrEmpty(request)) {
|
||||
ArchiLogger.LogNullError(nameof(request));
|
||||
return default;
|
||||
}
|
||||
|
||||
string json = await UrlGetToContentRetry(request, referer).ConfigureAwait(false);
|
||||
if (string.IsNullOrEmpty(json)) {
|
||||
return default;
|
||||
}
|
||||
|
||||
T result;
|
||||
|
||||
try {
|
||||
result = JsonConvert.DeserializeObject<T>(json);
|
||||
} catch (JsonException e) {
|
||||
ArchiLogger.LogGenericException(e);
|
||||
|
||||
if (Debugging.IsUserDebugging) {
|
||||
ArchiLogger.LogGenericDebug(string.Format(Strings.Content, json));
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
return (true, result);
|
||||
}
|
||||
|
||||
internal async Task<XmlDocument> UrlGetToXMLRetry(string request, string referer = null) {
|
||||
if (string.IsNullOrEmpty(request)) {
|
||||
ArchiLogger.LogNullError(nameof(request));
|
||||
|
||||
Reference in New Issue
Block a user