2018-03-10 15:47:00 +08:00
|
|
|
/*
|
2018-03-14 13:26:53 +08:00
|
|
|
Description: Adds the target trip to the mod list then elevates the uType
|
2018-03-10 15:47:00 +08:00
|
|
|
*/
|
|
|
|
|
2020-03-06 00:49:25 +08:00
|
|
|
import * as UAC from "../utility/UAC/info";
|
|
|
|
|
2018-09-30 14:44:36 +08:00
|
|
|
// module main
|
2019-11-07 15:35:23 +08:00
|
|
|
export async function run(core, server, socket, data) {
|
2018-06-04 15:07:24 +08:00
|
|
|
// increase rate limit chance and ignore if not admin
|
2020-03-06 00:49:25 +08:00
|
|
|
if (!UAC.isAdmin(socket.level)) {
|
2019-11-07 15:35:23 +08:00
|
|
|
return server.police.frisk(socket.address, 20);
|
2018-03-10 15:47:00 +08:00
|
|
|
}
|
|
|
|
|
2018-06-04 15:07:24 +08:00
|
|
|
// add new trip to config
|
2019-03-19 14:36:21 +08:00
|
|
|
core.config.mods.push({ trip: data.trip });
|
2018-03-10 15:47:00 +08:00
|
|
|
|
2018-09-30 14:44:36 +08:00
|
|
|
// find targets current connections
|
2019-11-07 15:35:23 +08:00
|
|
|
const newMod = server.findSockets({ trip: data.trip });
|
2018-03-14 13:26:53 +08:00
|
|
|
if (newMod.length !== 0) {
|
2019-11-07 15:35:23 +08:00
|
|
|
for (let i = 0, l = newMod.length; i < l; i += 1) {
|
2018-09-30 14:44:36 +08:00
|
|
|
// upgrade privilages
|
2018-03-14 13:26:53 +08:00
|
|
|
newMod[i].uType = 'mod';
|
2020-03-06 00:49:25 +08:00
|
|
|
newMod[i].level = UAC.levels.moderator;
|
2018-03-10 15:47:00 +08:00
|
|
|
|
2018-09-30 14:44:36 +08:00
|
|
|
// inform new mod
|
2018-03-14 13:26:53 +08:00
|
|
|
server.send({
|
2018-03-10 15:47:00 +08:00
|
|
|
cmd: 'info',
|
2019-11-07 15:35:23 +08:00
|
|
|
text: 'You are now a mod.',
|
2018-03-14 13:26:53 +08:00
|
|
|
}, newMod[i]);
|
2018-03-10 15:47:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-04 15:07:24 +08:00
|
|
|
// return success message
|
2018-03-10 15:47:00 +08:00
|
|
|
server.reply({
|
|
|
|
cmd: 'info',
|
2019-11-07 15:35:23 +08:00
|
|
|
text: `Added mod trip: ${data.trip}, remember to run 'saveconfig' to make it permanent`,
|
2018-03-10 15:47:00 +08:00
|
|
|
}, socket);
|
|
|
|
|
2018-06-04 15:07:24 +08:00
|
|
|
// notify all mods
|
2018-03-10 15:47:00 +08:00
|
|
|
server.broadcast({
|
|
|
|
cmd: 'info',
|
2019-11-07 15:35:23 +08:00
|
|
|
text: `Added mod: ${data.trip}`,
|
2020-03-06 00:49:25 +08:00
|
|
|
}, { level: UAC.isModerator });
|
2018-03-10 15:47:00 +08:00
|
|
|
|
2019-11-07 15:35:23 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const requiredData = ['trip'];
|
|
|
|
export const info = {
|
2018-05-13 18:33:22 +08:00
|
|
|
name: 'addmod',
|
2018-09-30 14:44:36 +08:00
|
|
|
description: 'Adds target trip to the config as a mod and upgrades the socket type',
|
|
|
|
usage: `
|
2019-11-07 15:35:23 +08:00
|
|
|
API: { cmd: 'addmod', trip: '<target trip>' }`,
|
2018-05-13 18:33:22 +08:00
|
|
|
};
|