2023-12-22 15:14:03 +08:00
|
|
|
/**
|
|
|
|
* @author Marzavec ( https://github.com/marzavec )
|
|
|
|
* @summary Disables the captcha
|
|
|
|
* @version 1.0.0
|
|
|
|
* @description Disables the captcha on the channel specified in the channel property,
|
|
|
|
* default is current channel
|
|
|
|
* @module disablecaptcha
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {
|
|
|
|
isModerator,
|
|
|
|
} from '../utility/_UAC.js';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Automatically executes once after server is ready
|
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} core - Reference to core environment object
|
2023-12-22 15:14:03 +08:00
|
|
|
* @public
|
|
|
|
* @return {void}
|
|
|
|
*/
|
|
|
|
export async function init(core) {
|
|
|
|
if (typeof core.captchas === 'undefined') {
|
|
|
|
core.captchas = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2023-12-22 15:14:03 +08:00
|
|
|
* @public
|
|
|
|
* @return {void}
|
|
|
|
*/
|
|
|
|
export async function run({
|
|
|
|
core, server, socket, payload,
|
|
|
|
}) {
|
|
|
|
// increase rate limit chance and ignore if not admin or mod
|
|
|
|
if (!isModerator(socket.level)) {
|
2023-12-27 16:26:49 +08:00
|
|
|
return server.police.frisk(socket, 10);
|
2023-12-22 15:14:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let targetChannel;
|
|
|
|
|
|
|
|
if (typeof payload.channel !== 'string') {
|
|
|
|
if (typeof socket.channel !== 'string') { // @todo Multichannel
|
|
|
|
return false; // silently fail
|
|
|
|
}
|
|
|
|
|
|
|
|
targetChannel = socket.channel;
|
|
|
|
} else {
|
|
|
|
targetChannel = payload.channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!core.captchas[targetChannel]) {
|
|
|
|
return server.reply({
|
2024-01-09 03:09:59 +08:00
|
|
|
cmd: 'info', // @todo Add numeric info code as `id`
|
2023-12-22 15:14:03 +08:00
|
|
|
text: 'Captcha is not enabled.',
|
|
|
|
channel: socket.channel, // @todo Multichannel
|
|
|
|
}, socket);
|
|
|
|
}
|
|
|
|
|
|
|
|
core.captchas[targetChannel] = false;
|
|
|
|
|
|
|
|
server.broadcast({
|
2024-01-09 03:09:59 +08:00
|
|
|
cmd: 'info', // @todo Add numeric info code as `id`
|
2023-12-22 15:14:03 +08:00
|
|
|
text: `Captcha disabled on: ${targetChannel}`,
|
|
|
|
channel: false, // @todo Multichannel, false for global info
|
|
|
|
}, { channel: targetChannel, level: isModerator });
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module meta information
|
|
|
|
* @public
|
|
|
|
* @typedef {Object} disablecaptcha/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
|
|
|
|
*/
|
|
|
|
export const info = {
|
|
|
|
name: 'disablecaptcha',
|
|
|
|
category: 'moderators',
|
|
|
|
description: 'Disables the captcha on the channel specified in the channel property, default is current channel',
|
|
|
|
usage: `
|
|
|
|
API: { cmd: 'disablecaptcha', channel: '<optional channel, defaults to your current channel' }`,
|
|
|
|
};
|