2022-06-23 00:32:51 +08:00
|
|
|
/**
|
|
|
|
* @author Marzavec ( https://github.com/marzavec )
|
|
|
|
* @summary Bridge warning events to a user
|
|
|
|
* @version 1.0.0
|
|
|
|
* @description If a warning occurs within the server, this module will relay the warning to the
|
|
|
|
* client
|
|
|
|
* @module socketreply
|
|
|
|
*/
|
2018-06-04 02:08:35 +08:00
|
|
|
|
2022-06-23 00:32:51 +08:00
|
|
|
/**
|
|
|
|
* Executes when invoked by a remote client
|
|
|
|
* @param {Object} env - Enviroment object with references to core, server, socket & payload
|
|
|
|
* @public
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2020-09-17 13:44:32 +08:00
|
|
|
export async function run({ server, socket, payload }) {
|
|
|
|
if (payload.cmdKey !== server.cmdKey) {
|
2018-06-04 02:08:35 +08:00
|
|
|
// internal command attempt by client, increase rate limit chance and ignore
|
2023-12-27 16:26:49 +08:00
|
|
|
return server.police.frisk(socket, 20);
|
2018-06-04 02:08:35 +08:00
|
|
|
}
|
|
|
|
|
2018-06-04 15:07:24 +08:00
|
|
|
// send warning to target socket
|
2022-06-23 00:32:51 +08:00
|
|
|
return server.reply({
|
|
|
|
cmd: 'warn',
|
2020-09-17 13:44:32 +08:00
|
|
|
text: payload.text,
|
2020-09-08 12:51:47 +08:00
|
|
|
}, socket);
|
2019-11-07 15:35:23 +08:00
|
|
|
}
|
|
|
|
|
2022-06-23 00:32:51 +08:00
|
|
|
/**
|
|
|
|
* The following payload properties are required to invoke this module:
|
|
|
|
* "cmdKey", "text"
|
|
|
|
* @public
|
|
|
|
* @typedef {Array} socketreply/requiredData
|
|
|
|
*/
|
2019-11-07 15:35:23 +08:00
|
|
|
export const requiredData = ['cmdKey', 'text'];
|
2022-06-23 00:32:51 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Module meta information
|
|
|
|
* @public
|
|
|
|
* @typedef {Object} socketreply/info
|
|
|
|
* @property {string} name - Module command name
|
|
|
|
* @property {string} category - Module category name
|
|
|
|
* @property {string} description - Information about module
|
|
|
|
* @property {string} usage - Information about module usage
|
|
|
|
*/
|
2019-11-07 15:35:23 +08:00
|
|
|
export const info = {
|
2018-06-04 02:08:35 +08:00
|
|
|
name: 'socketreply',
|
2022-06-23 00:32:51 +08:00
|
|
|
category: 'internal',
|
2019-11-07 15:35:23 +08:00
|
|
|
description: 'Internally used to relay warnings to clients',
|
2022-06-23 00:32:51 +08:00
|
|
|
usage: 'Internal Use Only',
|
2018-06-04 02:08:35 +08:00
|
|
|
};
|