mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Update from ASFB
This commit is contained in:
@@ -37,6 +37,9 @@ internal static partial class GeneratedRegexes {
|
||||
[GeneratedRegex(@"\d+", DefaultOptions)]
|
||||
internal static partial Regex Digits();
|
||||
|
||||
[GeneratedRegex(@"EResult (?<EResult>\d+)$", DefaultOptions)]
|
||||
internal static partial Regex InventoryEResult();
|
||||
|
||||
[GeneratedRegex(@"[^\u0000-\u007F]+", DefaultOptions)]
|
||||
internal static partial Regex NonAscii();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using ArchiSteamFarm.Core;
|
||||
using ArchiSteamFarm.Localization;
|
||||
using JetBrains.Annotations;
|
||||
@@ -75,30 +76,38 @@ public static class SteamUtilities {
|
||||
return EResult.Timeout;
|
||||
}
|
||||
|
||||
if (errorText.StartsWith("batched request timeout", StringComparison.Ordinal)) {
|
||||
if (errorText.StartsWith("batched request timeout", StringComparison.Ordinal) || errorText.StartsWith("Failed to send", StringComparison.Ordinal)) {
|
||||
return EResult.RemoteCallFailed;
|
||||
}
|
||||
|
||||
int startIndex = errorText.LastIndexOf('(');
|
||||
string errorCodeText;
|
||||
|
||||
if (startIndex < 0) {
|
||||
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(errorText), errorText));
|
||||
Match match = GeneratedRegexes.InventoryEResult().Match(errorText);
|
||||
|
||||
return null;
|
||||
if (match.Success && match.Groups.TryGetValue("EResult", out Group? groupResult)) {
|
||||
errorCodeText = groupResult.Value;
|
||||
} else {
|
||||
int startIndex = errorText.LastIndexOf('(');
|
||||
|
||||
if (startIndex < 0) {
|
||||
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(errorText), errorText));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
startIndex++;
|
||||
|
||||
int endIndex = errorText.IndexOf(')', startIndex + 1);
|
||||
|
||||
if (endIndex < 0) {
|
||||
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(errorText), errorText));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
errorCodeText = errorText[startIndex..endIndex];
|
||||
}
|
||||
|
||||
startIndex++;
|
||||
|
||||
int endIndex = errorText.IndexOf(')', startIndex + 1);
|
||||
|
||||
if (endIndex < 0) {
|
||||
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(errorText), errorText));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
string errorCodeText = errorText[startIndex..endIndex];
|
||||
|
||||
if (!byte.TryParse(errorCodeText, out byte errorCode)) {
|
||||
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(errorText), errorText));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user