diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 75548ef46..1b92a6336 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -87,7 +87,6 @@ namespace ArchiSteamFarm { private readonly SteamClient SteamClient; private readonly ConcurrentHashSet SteamFamilySharingIDs = new ConcurrentHashSet(); private readonly SteamFriends SteamFriends; - private readonly SteamSaleEvent SteamSaleEvent; private readonly SteamUser SteamUser; private readonly Trading Trading; @@ -120,6 +119,7 @@ namespace ArchiSteamFarm { private Timer PlayingWasBlockedTimer; private Timer SendItemsTimer; private bool SkipFirstShutdown; + private SteamSaleEvent SteamSaleEvent; private string TwoFactorCode; private byte TwoFactorCodeFailures; @@ -211,7 +211,6 @@ namespace ArchiSteamFarm { ArchiWebHandler = new ArchiWebHandler(this); CardsFarmer = new CardsFarmer(this); - SteamSaleEvent = new SteamSaleEvent(this); Trading = new Trading(this); if (!Debugging.IsDebugBuild && Program.GlobalConfig.Statistics) { @@ -231,11 +230,10 @@ namespace ArchiSteamFarm { public void Dispose() { // Those are objects that are always being created if constructor doesn't throw exception ArchiWebHandler.Dispose(); + CallbackSemaphore.Dispose(); CardsFarmer.Dispose(); HeartBeatTimer.Dispose(); - CallbackSemaphore.Dispose(); InitializationSemaphore.Dispose(); - SteamSaleEvent.Dispose(); Trading.Dispose(); // Those are objects that might be null and the check should be in-place @@ -243,6 +241,7 @@ namespace ArchiSteamFarm { FamilySharingInactivityTimer?.Dispose(); SendItemsTimer?.Dispose(); Statistics?.Dispose(); + SteamSaleEvent?.Dispose(); } internal async Task AcceptConfirmations(bool accept, Steam.ConfirmationDetails.EType acceptedType = Steam.ConfirmationDetails.EType.Unknown, ulong acceptedSteamID = 0, HashSet acceptedTradeIDs = null) { @@ -1112,21 +1111,26 @@ namespace ArchiSteamFarm { SendItemsTimer = null; } - if (BotConfig.SendTradePeriod == 0) { - return; + if (BotConfig.SendTradePeriod > 0) { + ulong steamMasterID = GetFirstSteamMasterID(); + if (steamMasterID != 0) { + SendItemsTimer = new Timer( + async e => await ResponseLoot(steamMasterID).ConfigureAwait(false), + null, + TimeSpan.FromHours(BotConfig.SendTradePeriod) + TimeSpan.FromSeconds(Program.LoadBalancingDelay * Bots.Count), // Delay + TimeSpan.FromHours(BotConfig.SendTradePeriod) // Period + ); + } } - ulong steamMasterID = GetFirstSteamMasterID(); - if (steamMasterID == 0) { - return; + if (SteamSaleEvent != null) { + SteamSaleEvent.Dispose(); + SteamSaleEvent = null; } - SendItemsTimer = new Timer( - async e => await ResponseLoot(steamMasterID).ConfigureAwait(false), - null, - TimeSpan.FromHours(BotConfig.SendTradePeriod) + TimeSpan.FromSeconds(Program.LoadBalancingDelay * Bots.Count), // Delay - TimeSpan.FromHours(BotConfig.SendTradePeriod) // Period - ); + if (BotConfig.AutoDiscoveryQueue) { + SteamSaleEvent = new SteamSaleEvent(this); + } } private void InitPermanentConnectionFailure() { @@ -1672,7 +1676,6 @@ namespace ArchiSteamFarm { if ((callback.CellID != 0) && (Program.GlobalDatabase.CellID != callback.CellID)) { Program.GlobalDatabase.CellID = callback.CellID; - SteamConfiguration.CellID = callback.CellID; } if (!HasMobileAuthenticator) { diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index 351312263..2dc3fbd2f 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -41,6 +41,11 @@ namespace ArchiSteamFarm { internal readonly bool AcceptGifts; #pragma warning restore 649 +#pragma warning disable 649 + [JsonProperty(Required = Required.DisallowNull)] + internal readonly bool AutoDiscoveryQueue; +#pragma warning restore 649 + [JsonProperty(Required = Required.DisallowNull)] internal readonly bool CardDropsRestricted = true; diff --git a/ArchiSteamFarm/config/example.json b/ArchiSteamFarm/config/example.json index 539f11332..960f75877 100644 --- a/ArchiSteamFarm/config/example.json +++ b/ArchiSteamFarm/config/example.json @@ -1,5 +1,6 @@ { "AcceptGifts": false, + "AutoDiscoveryQueue": false, "CardDropsRestricted": true, "CustomGamePlayedWhileFarming": null, "CustomGamePlayedWhileIdle": null,