Improve cooldown when ASF detects recent playing

This commit is contained in:
JustArchi
2019-04-12 13:43:48 +02:00
parent b43981a160
commit 04bf32e372
4 changed files with 34 additions and 8 deletions

View File

@@ -1460,14 +1460,17 @@ namespace ArchiSteamFarm {
StopPlayingWasBlockedTimer();
if (!IsPlayingPossible) {
ArchiLogger.LogGenericInfo(Strings.BotAccountOccupied);
PlayingWasBlocked = true;
ArchiLogger.LogGenericInfo(Strings.BotAccountOccupied);
return;
}
if (PlayingWasBlocked && (PlayingWasBlockedTimer == null)) {
InitPlayingWasBlockedTimer();
}
ArchiLogger.LogGenericInfo(Strings.BotAccountFree);
PlayingWasBlocked = false;
if (!await CardsFarmer.Resume(false).ConfigureAwait(false)) {
await ResetGamesPlayed().ConfigureAwait(false);
@@ -1797,6 +1800,19 @@ namespace ArchiSteamFarm {
await RegisterBot(BotName).ConfigureAwait(false);
}
private void InitPlayingWasBlockedTimer() {
if (PlayingWasBlockedTimer != null) {
return;
}
PlayingWasBlockedTimer = new Timer(
e => ResetPlayingWasBlockedWithTimer(),
null,
TimeSpan.FromSeconds(MinPlayingBlockedTTL), // Delay
Timeout.InfiniteTimeSpan // Period
);
}
private void InitStart() {
if (!BotConfig.Enabled) {
ArchiLogger.LogGenericInfo(Strings.BotInstanceNotStartingBecauseDisabled);
@@ -2353,12 +2369,7 @@ namespace ArchiSteamFarm {
PlayingBlocked = false;
if (PlayingWasBlocked && (PlayingWasBlockedTimer == null)) {
PlayingWasBlockedTimer = new Timer(
e => ResetPlayingWasBlockedWithTimer(),
null,
TimeSpan.FromSeconds(MinPlayingBlockedTTL), // Delay
Timeout.InfiniteTimeSpan // Period
);
InitPlayingWasBlockedTimer();
}
if (IsAccountLimited) {