diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index e18651d32..20d1e3288 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -44,6 +44,7 @@ namespace ArchiSteamFarm { private static readonly uint LoginID = MsgClientLogon.ObfuscationMask; // This must be the same for all ASF bots and all ASF processes private readonly string SentryFile; + private readonly Timer AcceptConfirmationsTimer; private readonly Timer SendItemsTimer; internal readonly string BotName; @@ -230,6 +231,15 @@ namespace ArchiSteamFarm { CardsFarmer = new CardsFarmer(this); Trading = new Trading(this); + if (BotConfig.AcceptConfirmationsPeriod > 0 && AcceptConfirmationsTimer == null) { + AcceptConfirmationsTimer = new Timer( + async e => await AcceptAllConfirmations().ConfigureAwait(false), + null, + TimeSpan.FromHours(BotConfig.AcceptConfirmationsPeriod), // Delay + TimeSpan.FromHours(BotConfig.AcceptConfirmationsPeriod) // Period + ); + } + if (BotConfig.SendTradePeriod > 0 && SendItemsTimer == null) { SendItemsTimer = new Timer( async e => await ResponseSendTrade().ConfigureAwait(false), @@ -535,29 +545,7 @@ namespace ArchiSteamFarm { return "That bot doesn't have ASF 2FA enabled!"; } - if (!await BotDatabase.SteamGuardAccount.RefreshSessionAsync().ConfigureAwait(false)) { - return "Could not refresh steam session!"; - } - - Confirmation[] confirmations = await BotDatabase.SteamGuardAccount.FetchConfirmationsAsync().ConfigureAwait(false); - if (confirmations == null) { - return "No confirmations to confirm!"; - } - - try { - foreach (Confirmation confirmation in confirmations) { - if (BotDatabase.SteamGuardAccount.AcceptConfirmation(confirmation)) { - Logging.LogGenericInfo("Accepting confirmation: Success!", BotName); - } else { - Logging.LogGenericWarning("Accepting confirmation: Failed!", BotName); - } - } - } catch (SteamGuardAccount.WGTokenInvalidException) { - Logging.LogGenericWarning("Accepting confirmation: Failed!", BotName); - Logging.LogGenericWarning("Confirmation could not be accepted because of invalid token exception", BotName); - Logging.LogGenericWarning("If issue persists, consider removing and readding ASF 2FA", BotName); - } - + await AcceptAllConfirmations().ConfigureAwait(false); return "Done!"; } diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index eb5bd36cb..81c7d4dad 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -87,6 +87,9 @@ namespace ArchiSteamFarm { [JsonProperty(Required = Required.DisallowNull)] internal byte SendTradePeriod { get; private set; } = 0; + [JsonProperty(Required = Required.DisallowNull)] + internal byte AcceptConfirmationsPeriod { get; private set; } = 0; + [JsonProperty] internal string CustomGamePlayedWhileIdle { get; private set; } = null;