Skip to content

Commit

Permalink
Version 2.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
3urobeat authored Nov 8, 2022
2 parents d9ab995 + ca52150 commit b641fd7
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 59 deletions.
1 change: 1 addition & 0 deletions advancedconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"_help_": "Read the docs: https://github.com/HerrEurobeat/steam-comment-service-bot/wiki/Advanced-Config-Documentation",
"disableAutoUpdate": false,
"loginDelay": 2500,
"loginTimeout": 60000,
"relogTimeout": 30000,
"maxLogOnRetries": 1,
"useLocalIP": true,
Expand Down
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "steam-comment-service-bot",
"version": "2.12.1",
"version": "2.12.2",
"description": "Request a ton of steam profile/group comments from a bot network with just one command!",
"main": "start.js",
"dependencies": {
Expand All @@ -11,9 +11,9 @@
"https": "^1.0.0",
"output-logger": "^2.2.3",
"request": "^2.88.2",
"steam-session": "^0.0.2-alpha",
"steam-session": "^0.0.3-alpha",
"steam-user": "^4.25.0",
"steamcommunity": "^3.44.2",
"steamcommunity": "^3.44.3",
"steamid": "^2.0.0",
"steamid-resolver": "^1.2.2"
},
Expand Down
26 changes: 22 additions & 4 deletions src/bot/events/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 09.07.2021 16:26:00
* Author: 3urobeat
*
* Last Modified: 16.10.2022 13:21:57
* Last Modified: 06.11.2022 16:16:42
* Modified By: 3urobeat
*
* Copyright (c) 2021 3urobeat <https://github.com/HerrEurobeat>
Expand Down Expand Up @@ -38,9 +38,20 @@ module.exports.run = (err, loginindex, thisbot, thisproxy, logOnOptions, bot) =>
logger("", "", true);
logger("warn", `${logger.colors.fgred}[${thisbot}] Lost connection to Steam! Reason: LogonSessionReplaced. I won't try to relog this account because someone else is using it now.`, false, false, null, true); // Force print this message now

// Abort or skip account
if (loginindex == 0) {
logger("error", `${logger.colors.fgred} Failed account is bot0! Aborting...`, true);
return process.send("stop()");
} else {
controller.skippedaccounts.push(loginindex);
login.skippednow.push(loginindex);

// Remove account from relogQueue if included so that the next account can try to relog itself
if (controller.relogQueue.includes(loginindex)) controller.relogQueue.splice(controller.relogQueue.indexOf(loginindex), 1);

// Remove account from botobject & communityobject so that it won't be used for anything anymore
if (controller.botobject[String(loginindex)]) delete controller.botobject[String(loginindex)];
if (controller.communityobject[String(loginindex)]) delete controller.communityobject[String(loginindex)];
}
return;
}
Expand All @@ -65,8 +76,8 @@ module.exports.run = (err, loginindex, thisbot, thisproxy, logOnOptions, bot) =>

let blockedEnumsForRetries = [EResult.Banned, EResult.AccountNotFound]; // No need to block InvalidPassword anymore as the sessionHandler handles credentials

// check if this is an initial login error and it is either a fatal error or all retries are used
if ((login.additionalaccinfo[loginindex].logOnTries > advancedconfig.maxLogOnRetries && !controller.relogQueue.includes(loginindex)) || blockedEnumsForRetries.includes(err.eresult)) {
// Check if all logOnTries are used or if this is a fatal error
if (login.additionalaccinfo[loginindex].logOnTries > advancedconfig.maxLogOnRetries || blockedEnumsForRetries.includes(err.eresult)) {
logger("", "", true);
logger("error", `Couldn't log in bot${loginindex} after ${login.additionalaccinfo[loginindex].logOnTries} attempt(s). ${err} (${err.eresult})`, true);

Expand All @@ -86,6 +97,13 @@ module.exports.run = (err, loginindex, thisbot, thisproxy, logOnOptions, bot) =>

controller.skippedaccounts.push(loginindex);
login.skippednow.push(loginindex);

// Remove account from relogQueue if included so that the next account can try to relog itself
if (controller.relogQueue.includes(loginindex)) controller.relogQueue.splice(controller.relogQueue.indexOf(loginindex), 1);

// Remove account from botobject & communityobject so that it won't be used for anything anymore
if (controller.botobject[String(loginindex)]) delete controller.botobject[String(loginindex)];
if (controller.communityobject[String(loginindex)]) delete controller.communityobject[String(loginindex)];
}

} else { // Got retries left or it is a relog...
Expand All @@ -104,7 +122,7 @@ module.exports.run = (err, loginindex, thisbot, thisproxy, logOnOptions, bot) =>

// Call either relogAccount or logOnAccount function to continue where we started at after 5 sec
setTimeout(() => {
if (controller.relogQueue.includes(loginindex)) require("../helpers/relogAccount.js").run(loginindex, thisbot, logOnOptions, bot, thisproxy);
if (controller.relogQueue.includes(loginindex)) require("../helpers/relogAccount.js").run(loginindex, thisbot, logOnOptions, bot, thisproxy, true); // Force relog with last param
else botfile.logOnAccount();
}, 5000);
}
Expand Down
20 changes: 16 additions & 4 deletions src/bot/events/friendMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 09.07.2021 16:26:00
* Author: 3urobeat
*
* Last Modified: 16.10.2022 12:25:23
* Last Modified: 08.11.2022 11:33:32
* Modified By: 3urobeat
*
* Copyright (c) 2021 3urobeat <https://github.com/HerrEurobeat>
Expand Down Expand Up @@ -59,12 +59,22 @@ module.exports.run = (loginindex, thisbot, bot, community, steamID, message) =>
txt += "...";
}

