mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-21 16:58:37 +00:00
Report warning on listing/matching
If user intentionally enabled STM or MatchActively, we should display him warning if that's not possible due to not meeting the requirements.
This commit is contained in:
@@ -147,14 +147,14 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
|
|||||||
internal void OnNewItemsNotification() => ShouldSendAnnouncementEarlier = true;
|
internal void OnNewItemsNotification() => ShouldSendAnnouncementEarlier = true;
|
||||||
|
|
||||||
internal async Task OnPersonaState(string? nickname = null, string? avatarHash = null) {
|
internal async Task OnPersonaState(string? nickname = null, string? avatarHash = null) {
|
||||||
if (!Bot.BotConfig.RemoteCommunication.HasFlag(BotConfig.ERemoteCommunication.PublicListing)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WebBrowser == null) {
|
if (WebBrowser == null) {
|
||||||
throw new InvalidOperationException(nameof(WebBrowser));
|
throw new InvalidOperationException(nameof(WebBrowser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Bot.BotConfig.RemoteCommunication.HasFlag(BotConfig.ERemoteCommunication.PublicListing) || !Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.SteamTradeMatcher)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((DateTime.UtcNow < LastAnnouncement.AddMinutes(ShouldSendAnnouncementEarlier ? MinAnnouncementTTL : MaxAnnouncementTTL)) && ShouldSendHeartBeats) {
|
if ((DateTime.UtcNow < LastAnnouncement.AddMinutes(ShouldSendAnnouncementEarlier ? MinAnnouncementTTL : MaxAnnouncementTTL)) && ShouldSendHeartBeats) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -173,6 +173,8 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
|
|||||||
// This is actually network failure, so we'll stop sending heartbeats but not record it as valid check
|
// This is actually network failure, so we'll stop sending heartbeats but not record it as valid check
|
||||||
ShouldSendHeartBeats = false;
|
ShouldSendHeartBeats = false;
|
||||||
|
|
||||||
|
Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(IsEligibleForListing)}: {eligible?.ToString() ?? "null"}"));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +183,8 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
|
|||||||
LastAnnouncement = DateTime.UtcNow;
|
LastAnnouncement = DateTime.UtcNow;
|
||||||
ShouldSendAnnouncementEarlier = ShouldSendHeartBeats = false;
|
ShouldSendAnnouncementEarlier = ShouldSendHeartBeats = false;
|
||||||
|
|
||||||
|
Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(IsEligibleForListing)}: {eligible.Value}"));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,21 +400,14 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool?> IsEligibleForListing() {
|
private async Task<bool?> IsEligibleForListing() {
|
||||||
// Bot must be eligible for matching first
|
// Bot must be eligible for matching
|
||||||
bool? isEligibleForMatching = await IsEligibleForMatching().ConfigureAwait(false);
|
bool? isEligibleForMatching = await IsEligibleForMatching().ConfigureAwait(false);
|
||||||
|
|
||||||
if (isEligibleForMatching != true) {
|
if (isEligibleForMatching != true) {
|
||||||
return isEligibleForMatching;
|
return isEligibleForMatching;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bot must have STM enabled in TradingPreferences
|
// Bot must have a public inventory
|
||||||
if (!Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.SteamTradeMatcher)) {
|
|
||||||
Bot.ArchiLogger.LogGenericTrace(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(Bot.BotConfig.TradingPreferences)}: {Bot.BotConfig.TradingPreferences}"));
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bot must have public inventory
|
|
||||||
bool? hasPublicInventory = await Bot.HasPublicInventory().ConfigureAwait(false);
|
bool? hasPublicInventory = await Bot.HasPublicInventory().ConfigureAwait(false);
|
||||||
|
|
||||||
if (hasPublicInventory != true) {
|
if (hasPublicInventory != true) {
|
||||||
@@ -462,12 +459,20 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
|
|||||||
throw new InvalidOperationException(nameof(ASF.GlobalConfig.LicenseID));
|
throw new InvalidOperationException(nameof(ASF.GlobalConfig.LicenseID));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Bot.IsConnectedAndLoggedOn || Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchEverything) || !Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchActively) || (await IsEligibleForMatching().ConfigureAwait(false) != true)) {
|
if (!Bot.IsConnectedAndLoggedOn || Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchEverything) || !Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.MatchActively)) {
|
||||||
Bot.ArchiLogger.LogGenericTrace(Strings.ErrorAborted);
|
Bot.ArchiLogger.LogGenericTrace(Strings.ErrorAborted);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool? eligible = await IsEligibleForMatching().ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (eligible != true) {
|
||||||
|
Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, $"{nameof(IsEligibleForMatching)}: {eligible?.ToString() ?? "null"}"));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
HashSet<Asset.EType> acceptedMatchableTypes = Bot.BotConfig.MatchableTypes.Where(AcceptedMatchableTypes.Contains).ToHashSet();
|
HashSet<Asset.EType> acceptedMatchableTypes = Bot.BotConfig.MatchableTypes.Where(AcceptedMatchableTypes.Contains).ToHashSet();
|
||||||
|
|
||||||
if (acceptedMatchableTypes.Count == 0) {
|
if (acceptedMatchableTypes.Count == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user