Update from ASFB

This commit is contained in:
Łukasz Domeradzki
2024-03-28 12:29:18 +01:00
parent 2a2f9c27a4
commit 154655c35c
2 changed files with 29 additions and 17 deletions

View File

@@ -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();
}

View File

@@ -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));