From d398e84f25f0a232d4ec8338ae8c3b7b9ed2926e Mon Sep 17 00:00:00 2001 From: Archi Date: Mon, 1 Jan 2024 23:00:58 +0100 Subject: [PATCH] Misc --- .../Commands.cs | 2 +- .../RemoteCommunication.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Commands.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Commands.cs index 07e2a0910..26c0929ce 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Commands.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Commands.cs @@ -96,7 +96,7 @@ internal static class Commands { return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(remoteCommunication))); } - remoteCommunication.TriggerMatchActively(); + remoteCommunication.TriggerMatchActivelyEarlier(); return bot.Commands.FormatBotResponse(Strings.Done); } diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs index cfde0cd96..3b7e8a389 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs @@ -771,7 +771,16 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { } } - internal void TriggerMatchActively() => Utilities.InBackground(() => MatchActively()); + internal void TriggerMatchActivelyEarlier() { + if (MatchActivelyTimer == null) { + Utilities.InBackground(() => MatchActively()); + } else { + // ReSharper disable once SuspiciousLockOverSynchronizationPrimitive - this is not a mistake, we need extra synchronization, and we can re-use the semaphore object for that + lock (MatchActivelySemaphore) { + MatchActivelyTimer.Change(TimeSpan.Zero, TimeSpan.FromHours(6)); + } + } + } private async Task IsEligibleForListing() { // Bot must be eligible for matching