Skip to content

Commit

Permalink
feat: Count all request types during runtime and accumulate them in i…
Browse files Browse the repository at this point in the history
…nfo cmd
  • Loading branch information
3urobeat committed Feb 12, 2025
1 parent 29f2fe1 commit d4d811e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 26 deletions.
14 changes: 8 additions & 6 deletions src/commands/core/favorite.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Created Date: 2023-06-02 13:23:01
* Author: 3urobeat
*
* Last Modified: 2024-10-10 18:19:35
* Last Modified: 2025-02-12 21:57:31
* Modified By: 3urobeat
*
* Copyright (c) 2023 - 2024 3urobeat <https://github.com/3urobeat>
* Copyright (c) 2023 - 2025 3urobeat <https://github.com/3urobeat>
*
* 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.
Expand Down Expand Up @@ -207,14 +207,15 @@ module.exports.favorite = {
failedcmdreference = `\nTo get detailed information why which request failed please type '${resInfo.cmdprefix}failed'. You can read why your error was probably caused here: https://github.com/3urobeat/steam-comment-service-bot/blob/master/docs/wiki/errors_doc.md`;
}

// Send finished message
// Send finished message and set status of this request to cooldown
respond(`${await commandHandler.data.getLang("favoritesuccess", { "failedamount": Object.keys(activeReqEntry.failed).length, "numberOfFavs": activeReqEntry.amount }, requesterID)}\n${failedcmdreference}`);

// Set status of this request to cooldown and add amount of successful comments to our global commentCounter
activeReqEntry.status = "cooldown";

}

commandHandler.controller.info.favCounter += activeReqEntry.amount - Object.keys(activeReqEntry.failed).length;

});
});
}
Expand Down Expand Up @@ -405,14 +406,15 @@ module.exports.unfavorite = {
failedcmdreference = `\nTo get detailed information why which request failed please type '${resInfo.cmdprefix}failed'. You can read why your error was probably caused here: https://github.com/3urobeat/steam-comment-service-bot/blob/master/docs/wiki/errors_doc.md`;
}

// Send finished message
// Send finished message and set status of this request to cooldown
respond(`${await commandHandler.data.getLang("favoritesuccess", { "failedamount": Object.keys(activeReqEntry.failed).length, "numberOfFavs": activeReqEntry.amount }, requesterID)}\n${failedcmdreference}`);

// Set status of this request to cooldown and add amount of successful comments to our global commentCounter
activeReqEntry.status = "cooldown";

}

commandHandler.controller.info.favCounter += activeReqEntry.amount - Object.keys(activeReqEntry.failed).length;

});
});
}
Expand Down
12 changes: 7 additions & 5 deletions src/commands/core/follow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 2023-09-24 15:04:33
* Author: 3urobeat
*
* Last Modified: 2025-01-06 19:48:16
* Last Modified: 2025-02-12 21:57:20
* Modified By: 3urobeat
*
* Copyright (c) 2023 - 2025 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -240,14 +240,15 @@ module.exports.follow = {
failedcmdreference = `\nTo get detailed information why which request failed please type '${resInfo.cmdprefix}failed'. You can read why your error was probably caused here: https://github.com/3urobeat/steam-comment-service-bot/blob/master/docs/wiki/errors_doc.md`;
}

// Send finished message
// Send finished message and set status of this request to cooldown
respond(`${await commandHandler.data.getLang("followsuccess", { "failedamount": Object.keys(activeReqEntry.failed).length, "totalamount": activeReqEntry.amount }, requesterID)}\n${failedcmdreference}`);

// Set status of this request to cooldown and add amount of successful comments to our global commentCounter
activeReqEntry.status = "cooldown";

}

commandHandler.controller.info.followCounter += activeReqEntry.amount - Object.keys(activeReqEntry.failed).length;

});
}
};
Expand Down Expand Up @@ -470,14 +471,15 @@ module.exports.unfollow = {
failedcmdreference = `\nTo get detailed information why which request failed please type '${resInfo.cmdprefix}failed'. You can read why your error was probably caused here: https://github.com/3urobeat/steam-comment-service-bot/blob/master/docs/wiki/errors_doc.md`;
}

// Send finished message
// Send finished message and set status of this request to cooldown
respond(`${await commandHandler.data.getLang("followsuccess", { "failedamount": Object.keys(activeReqEntry.failed).length, "totalamount": activeReqEntry.amount }, requesterID)}\n${failedcmdreference}`);

// Set status of this request to cooldown and add amount of successful comments to our global commentCounter
activeReqEntry.status = "cooldown";

}