logger("debug", `[${thisbot}] Sending message (${txt.length} chars) to ${new SteamID(String(steamID)).getSteamID64()} (retry: ${retry == true}): "${txt.replace(/\n/g, "\\n")}"`); // Intentionally checking for == true to prevent showing undefined
// Log full message if in debug mode, otherwise log cut down version
let recipientSteamID64 = new SteamID(String(steamID)).getSteamID64();

if (advancedconfig.printDebug) {
logger("debug", `[${thisbot}] Sending message (${txt.length} chars) to ${recipientSteamID64} (retry: ${retry == true}): "${txt.replace(/\n/g, "\\n")}"`); // Intentionally checking for == true to prevent showing undefined
} else {
if (txt.length >= 75) logger("info", `[${thisbot}] Sending message to ${recipientSteamID64}: "${txt.slice(0, 75).replace(/\n/g, "\\n") + "..."}"`);
else logger("info", `[${thisbot}] Sending message to ${recipientSteamID64}: "${txt.replace(/\n/g, "\\n")}"`);
}

bot.chat.sendFriendMessage(steamID, txt, {}, (err) => {
if (err) { // Check for error as some chat messages seem to not get send lately
logger("warn", `[${thisbot}] Error trying to send chat message of length ${txt.length} to ${new SteamID(String(steamID)).getSteamID64()}! ${err}`);
if (!retry) chatmsg(steamID, "Sorry, it looks like Steam blocked my last message. Please try again later.", true); // Send the user a fallback message just to indicate the bot is not down
logger("warn", `[${thisbot}] Error trying to send chat message of length ${txt.length} to ${recipientSteamID64}! ${err}`);

// Send the user a fallback message after 5 seconds just to indicate the bot is not down
if (!retry) setTimeout(() => chatmsg(steamID, "Sorry, it looks like Steam blocked my last message. Please try again later.", true), 5000);
}
});
}
Expand Down Expand Up @@ -309,6 +319,7 @@ module.exports.run = (loginindex, thisbot, bot, community, steamID, message) =>

