Skip to content

Commit

Permalink
feat(Controller): Emit ready event on second login rerun even if POST…
Browse files Browse the repository at this point in the history
…PONED accounts still exist
  • Loading branch information
3urobeat committed May 4, 2024
1 parent 77c9f8e commit 863b87c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/controller/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 2021-07-09 16:26:00
* Author: 3urobeat
*
* Last Modified: 2024-05-04 21:53:58
* Last Modified: 2024-05-04 22:46:20
* Modified By: 3urobeat
*
* Copyright (c) 2021 - 2024 3urobeat <https://github.com/3urobeat>
Expand All @@ -23,6 +23,8 @@ const ascii = require("../data/ascii.js");
const misc = require("./helpers/misc.js");


let postponedRetries = 0; // Tracks the amount of reruns caused by accounts with POSTPONED status

/**
* Attempts to log in all bot accounts which are currently offline one after another.
* Creates a new bot object for every new account and reuses existing one if possible
Expand Down Expand Up @@ -137,8 +139,12 @@ Controller.prototype.login = async function(firstLogin) {
this.info.activeLogin = false;

// Emit ready event if this is the first start and no login is pending
if (this.info.readyAfter == 0 && !Object.values(this.bots).some((e) => e.status == Bot.EStatus.POSTPONED)) {
this._readyEvent();
if (this.info.readyAfter == 0) {
if (!Object.values(this.bots).some((e) => e.status == Bot.EStatus.POSTPONED) || postponedRetries > 0) { // Emit ready event either way if we are already on a rerun to make the bot usable
this._readyEvent();
}

postponedRetries++;
}

// Call itself again to process any POSTPONED or newly qualified accounts - this has to happen after the ready check above as login() sets every POSTPONED account to OFFLINE
Expand Down
2 changes: 1 addition & 1 deletion src/data/fileStructure.json
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@
{
"path": "src/controller/login.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/controller/login.js",
"checksum": "ca44fdc848b159d90a0c4dfba43037ae"
"checksum": "5c2004ff7748ccb64d90f1ae61d93f5a"
},
{
"path": "src/data/ascii.js",
Expand Down

0 comments on commit 863b87c

Please sign in to comment.