diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Localization/Strings.Designer.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Localization/Strings.Designer.cs index 63042578e..d22ca609d 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Localization/Strings.Designer.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Localization/Strings.Designer.cs @@ -68,5 +68,11 @@ namespace ArchiSteamFarm.OfficialPlugins.ItemsMatcher.Localization { return ResourceManager.GetString("TradeOfferFailed", resourceCulture); } } + + internal static string ActivelyMatchingSomeConfirmationsFailed { + get { + return ResourceManager.GetString("ActivelyMatchingSomeConfirmationsFailed", resourceCulture); + } + } } } diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Localization/Strings.resx b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Localization/Strings.resx index 0949149bf..50f62b98e 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Localization/Strings.resx +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Localization/Strings.resx @@ -78,4 +78,8 @@ Failed to send a trade offer to bot {0} ({1}), moving on... {0} will be replaced by steam ID (number), {1} will be replaced by user's nickname' + + Some confirmations have failed, approximately {0} out of {1} trades were sent successfully. + {0} will be replaced by amount of the trade offers that succeeded (number), {1} will be replaced by amount of the trade offers that were supposed to be sent in total (number) + diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs index a00d8cc12..4fa4dd4e1 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs @@ -659,9 +659,16 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { byte maxTradeHoldDuration = ASF.GlobalConfig?.MaxTradeHoldDuration ?? GlobalConfig.DefaultMaxTradeHoldDuration; + byte failuresInRow = 0; uint matchedSets = 0; foreach (ListedUser listedUser in listedUsers.Where(listedUser => (listedUser.SteamID != Bot.SteamID) && acceptedMatchableTypes.Any(listedUser.MatchableTypes.Contains) && !Bot.IsBlacklistedFromTrades(listedUser.SteamID)).OrderByDescending(static listedUser => listedUser.MatchEverything).ThenBy(static listedUser => listedUser.TotalInventoryCount)) { + if (failuresInRow >= WebBrowser.MaxTries) { + Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(failuresInRow)} >= {WebBrowser.MaxTries}")); + + break; + } + HashSet<(uint RealAppID, Asset.EType Type, Asset.ERarity Rarity)> wantedSets = ourTradableState.Keys.Where(set => listedUser.MatchableTypes.Contains(set.Type)).ToHashSet(); if (wantedSets.Count == 0) { @@ -841,11 +848,15 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { if (!success) { // The user likely no longer has the items we need, this is fine, we can continue the matching with other ones + failuresInRow++; + Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Localization.Strings.TradeOfferFailed, listedUser.SteamID, listedUser.Nickname)); break; } + failuresInRow = 0; + Bot.ArchiLogger.LogGenericInfo(Strings.Success); // Assume the trade offer has went through and was accepted, this will allow us to keep matching the same set with different users as if we've got what we wanted @@ -921,10 +932,10 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { } if (pendingMobileTradeOfferIDs.Count > 0) { - (bool twoFactorSuccess, _, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false); + (bool twoFactorSuccess, IReadOnlyCollection? handledConfirmations, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false); if (!twoFactorSuccess) { - Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(twoFactorSuccess))); + Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Localization.Strings.ActivelyMatchingSomeConfirmationsFailed, handledConfirmations?.Count ?? 0, pendingMobileTradeOfferIDs.Count)); return; }