default: // Cmd not recognized
if (message.startsWith("!")) chatmsg(steamID, lang.commandnotfound);
else logger("debug", "Chat message is not a command, ignoring message.");
}
} else {
switch(message.toLowerCase()) {
Expand All @@ -317,6 +328,7 @@ module.exports.run = (loginindex, thisbot, bot, community, steamID, message) =>
break;
default:
if (message.startsWith("!")) chatmsg(steamID, `${lang.childbotmessage}\nhttps://steamcommunity.com/profiles/${new SteamID(String(controller.botobject[0].steamID)).getSteamID64()}`);
else logger("debug", "Chat message is not a command, ignoring message.");
}
}
};
4 changes: 2 additions & 2 deletions src/bot/helpers/checkAvailability.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 28.02.2022 11:06:57
* Author: 3urobeat
*
* Last Modified: 16.10.2022 13:30:22
* Last Modified: 06.11.2022 13:53:55
* Modified By: 3urobeat
*
* Copyright (c) 2022 3urobeat <https://github.com/HerrEurobeat>
Expand Down Expand Up @@ -83,7 +83,7 @@ module.exports.checkAvailability = (receiverSteamID, numberOfComments, removeLim
var whenavailable; // We will save the until value of the activecommentprocess entry that the user has to wait for here
var allAccounts = [ ... Object.keys(controller.communityobject) ]; // Clone keys array of communityobject

// loop over activecommentprocess obj and remove all valid entries from allAccounts array if object is not empty
// Loop over activecommentprocess obj and remove all valid entries from allAccounts array to remove all accounts that are currently being used in another request
if (Object.keys(mainfile.activecommentprocess).length > 0) {
Object.keys(mainfile.activecommentprocess).forEach((e) => {

Expand Down
94 changes: 94 additions & 0 deletions src/bot/helpers/handleLoginTimeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* File: handleLoginTimeout.js
* Project: steam-comment-service-bot
* Created Date: 03.11.2022 12:27:46
* Author: 3urobeat
*
* Last Modified: 07.11.2022 11:07:07
* Modified By: 3urobeat
*
* Copyright (c) 2022 3urobeat <https://github.com/HerrEurobeat>
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/


const controller = require("../../controller/controller.js");
const login = require("../../controller/login.js");


/**
* Handles force progressing the relog queue should an account get stuck while trying to log in to prevent the bot from softlocking (see issue #139)
* @param {Number} loginindex The loginindex of the calling account
* @param {String} thisbot The thisbot string of the calling account
* @param {Object} logOnOptions The steam-user logOnOptions object
* @param {SteamUser} bot The bot instance of the calling account
* @param {String} thisproxy The proxy of the calling account
*/
module.exports.handleLoginTimeout = (loginindex, thisbot, logOnOptions, bot, thisproxy) => {
// Ignore if login timeout handler is disabled in advancedconfig
if (advancedconfig.loginTimeout == 0) {
logger("debug", `handleLoginTimeout(): Ignoring timeout attach request for bot${loginindex} because loginTimeout is disabled in advancedconfig!`);
return;
}

let currentLogOnTry = login.additionalaccinfo[loginindex].logOnTries;

logger("debug", `handleLoginTimeout(): Attached ${advancedconfig.loginTimeout / 1000} seconds timeout for bot${loginindex}...`);

// Check if account is still in relogQueue with the same logOnTries value 60 seconds later and force progress
setTimeout(() => {

// Ignore timeout if account progressed since then
let newLogOnTry = login.additionalaccinfo[loginindex].logOnTries;
let accInQueue = controller.relogQueue.includes(loginindex);

if (currentLogOnTry != newLogOnTry || !accInQueue) {
logger("debug", `[${thisbot}] handleLoginTimeout(): Timeout for bot${loginindex} done, acc not stuck. old/new logOnTries: ${currentLogOnTry}/${newLogOnTry} - acc in relogQueue: ${accInQueue}`);
return;
}

// Check if all logOnRetries are used up and skip account
if (login.additionalaccinfo[loginindex].logOnTries > advancedconfig.maxLogOnRetries) {
logger("", "", true);
logger("error", `Couldn't log in bot${loginindex} after ${login.additionalaccinfo[loginindex].logOnTries} attempt(s). Error: Login attempt timed out and all available logOnRetries were used.`, true);

// Add additional messages for specific errors to hopefully help the user diagnose the cause
if (thisproxy != null) logger("", ` Is your proxy ${login.proxyShift - 1} offline or maybe blocked by Steam?`, true);

// Abort execution if account is bot0
if (loginindex == 0) {
logger("", "", true);
logger("error", "Aborting because the first bot account always needs to be logged in!\nPlease wait a moment and start the bot again.", true);
return process.send("stop()");

} else { // Skip account if not bot0

logger("info", "Failed account is not bot0. Skipping account...", true);

controller.skippedaccounts.push(loginindex);
login.skippednow.push(loginindex);

// Remove account from relogQueue if included so that the next account can try to relog itself
if (controller.relogQueue.includes(loginindex)) controller.relogQueue.splice(controller.relogQueue.indexOf(loginindex), 1);

// Remove account from botobject & communityobject so that it won't be used for anything anymore
if (controller.botobject[String(loginindex)]) delete controller.botobject[String(loginindex)];
if (controller.communityobject[String(loginindex)]) delete controller.communityobject[String(loginindex)];
}

} else {

// Force progress if account is stuck
logger("warn", `Detected timed out login attempt for bot${loginindex}! Force progressing relog queue to avoid soft-locking the bot...`);

bot.logOff(); // Call logOff() just to be sure

require("../helpers/relogAccount.js").run(loginindex, thisbot, logOnOptions, bot, thisproxy, true); // Force relog with last param
}

}, advancedconfig.loginTimeout);

};
Loading

0 comments on commit b641fd7

Please sign in to comment.