Skip to content

Commit

Permalink
fix(Bot): Fix switchProxy not switching to proxy 0
Browse files Browse the repository at this point in the history
  • Loading branch information
3urobeat committed May 2, 2024
1 parent fdd0f14 commit c8a8cb4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/bot/bot.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-03-01 17:59:47
* Last Modified: 2024-05-02 10:51:07
* Modified By: 3urobeat
*
* Copyright (c) 2021 - 2024 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -286,7 +286,7 @@ Bot.prototype.handleLoginTimeout = function() {};
Bot.prototype.handleMissingGameLicenses = function() {};

/**
* Changes the proxy of this bot account and relogs it.
* Changes the proxy of this bot account.
* @param {number} newProxyIndex Index of the new proxy inside the DataManager.proxies array.
*/
Bot.prototype.switchProxy = function(newProxyIndex) {}; // eslint-disable-line
Expand Down
8 changes: 4 additions & 4 deletions src/bot/helpers/handleRelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 2023-10-05 16:14:46
* Author: 3urobeat
*
* Last Modified: 2024-03-08 11:48:23
* Last Modified: 2024-05-02 10:54:36
* Modified By: 3urobeat
*
* Copyright (c) 2023 - 2024 3urobeat <https://github.com/3urobeat>
Expand All @@ -22,12 +22,12 @@ const Bot = require("../bot");


/**
* Changes the proxy of this bot account and relogs it.
* Changes the proxy of this bot account.
* @param {number} newProxyIndex Index of the new proxy inside the DataManager.proxies array.
*/
Bot.prototype.switchProxy = function(newProxyIndex) {

if (!newProxyIndex) return new Error("newProxyIndex is undefined");
if (newProxyIndex == undefined) return new Error("newProxyIndex is undefined"); // Explicitly check for undefined to prevent the value 0 from triggering this check

logger("info", `[${this.logPrefix}] Switching proxy from ${this.loginData.proxyIndex} to ${newProxyIndex}. The bot account will relog in a moment...`);

Expand Down Expand Up @@ -101,7 +101,7 @@ Bot.prototype.checkAndSwitchMyProxy = async function() {
// Find proxy with least amount of associated bots
let leastUsedProxy = activeProxies.reduce((a, b) => a.bots.length < b.bots.length ? a : b);

logger("warn", `[${this.logPrefix}] Failed to ping Steam using proxy ${this.loginData.proxyIndex}! Switched to proxy ${leastUsedProxy.proxyIndex} which currently has the least amount of usage and appears to be online.`);
logger("warn", `[${this.logPrefix}] Failed to ping Steam using proxy ${this.loginData.proxyIndex}! Switching to proxy ${leastUsedProxy.proxyIndex} which currently has the least amount of usage and appears to be online.`);


// Switch proxy and relog, no need for handleRelog() to do something
Expand Down
4 changes: 2 additions & 2 deletions src/data/fileStructure.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
{
"path": "src/bot/bot.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/bot/bot.js",
"checksum": "bf91bc9deef102f02ff63522143f72f7"
"checksum": "fecb280b21cb7469ea5ff56827ce60de"
},
{
"path": "src/bot/events/debug.js",
Expand Down Expand Up @@ -373,7 +373,7 @@
{
"path": "src/bot/helpers/handleRelog.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/bot/helpers/handleRelog.js",
"checksum": "3808cfde6f188582a539628ef4f5eb76"
"checksum": "e9197cd02697f19733c7e199ca783eeb"
},
{
"path": "src/bot/helpers/steamChatInteraction.js",
Expand Down

0 comments on commit c8a8cb4

Please sign in to comment.