Skip to content

Commit

Permalink
Rename commentcooldown -> requestCooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
3urobeat committed Oct 19, 2023
1 parent fcd22f8 commit a24eed2
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"defaultLanguage": "english",
"requestDelay": 15000,
"skipSteamGuard": false,
"commentcooldown": 5,
"requestCooldown": 5,
"botaccountcooldown": 10,
"maxRequests": 0,
"maxOwnerRequests": 5,
Expand Down
2 changes: 1 addition & 1 deletion docs/wiki/config_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This is the full documentation to customize your `config.json`.
| \_help\_ | String | No functionality. Links directly to here to provide easily accessible explanations. |
| requestDelay | Number in ms | Adds a delay between each comment to prevent a cooldown from steam. Default: 7500
| skipSteamGuard | true or false | When true, the bot will skip all accounts that require a steamGuard to be typed in when logging in. Default: false |
| commentcooldown | Number in min | Applies this cooldown in minutes to every user after they requested comments. Set to 0 to disable. Default: 5
| requestCooldown | Number in min | Applies this cooldown in minutes to every user after they requested comments. Set to 0 to disable. Default: 5
| botaccountcooldown | Number in min | Applies this cooldown to every bot account used in a comment request to prevent getting a cooldown from steam. Set to 0 to disable. Default: 10 |
| maxRequests | Number | Defines how many comments a normal user can request from your bot. Will automatically use accounts multiple times if it is greater than the amount of accounts logged in. |
| maxOwnerRequests | Number | Defines how many comments owners can request (every user in the ownerid array). Will automatically use accounts multiple times if it is greater than the amount of accounts logged in. |
Expand Down
4 changes: 2 additions & 2 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: 15.10.2023 19:52:43
* Last Modified: 19.10.2023 19:00:06
* Modified By: 3urobeat
*
* Copyright (c) 2021 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -69,7 +69,7 @@ Bot.prototype._attachSteamFriendMessageEvent = function() {
if (!doc) { // Add user to database if he/she is missing for some reason
let lastcommentobj = {
id: new SteamID(String(steamID)).getSteamID64(),
time: Date.now() - (this.data.config.commentcooldown * 60000) // Subtract commentcooldown so that the user is able to use the command instantly
time: Date.now() - (this.data.config.requestCooldown * 60000) // Subtract requestCooldown so that the user is able to use the command instantly
};

this.controller.data.lastCommentDB.insert(lastcommentobj, (err) => { if (err) logger("error", "Error inserting new user into lastcomment.db database! Error: " + err); });
Expand Down
4 changes: 2 additions & 2 deletions src/bot/events/relationship.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: 10.09.2023 11:51:42
* Last Modified: 19.10.2023 19:00:06
* Modified By: 3urobeat
*
* Copyright (c) 2021 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -45,7 +45,7 @@ Bot.prototype._attachSteamFriendRelationshipEvent = function() {
// Add user to lastcomment database
let lastcommentobj = {
id: steamID64,
time: Date.now() - (this.controller.data.config.commentcooldown * 60000) // Subtract commentcooldown so that the user is able to use the command instantly
time: Date.now() - (this.controller.data.config.requestCooldown * 60000) // Subtract requestCooldown so that the user is able to use the command instantly
};

this.controller.data.lastCommentDB.remove({ id: steamID64 }, {}, (err) => { if (err) logger("error", "Error removing duplicate steamid from lastcomment.db on friendRelationship! Error: " + err); }); // Remove any old entries
Expand Down
4 changes: 2 additions & 2 deletions src/bot/events/webSession.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: 07.10.2023 12:25:47
* Last Modified: 19.10.2023 19:00:06
* Modified By: 3urobeat
*
* Copyright (c) 2021 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -74,7 +74,7 @@ Bot.prototype._attachSteamWebSessionEvent = function() {
// Add user to lastcomment database
let lastcommentobj = {
id: thisfriend,
time: Date.now() - (this.controller.data.config.commentcooldown * 60000) // Subtract commentcooldown so that the user is able to use the command instantly
time: Date.now() - (this.controller.data.config.requestCooldown * 60000) // Subtract requestCooldown so that the user is able to use the command instantly
};

this.controller.data.lastCommentDB.remove({ id: thisfriend }, {}, (err) => { if (err) logger("error", "Error removing duplicate steamid from lastcomment.db on offline friend accept! Error: " + err); }); // Remove any old entries
Expand Down
4 changes: 2 additions & 2 deletions src/commands/core/comment.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: 18.10.2023 23:06:09
* Last Modified: 19.10.2023 19:00:06
* Modified By: 3urobeat
*
* Copyright (c) 2021 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -277,7 +277,7 @@ async function comment(commandHandler, resInfo, respond, postComment, commentArg
}

// Give requesting user cooldown. Set timestamp to now if cooldown is disabled to avoid issues when a process is aborted but cooldown can't be cleared
if (commandHandler.data.config.commentcooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
if (commandHandler.data.config.requestCooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
else commandHandler.data.setUserCooldown(activeReqEntry.requestedby, activeReqEntry.until);
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/core/favorite.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 02.06.2023 13:23:01
* Author: 3urobeat
*
* Last Modified: 18.10.2023 23:10:49
* Last Modified: 19.10.2023 19:00:06
* Modified By: 3urobeat
*
* Copyright (c) 2023 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -142,7 +142,7 @@ module.exports.favorite = {
}

// Give requesting user cooldown. Set timestamp to now if cooldown is disabled to avoid issues when a process is aborted but cooldown can't be cleared
if (commandHandler.data.config.commentcooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
if (commandHandler.data.config.requestCooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
else commandHandler.data.setUserCooldown(activeReqEntry.requestedby, activeReqEntry.until);
}

Expand Down Expand Up @@ -332,7 +332,7 @@ module.exports.unfavorite = {
}

// Give requesting user cooldown. Set timestamp to now if cooldown is disabled to avoid issues when a process is aborted but cooldown can't be cleared
if (commandHandler.data.config.commentcooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
if (commandHandler.data.config.requestCooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
else commandHandler.data.setUserCooldown(activeReqEntry.requestedby, activeReqEntry.until);
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/core/follow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 24.09.2023 15:04:33
* Author: 3urobeat
*
* Last Modified: 18.10.2023 23:11:06
* Last Modified: 19.10.2023 19:00:06
* Modified By: 3urobeat
*
* Copyright (c) 2023 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -135,7 +135,7 @@ module.exports.follow = {
}

// Give requesting user cooldown. Set timestamp to now if cooldown is disabled to avoid issues when a process is aborted but cooldown can't be cleared
if (commandHandler.data.config.commentcooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
if (commandHandler.data.config.requestCooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
else commandHandler.data.setUserCooldown(activeReqEntry.requestedby, activeReqEntry.until);
}

Expand Down Expand Up @@ -319,7 +319,7 @@ module.exports.unfollow = {
}

// Give requesting user cooldown. Set timestamp to now if cooldown is disabled to avoid issues when a process is aborted but cooldown can't be cleared
if (commandHandler.data.config.commentcooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
if (commandHandler.data.config.requestCooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
else commandHandler.data.setUserCooldown(activeReqEntry.requestedby, activeReqEntry.until);
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/core/requests.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: 07.10.2023 23:34:56
* Last Modified: 19.10.2023 19:00:06
* Modified By: 3urobeat
*
* Copyright (c) 2021 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -125,9 +125,9 @@ module.exports.resetCooldown = {
if (err) return respond((await commandHandler.data.getLang("invalidprofileid", null, requesterID)) + "\n\nError: " + err);
if (res) userID = res; // Change steamID64 to the provided id

if (commandHandler.data.config.commentcooldown == 0) return respond(await commandHandler.data.getLang("resetcooldowncmdcooldowndisabled", null, requesterID)); // Is the cooldown enabled?
if (commandHandler.data.config.requestCooldown == 0) return respond(await commandHandler.data.getLang("resetcooldowncmdcooldowndisabled", null, requesterID)); // Is the cooldown enabled?

commandHandler.data.lastCommentDB.update({ id: userID }, { $set: { time: Date.now() - (commandHandler.data.config.commentcooldown * 60000) } }, async (err) => {
commandHandler.data.lastCommentDB.update({ id: userID }, { $set: { time: Date.now() - (commandHandler.data.config.requestCooldown * 60000) } }, async (err) => {
if (err) return respond("Error updating database entry: " + err);
else respond(await commandHandler.data.getLang("resetcooldowncmdsuccess", { "profileid": userID.toString() }, requesterID));
});
Expand Down
6 changes: 3 additions & 3 deletions src/commands/core/vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 28.05.2023 12:02:24
* Author: 3urobeat
*
* Last Modified: 18.10.2023 23:11:23
* Last Modified: 19.10.2023 19:00:06
* Modified By: 3urobeat
*
* Copyright (c) 2023 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -142,7 +142,7 @@ module.exports.upvote = {
}

// Give requesting user cooldown. Set timestamp to now if cooldown is disabled to avoid issues when a process is aborted but cooldown can't be cleared
if (commandHandler.data.config.commentcooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
if (commandHandler.data.config.requestCooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
else commandHandler.data.setUserCooldown(activeReqEntry.requestedby, activeReqEntry.until);
}

Expand Down Expand Up @@ -337,7 +337,7 @@ module.exports.downvote = {
}

// Give requesting user cooldown. Set timestamp to now if cooldown is disabled to avoid issues when a process is aborted but cooldown can't be cleared
if (commandHandler.data.config.commentcooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
if (commandHandler.data.config.requestCooldown == 0) commandHandler.data.setUserCooldown(activeReqEntry.requestedby, Date.now());
else commandHandler.data.setUserCooldown(activeReqEntry.requestedby, activeReqEntry.until);
}

Expand Down
4 changes: 2 additions & 2 deletions src/controller/helpers/friendlist.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: 29.09.2023 17:13:11
* Last Modified: 19.10.2023 19:00:06
* Modified By: 3urobeat
*
* Copyright (c) 2021 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -36,7 +36,7 @@ Controller.prototype.checkLastcommentDB = function(bot) {

let obj = {
id: e,
time: Date.now() - (this.data.config.commentcooldown * 60000) // Subtract commentcooldown so that the user is able to use the command instantly
time: Date.now() - (this.data.config.requestCooldown * 60000) // Subtract requestCooldown so that the user is able to use the command instantly
};

this.data.lastCommentDB.insert(obj, (err) => {
Expand Down
22 changes: 11 additions & 11 deletions src/data/fileStructure.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
{
"path": "docs/wiki/config_doc.md",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/docs/wiki/config_doc.md",
"checksum": "521c76407297ab89d341dbfe66925c5e"
"checksum": "3663cc9af21201dbedc6c538c2e60945"
},
{
"path": "docs/wiki/contributing.md",
Expand Down Expand Up @@ -328,7 +328,7 @@
{
"path": "src/bot/events/friendMessage.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/bot/events/friendMessage.js",
"checksum": "275022cd3e65b2d6463f3c58b1387564"
"checksum": "808e9f56ee7246b9fc146551ff5b099a"
},
{
"path": "src/bot/events/loggedOn.js",
Expand All @@ -338,12 +338,12 @@
{
"path": "src/bot/events/relationship.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/bot/events/relationship.js",
"checksum": "54f47fc608f7dc15e8ad06fbd5967fbb"
"checksum": "c59e096971df409c17b07cf25c2ed167"
},
{
"path": "src/bot/events/webSession.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/bot/events/webSession.js",
"checksum": "9a4caafdde3fbc7ea5102d06b64ae2d8"
"checksum": "9f0bab858334349bd8fae8c7dac4a873"
},
{
"path": "src/bot/helpers/checkMsgBlock.js",
Expand Down Expand Up @@ -383,17 +383,17 @@
{
"path": "src/commands/core/comment.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/core/comment.js",
"checksum": "85a7614876e7fac7f1b5a0fbef8741f3"
"checksum": "17a0106bd432bd48bb3fe4b31f0b45d1"
},
{
"path": "src/commands/core/favorite.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/core/favorite.js",
"checksum": "ae056754af4021a9f2289086fa80b50d"
"checksum": "c04d5a5108404fe2c553ef1ebf9615bf"
},
{
"path": "src/commands/core/follow.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/core/follow.js",
"checksum": "32a1874d42574d38a28e90b2a84fbb25"
"checksum": "fc00572ec05fce0040ee0eb518e8fa1d"
},
{
"path": "src/commands/core/friend.js",
Expand All @@ -413,7 +413,7 @@
{
"path": "src/commands/core/requests.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/core/requests.js",
"checksum": "aa524705271741066cc89ce0b74912b1"
"checksum": "18c4250b933248e4f720d7b26e290194"
},
{
"path": "src/commands/core/settings.js",
Expand All @@ -428,7 +428,7 @@
{
"path": "src/commands/core/vote.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/core/vote.js",
"checksum": "15920a7e90ef8851c98fc10b309ed8ff"
"checksum": "c5f08b08c385d58c36040c3c94c7bdd8"
},
{
"path": "src/commands/helpers/getCommentArgs.js",
Expand Down Expand Up @@ -503,7 +503,7 @@
{
"path": "src/controller/helpers/friendlist.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/controller/helpers/friendlist.js",
"checksum": "ca070f444b4aff9942e912a6117d2953"
"checksum": "115150407cf054d506eef7831e89022b"
},
{
"path": "src/controller/helpers/getBots.js",
Expand Down Expand Up @@ -603,7 +603,7 @@
{
"path": "src/dataManager/helpers/handleCooldowns.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/dataManager/helpers/handleCooldowns.js",
"checksum": "2ce3303785620a6f9072cfda9af45a34"
"checksum": "078a375e1fd1ee91c76a4d76de34d16c"
},
{
"path": "src/dataManager/helpers/handleExpiringTokens.js",
Expand Down
6 changes: 3 additions & 3 deletions src/dataManager/helpers/handleCooldowns.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 13.04.2023 17:58:23
* Author: 3urobeat
*
* Last Modified: 10.07.2023 12:47:30
* Last Modified: 19.10.2023 19:00:06
* Modified By: 3urobeat
*
* Copyright (c) 2023 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -58,7 +58,7 @@ DataManager.prototype.getUserCooldown = function(id) {
lastReq = Number(Math.round(lastReq+"e"+2)+"e-"+2); // Limit lastReq value to two decimals

// Format untilStr
let until = Math.abs(((Date.now() - doc.time) / 1000) - (this.config.commentcooldown * 60));
let until = Math.abs(((Date.now() - doc.time) / 1000) - (this.config.requestCooldown * 60));
let untilUnit = "seconds";

if (until > 60) {
Expand All @@ -76,7 +76,7 @@ DataManager.prototype.getUserCooldown = function(id) {
until = Number(Math.round(until+"e"+2)+"e-"+2); // Limit until value to two decimals

obj.lastRequest = doc.time;
obj.until = doc.time + (this.config.commentcooldown * 60000);
obj.until = doc.time + (this.config.requestCooldown * 60000);
obj.lastRequestStr = `${lastReq} ${lastReqUnit}`;
obj.untilStr = `${until} ${untilUnit}`;

Expand Down

0 comments on commit a24eed2

Please sign in to comment.