Skip to content

Commit

Permalink
fix: Fix unique requests (follow/fav/vote) attempting to use unavaila…
Browse files Browse the repository at this point in the history
…ble accounts

The unfollow command (and others) overwrite allAccounts (the set being used in the end) with all accounts found in ratingHistory (for follow in this case). This caused the bot attempting to use an account that was in ratingHistory.db but not actually in the set of logged in accounts.
  • Loading branch information
3urobeat committed Feb 13, 2025
1 parent 4f60fbb commit 9e8d281
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/commands/helpers/getFavoriteBots.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 2023-06-02 14:07:27
* Author: 3urobeat
*
* Last Modified: 2025-01-12 18:26:47
* Last Modified: 2025-02-13 22:23:30
* Modified By: 3urobeat
*
* Copyright (c) 2023 - 2025 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -40,7 +40,7 @@ module.exports.getAvailableBotsForFavorizing = async (commandHandler, amount, id
// Remove bot accounts from allAccounts which have already favorized this id, or only allow them for type unfavorite
const previousLengthFavorized = allAccounts.length;
const alreadyUsedRes = await commandHandler.data.ratingHistoryDB.findAsync({ id: id, type: "favorite" }, {});
const alreadyUsed = alreadyUsedRes.map((e) => e.accountName); // Reduce db response to accountNames only
const alreadyUsed = alreadyUsedRes.map((e) => e.accountName).filter((e) => allAccounts.includes(e)); // Reduce db response to accountNames only but filter any !ONLINE accounts

if (favType == "favorite") {
allAccounts = allAccounts.filter((e) => !alreadyUsed.includes(e));
Expand Down
4 changes: 2 additions & 2 deletions src/commands/helpers/getFollowBots.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 2023-09-24 18:01:44
* Author: 3urobeat
*
* Last Modified: 2025-01-12 18:26:55
* Last Modified: 2025-02-13 22:23:41
* Modified By: 3urobeat
*
* Copyright (c) 2023 - 2025 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -52,7 +52,7 @@ module.exports.getAvailableBotsForFollowing = async (commandHandler, amount, can
// Remove bot accounts from allAccounts which have already followed this id, or only allow them for type unfollow
const previousLength = allAccounts.length;
const alreadyUsedRes = await commandHandler.data.ratingHistoryDB.findAsync({ id: id, type: idType + "Follow" }, {});
const alreadyUsed = alreadyUsedRes.map((e) => e.accountName); // Reduce db response to accountNames only
const alreadyUsed = alreadyUsedRes.map((e) => e.accountName).filter((e) => allAccounts.includes(e)); // Reduce db response to accountNames only but filter any !ONLINE accounts

if (favType == "follow") {
allAccounts = allAccounts.filter((e) => !alreadyUsed.includes(e));
Expand Down
4 changes: 2 additions & 2 deletions src/commands/helpers/getVoteBots.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 2023-05-28 12:21:02
* Author: 3urobeat
*
* Last Modified: 2025-01-12 18:27:12
* Last Modified: 2025-02-13 22:23:30
* Modified By: 3urobeat
*
* Copyright (c) 2023 - 2025 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -47,7 +47,7 @@ module.exports.getAvailableBotsForVoting = async (commandHandler, amount, id, vo
// Remove bot accounts from allAccounts which have already voted on this id with this voteType
const previousLengthVoted = allAccounts.length;
const alreadyUsedRes = await commandHandler.data.ratingHistoryDB.findAsync({ id: id, type: voteType }, {});
const alreadyUsed = alreadyUsedRes.map((e) => e.accountName); // Reduce db response to accountNames only
const alreadyUsed = alreadyUsedRes.map((e) => e.accountName).filter((e) => allAccounts.includes(e)); // Reduce db response to accountNames only but filter any !ONLINE accounts

allAccounts = allAccounts.filter((e) => !alreadyUsed.includes(e));

Expand Down
6 changes: 3 additions & 3 deletions src/data/fileStructure.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
{
"path": "src/commands/helpers/getFavoriteBots.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/helpers/getFavoriteBots.js",
"checksum": "315301f00872c3e9f4f9a8c511a79590"
"checksum": "0d61225a97ce56a7414fa020e102b827"
},
{
"path": "src/commands/helpers/getFollowArgs.js",
Expand All @@ -253,7 +253,7 @@
{
"path": "src/commands/helpers/getFollowBots.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/helpers/getFollowBots.js",
"checksum": "479e64a49bc48c0ff3e04e96a2706ed8"
"checksum": "d8dee77fab6f9d2b04b054aa6bef72b2"
},
{
"path": "src/commands/helpers/getMiscArgs.js",
Expand All @@ -263,7 +263,7 @@
{
"path": "src/commands/helpers/getVoteBots.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/helpers/getVoteBots.js",
"checksum": "13ed1a7d13d6a53edabe713f4713cc97"
"checksum": "c44450f5f4454d89c0dda7cb1b74381c"
},
{
"path": "src/commands/helpers/handleRequestErrors.js",
Expand Down

0 comments on commit 9e8d281

Please sign in to comment.