commandHandler.controller.info.followCounter += activeReqEntry.amount - Object.keys(activeReqEntry.failed).length;

});
}
};
8 changes: 5 additions & 3 deletions src/commands/core/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Created Date: 2021-07-09 16:26:00
* Author: 3urobeat
*
* Last Modified: 2024-02-25 18:49:13
* Last Modified: 2025-02-12 22:07:40
* Modified By: 3urobeat
*
* Copyright (c) 2021 - 2024 3urobeat <https://github.com/3urobeat>
* Copyright (c) 2021 - 2025 3urobeat <https://github.com/3urobeat>
*
* 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.
Expand Down Expand Up @@ -111,6 +111,8 @@ module.exports.info = {
let userLastReq = "Never";
if (doc) userLastReq = ((new Date(doc.time)).toISOString().replace(/T/, " ").replace(/\..+/, "")) + " (GMT time)";

const info = commandHandler.controller.info;

/* eslint-disable no-irregular-whitespace */
respond(`
-----------------------------------~~~~~------------------------------------
Expand All @@ -122,7 +124,7 @@ module.exports.info = {
>   Your ID: ${resInfo.userID} | Steam Chat? ${resInfo.fromSteamChat ? "Yes" : "No"} | Owner? ${owners.includes(resInfo.userID) ? "Yes" : "No"}
>   Your last request: ${userLastReq}
>   Last processed request: ${(new Date(lastReq)).toISOString().replace(/T/, " ").replace(/\..+/, "")} (GMT time)
>   I have commented ${commandHandler.controller.info.commentCounter} times since my last restart and completed request!
>   I have fulfilled ${info.commentCounter + info.favCounter + info.followCounter + info.voteCounter} comments/favs/follows/votes since my last restart!
-----------------------------------~~~~~------------------------------------
`.replace(/^( {4})+/gm, "")); // Remove all the whitespaces that are added by the proper code indentation here
/* eslint-enable no-irregular-whitespace */
Expand Down
9 changes: 5 additions & 4 deletions src/commands/core/vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Created Date: 2023-05-28 12:02:24
* Author: 3urobeat
*
* Last Modified: 2024-10-10 18:20:41
* Last Modified: 2025-02-12 21:57:41
* Modified By: 3urobeat
*
* Copyright (c) 2023 - 2024 3urobeat <https://github.com/3urobeat>
* Copyright (c) 2023 - 2025 3urobeat <https://github.com/3urobeat>
*
* 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.
Expand Down Expand Up @@ -260,14 +260,15 @@ async function processVoteRequest(origin, commandHandler, args, respondModule, c
failedcmdreference = `\nTo get detailed information why which request failed please type '${resInfo.cmdprefix}failed'. You can read why your error was probably caused here: https://github.com/3urobeat/steam-comment-service-bot/blob/master/docs/wiki/errors_doc.md`;
}

// Send finished message
// Send finished message and set status of this request to cooldown
respond(`${await commandHandler.data.getLang("votesuccess", { "failedamount": Object.keys(activeReqEntry.failed).length, "numberOfVotes": activeReqEntry.amount }, requesterID)}\n${failedcmdreference}`);

// Set status of this request to cooldown and add amount of successful comments to our global commentCounter
activeReqEntry.status = "cooldown";

}

commandHandler.controller.info.voteCounter += activeReqEntry.amount - Object.keys(activeReqEntry.failed).length;

});
}

Expand Down
10 changes: 7 additions & 3 deletions src/controller/controller.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: 2025-01-31 11:41:41
* Last Modified: 2025-02-12 21:55:08
* Modified By: 3urobeat
*
* Copyright (c) 2021 - 2025 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -63,7 +63,7 @@ const Controller = function() {

/**
* Collection of various misc parameters
* @type {{ bootStartTimestamp: number, lastLoginTimestamp: object, steamGuardInputTime: number, startupWarnings: number, activeLogin: boolean, relogAfterDisconnect: boolean, readyAfter: number, skippedaccounts: string[], commentCounter: number }}
* @type {{ bootStartTimestamp: number, lastLoginTimestamp: object, steamGuardInputTime: number, startupWarnings: number, activeLogin: boolean, relogAfterDisconnect: boolean, readyAfter: number, skippedaccounts: string[], commentCounter: number, favCounter: number, followCounter: number, voteCounter: number }}
*/
this.info = {
bootStartTimestamp: Date.now(), // Save timestamp to be able to calculate startup time in ready event
Expand All @@ -74,7 +74,11 @@ const Controller = function() {
relogAfterDisconnect: true, // Allows to prevent accounts from relogging when calling bot.logOff()
readyAfter: 0, // Length of last startup in seconds
skippedaccounts: [], // Array of account names which have been skipped
commentCounter: 0 // Tracks total amount of comments to display in info command

commentCounter: 0, // Tracks total amount of comments to display in info/stats command
favCounter: 0, // Tracks total amount of favs + unfavs
followCounter: 0, // ...
voteCounter: 0,
};

/**
Expand Down
10 changes: 5 additions & 5 deletions src/data/fileStructure.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@
{
"path": "src/commands/core/favorite.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/core/favorite.js",
"checksum": "ae2c352d914cde611cddb8fb79971909"
"checksum": "1a5a4569ff4f4e88bb431b4b7147a479"
},
{
"path": "src/commands/core/follow.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/core/follow.js",
"checksum": "5f1f07fd3ff58d90f6801c76b0c7d3e2"
"checksum": "54f83235e0d8ca83c2ee75e91e285212"
},
{
"path": "src/commands/core/friend.js",
Expand All @@ -198,7 +198,7 @@
{
"path": "src/commands/core/general.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/commands/core/general.js",
"checksum": "a3017332fef9c3269d0a41fda1598025"
"checksum": "eff7522cbc2b49aa903770a4ea2893a8"
},
{
"path": "src/commands/core/group.js",
Expand All @@ -223,7 +223,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": "34892d7e75ee3bc9964f746c03fa3ddb"
"checksum": "6f0c55c7f8b8f8d91027cac6141722a6"
},
{
"path": "src/commands/helpers/calculateSuggestion.js",
Expand Down Expand Up @@ -278,7 +278,7 @@
{
"path": "src/controller/controller.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/controller/controller.js",
"checksum": "886cfd986562d1ee7301ce0829ec5818"
"checksum": "cbcb80b86e22c8eb93219b2ca875ab70"
},
{
"path": "src/controller/events/dataUpdate.js",
Expand Down

0 comments on commit d4d811e

Please sign in to comment.