Skip to content

Commit

Permalink
refactor: Fix JsDoc Bot reference being unresolved in Controller func…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
3urobeat committed Jan 5, 2025
1 parent 6fac016 commit 506d9c1
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 58 deletions.
117 changes: 60 additions & 57 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-03 21:48:48
* Last Modified: 2025-01-05 13:08:02
* Modified By: 3urobeat
*
* Copyright (c) 2021 - 2025 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -394,6 +394,64 @@ Controller.prototype._preLogin = async function() {
runOnRegistration: false
});


// Functions implemented by Controller which require the previously unresolved Bot class import
/**
* Filters the active set of bot accounts by a given criteria
* @param {function(Bot): boolean} predicate Function that returns true if the account should be included in the result
* @returns {Array.<Bot>} Array of bot instances that match the criteria
*/
this.filterAccounts = function(predicate) {}; // eslint-disable-line

/**
* Runs internal statusUpdate event code and emits statusUpdate event for plugins
* @param {Bot} bot Bot instance
* @param {Bot.EStatus} newStatus The new status of this bot
*/
this._statusUpdateEvent = function(bot, newStatus) {}; // eslint-disable-line

/**
* Emits steamGuardInput event for bot & plugins
* @param {Bot} bot Bot instance of the affected account
* @param {function(string): void} submitCode Function to submit a code. Pass an empty string to skip the account.
*/
this._steamGuardInputEvent = function(bot, submitCode) {}; // eslint-disable-line

/**
* Emits steamGuardQrCode event for bot & plugins
* @param {Bot} bot Bot instance of the affected account
* @param {string} challengeUrl The QrCode Challenge URL supplied by Steam. Display this value using a QR-Code parser and let a user scan it using their Steam Mobile App.
*/
this._steamGuardQrCodeEvent = function(bot, challengeUrl) {}; // eslint-disable-line

/**
* Check if all friends are in lastcomment database
* @param {Bot} bot Bot object of the account to check
*/
this.checkLastcommentDB = function(bot) {}; // eslint-disable-line

/**
* Checks the remaining space on the friendlist of a bot account, sends a warning message if it is less than 10 and force unfriends oldest lastcomment db user to always keep room for 1 friend.
* @param {Bot} bot Bot object of the account to check
* @param {function(number|null): void} callback Called with `remaining` (Number) on success or `null` on failure
*/
this.friendListCapacityCheck = function(bot, callback) {}; // eslint-disable-line

/**
* Retrieves all matching bot accounts and returns them.
* @param {(EStatus|EStatus[]|string)} [statusFilter=EStatus.ONLINE] Optional: EStatus or Array of EStatus's including account statuses to filter. Pass '*' to get all accounts. If omitted, only accs with status 'EStatus.ONLINE' will be returned.
* @param {boolean} [mapToObject=false] Optional: If true, an object will be returned where every bot object is mapped to their accountName.
* @returns {Array.<Bot>} An array or object if `mapToObject == true` containing all matching bot accounts. Note: This JsDoc type param only specifies the default array version to get IntelliSense support.
*/
this.getBots = function(statusFilter = EStatus.ONLINE, mapToObject = false) {}; // eslint-disable-line

/**
* Retrieves bot accounts per proxy. This can be used to find the most and least used active proxies for example.
* @param {boolean} [filterOffline=false] Set to true to remove proxies which are offline. Make sure to call `checkAllProxies()` beforehand!
* @returns {Array.<{ bots: Array.<Bot>, proxy: string, proxyIndex: number, isOnline: boolean, lastOnlineCheck: number }>} Bot accounts mapped to their associated proxy
*/
this.getBotsPerProxy = function(filterOffline = false) {}; // eslint-disable-line

};


