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
|
channel ownership base, part 1
Fleshing out the new channel ownership feature, along with a typo fix and small syntax updates.
A claim can now be staked with /claimchannel, a channel owner may change a trip's level using /setlevel
To do: unclaimchannel, setmotd, makeprivate, makepublic, renewclaim, garbage keeping, update mod commands to accept channelOwner and channelModerator, etc
2024-01-05 16:30:28 +08:00
|
|
|
* @param {Object} env - Environment object with references to core, server, socket & payload
|
2022-06-23 00:32:51 +08:00
|
|
|
* @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
|
|
|
};
|