Expand Down Expand Up @@ -422,6 +480,7 @@ Controller.prototype.stop = function() {


/* -------- Register functions to let the IntelliSense know what's going on in helper files -------- */
// NOTE: Functions containing 'Bot' class in JsDoc MUST be referenced in _preLogin() instead, as the the Bot import is not resolved here yet

/**
* Attempts to log in all bot accounts which are currently offline one after another.
Expand Down Expand Up @@ -467,13 +526,6 @@ Controller.prototype.relogAccount = function(accountName) {}; // eslint-disable-
*/
Controller.prototype.respreadProxies = async function() {};

/**
* Filters the active set of bot accounts by a given criteria
* @param {function(Bot): boolean} predicate Function that returns true if the account should be included in the result
* @returns {Array.<Bot>} Array of bot instances that match the criteria
*/
Controller.prototype.filterAccounts = function(predicate) {}; // eslint-disable-line

/**
* Set of premade functions for filterAccounts()
* @type {{ all: Function, statusOffline: Function, statusOnline: Function, statusError: Function, statusSkipped: Function, limited: Function, unlimited: Function }}
Expand All @@ -485,60 +537,11 @@ Controller.prototype.filters = {};
*/
Controller.prototype._readyEvent = function() {};

/**
* Runs internal statusUpdate event code and emits statusUpdate event for plugins
* @param {Bot} bot Bot instance
* @param {Bot.EStatus} newStatus The new status of this bot
*/
Controller.prototype._statusUpdateEvent = function(bot, newStatus) {}; // eslint-disable-line

/**
* Emits steamGuardInput event for bot & plugins
* @param {Bot} bot Bot instance of the affected account
* @param {function(string): void} submitCode Function to submit a code. Pass an empty string to skip the account.
*/
Controller.prototype._steamGuardInputEvent = function(bot, submitCode) {}; // eslint-disable-line

/**
* Emits steamGuardQrCode event for bot & plugins
* @param {Bot} bot Bot instance of the affected account
* @param {string} challengeUrl The QrCode Challenge URL supplied by Steam. Display this value using a QR-Code parser and let a user scan it using their Steam Mobile App.
*/
Controller.prototype._steamGuardQrCodeEvent = function(bot, challengeUrl) {}; // eslint-disable-line

/**
* Check if all friends are in lastcomment database
* @param {Bot} bot Bot object of the account to check
*/
Controller.prototype.checkLastcommentDB = function(bot) {}; // eslint-disable-line

/**
* Checks the remaining space on the friendlist of a bot account, sends a warning message if it is less than 10 and force unfriends oldest lastcomment db user to always keep room for 1 friend.
* @param {Bot} bot Bot object of the account to check
* @param {function(number|null): void} callback Called with `remaining` (Number) on success or `null` on failure
*/
Controller.prototype.friendListCapacityCheck = function(bot, callback) {}; // eslint-disable-line

/**
* Check for friends who haven't requested comments in config.unfriendtime days and unfriend them
*/
Controller.prototype._lastcommentUnfriendCheck = function() {} // eslint-disable-line

/**
* Retrieves all matching bot accounts and returns them.
* @param {(EStatus|EStatus[]|string)} [statusFilter=EStatus.ONLINE] Optional: EStatus or Array of EStatus's including account statuses to filter. Pass '*' to get all accounts. If omitted, only accs with status 'EStatus.ONLINE' will be returned.
* @param {boolean} [mapToObject=false] Optional: If true, an object will be returned where every bot object is mapped to their accountName.
* @returns {Array.<Bot>} An array or object if `mapToObject == true` containing all matching bot accounts. Note: This JsDoc type param only specifies the default array version to get IntelliSense support.
*/
Controller.prototype.getBots = function(statusFilter = EStatus.ONLINE, mapToObject = false) {}; // eslint-disable-line

/**
* Retrieves bot accounts per proxy. This can be used to find the most and least used active proxies for example.
* @param {boolean} [filterOffline=false] Set to true to remove proxies which are offline. Make sure to call `checkAllProxies()` beforehand!
* @returns {Array.<{ bots: Array.<Bot>, proxy: string, proxyIndex: number, isOnline: boolean, lastOnlineCheck: number }>} Bot accounts mapped to their associated proxy
*/
Controller.prototype.getBotsPerProxy = function(filterOffline = false) {}; // eslint-disable-line

/**
* Internal: Handles process's unhandledRejection & uncaughtException error events.
* Should a NPM related error be detected it attempts to reinstall all packages using our npminteraction helper function
Expand Down
2 changes: 1 addition & 1 deletion src/data/fileStructure.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
{
"path": "src/controller/controller.js",
"url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/controller/controller.js",
"checksum": "07e5a65b201a97ef1db936581b9bffa1"
"checksum": "8ace7a10caf5ab679d187e8ce9f4a057"
},
{
"path": "src/controller/events/ready.js",
Expand Down

0 comments on commit 506d9c1

Please sign in to comment.