mirror of
https://github.com/hack-chat/main.git
synced 2024-03-22 13:20:33 +08:00
Merge pull request #89 from MinusGix/nul_initial2
Added UAC and numeric user levels
This commit is contained in:
commit
4e0e269007
|
@ -2,10 +2,12 @@
|
||||||
Description: Adds the target trip to the mod list then elevates the uType
|
Description: Adds the target trip to the mod list then elevates the uType
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket, data) {
|
export async function run(core, server, socket, data) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (socket.uType !== 'admin') {
|
if (!UAC.isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket.address, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +20,7 @@ export async function run(core, server, socket, data) {
|
||||||
for (let i = 0, l = newMod.length; i < l; i += 1) {
|
for (let i = 0, l = newMod.length; i < l; i += 1) {
|
||||||
// upgrade privilages
|
// upgrade privilages
|
||||||
newMod[i].uType = 'mod';
|
newMod[i].uType = 'mod';
|
||||||
|
newMod[i].level = UAC.levels.moderator;
|
||||||
|
|
||||||
// inform new mod
|
// inform new mod
|
||||||
server.send({
|
server.send({
|
||||||
|
@ -37,7 +40,7 @@ export async function run(core, server, socket, data) {
|
||||||
server.broadcast({
|
server.broadcast({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: `Added mod: ${data.trip}`,
|
text: `Added mod: ${data.trip}`,
|
||||||
}, { uType: 'mod' });
|
}, { level: UAC.isModerator });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Description: Outputs all current channels and their user nicks
|
Description: Outputs all current channels and their user nicks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket) {
|
export async function run(core, server, socket) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (socket.uType !== 'admin') {
|
if (!UAC.isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket.address, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Description: Clears and resets the command modules, outputting any errors
|
Description: Clears and resets the command modules, outputting any errors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket, data) {
|
export async function run(core, server, socket, data) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (socket.uType !== 'admin') {
|
if (!UAC.isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket.address, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,17 +30,11 @@ export async function run(core, server, socket, data) {
|
||||||
loadResult += `\nReason: ${data.reason}`;
|
loadResult += `\nReason: ${data.reason}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reply with results
|
// send results to moderators (which the user using this command is higher than)
|
||||||
server.reply({
|
server.reply({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: loadResult,
|
text: loadResult,
|
||||||
}, socket);
|
}, { level: UAC.isModerator });
|
||||||
|
|
||||||
// notify mods of reload #transparency
|
|
||||||
server.broadcast({
|
|
||||||
cmd: 'info',
|
|
||||||
text: loadResult,
|
|
||||||
}, { uType: 'mod' });
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Description: Removes target trip from the config as a mod and downgrades the socket type
|
Description: Removes target trip from the config as a mod and downgrades the socket type
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket, data) {
|
export async function run(core, server, socket, data) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (socket.uType !== 'admin') {
|
if (!UAC.isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket.address, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +20,7 @@ export async function run(core, server, socket, data) {
|
||||||
for (let i = 0, l = targetMod.length; i < l; i += 1) {
|
for (let i = 0, l = targetMod.length; i < l; i += 1) {
|
||||||
// downgrade privilages
|
// downgrade privilages
|
||||||
targetMod[i].uType = 'user';
|
targetMod[i].uType = 'user';
|
||||||
|
targetMod[i].level = UAC.levels.user;
|
||||||
|
|
||||||
// inform ex-mod
|
// inform ex-mod
|
||||||
server.send({
|
server.send({
|
||||||
|
@ -39,7 +42,7 @@ export async function run(core, server, socket, data) {
|
||||||
server.broadcast({
|
server.broadcast({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: `Removed mod: ${data.trip}`,
|
text: `Removed mod: ${data.trip}`,
|
||||||
}, { uType: 'mod' });
|
}, { level: UAC.isModerator });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Description: Writes the current config to disk
|
Description: Writes the current config to disk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket) {
|
export async function run(core, server, socket) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (socket.uType !== 'admin') {
|
if (!UAC.isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket.address, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,17 +19,11 @@ export async function run(core, server, socket) {
|
||||||
}, socket);
|
}, socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return success message
|
// return success message to moderators and admins
|
||||||
server.reply({
|
server.reply({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: 'Config saved!',
|
text: 'Config saved!',
|
||||||
}, socket);
|
}, { level: UAC.isModerator });
|
||||||
|
|
||||||
// notify mods #transparency
|
|
||||||
server.broadcast({
|
|
||||||
cmd: 'info',
|
|
||||||
text: 'Config saved!',
|
|
||||||
}, { uType: 'mod' });
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Description: Emmits a server-wide message as `info`
|
Description: Emmits a server-wide message as `info`
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket, data) {
|
export async function run(core, server, socket, data) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (socket.uType !== 'admin') {
|
if (!UAC.isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket.address, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
Description: Rebroadcasts any `text` to all clients in a `channel`
|
Description: Rebroadcasts any `text` to all clients in a `channel`
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module support functions
|
// module support functions
|
||||||
const parseText = (text) => {
|
const parseText = (text) => {
|
||||||
// verifies user input is text
|
// verifies user input is text
|
||||||
|
@ -43,11 +45,12 @@ export async function run(core, server, socket, data) {
|
||||||
cmd: 'chat',
|
cmd: 'chat',
|
||||||
nick: socket.nick,
|
nick: socket.nick,
|
||||||
text,
|
text,
|
||||||
|
level: socket.level
|
||||||
};
|
};
|
||||||
|
|
||||||
if (socket.uType === 'admin') {
|
if (UAC.isAdmin(socket.level)) {
|
||||||
payload.admin = true;
|
payload.admin = true;
|
||||||
} else if (socket.uType === 'mod') {
|
} else if (UAC.isModerator(socket.level)) {
|
||||||
payload.mod = true;
|
payload.mod = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
Description: Initial entry point, applies `channel` and `nick` to the calling socket
|
Description: Initial entry point, applies `channel` and `nick` to the calling socket
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module support functions
|
// module support functions
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
@ -20,6 +22,7 @@ export function parseNickname(core, data) {
|
||||||
nick: '',
|
nick: '',
|
||||||
uType: 'user',
|
uType: 'user',
|
||||||
trip: null,
|
trip: null,
|
||||||
|
level: UAC.levels.user,
|
||||||
};
|
};
|
||||||
|
|
||||||
// seperate nick from password
|
// seperate nick from password
|
||||||
|
@ -36,6 +39,7 @@ export function parseNickname(core, data) {
|
||||||
if (hash(password + core.config.tripSalt) === core.config.adminTrip) {
|
if (hash(password + core.config.tripSalt) === core.config.adminTrip) {
|
||||||
userInfo.uType = 'admin';
|
userInfo.uType = 'admin';
|
||||||
userInfo.trip = 'Admin';
|
userInfo.trip = 'Admin';
|
||||||
|
userInfo.level = UAC.levels.admin;
|
||||||
} else if (userInfo.nick.toLowerCase() === core.config.adminName.toLowerCase()) {
|
} else if (userInfo.nick.toLowerCase() === core.config.adminName.toLowerCase()) {
|
||||||
// they've got the main-admin name while not being an admin
|
// they've got the main-admin name while not being an admin
|
||||||
return 'You are not the admin, liar!';
|
return 'You are not the admin, liar!';
|
||||||
|
@ -48,6 +52,7 @@ export function parseNickname(core, data) {
|
||||||
core.config.mods.forEach((mod) => {
|
core.config.mods.forEach((mod) => {
|
||||||
if (userInfo.trip === mod.trip) {
|
if (userInfo.trip === mod.trip) {
|
||||||
userInfo.uType = 'mod';
|
userInfo.uType = 'mod';
|
||||||
|
userInfo.level = UAC.levels.moderator;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -113,6 +118,7 @@ export async function run(core, server, socket, data) {
|
||||||
nick: userInfo.nick,
|
nick: userInfo.nick,
|
||||||
trip: userInfo.trip || 'null',
|
trip: userInfo.trip || 'null',
|
||||||
hash: userInfo.userHash,
|
hash: userInfo.userHash,
|
||||||
|
level: userInfo.level,
|
||||||
};
|
};
|
||||||
|
|
||||||
// send join announcement and prep online set
|
// send join announcement and prep online set
|
||||||
|
@ -126,6 +132,7 @@ export async function run(core, server, socket, data) {
|
||||||
socket.nick = userInfo.nick;
|
socket.nick = userInfo.nick;
|
||||||
socket.channel = data.channel;
|
socket.channel = data.channel;
|
||||||
socket.hash = userInfo.userHash;
|
socket.hash = userInfo.userHash;
|
||||||
|
socket.level = userInfo.level;
|
||||||
if (userInfo.trip !== null) socket.trip = userInfo.trip;
|
if (userInfo.trip !== null) socket.trip = userInfo.trip;
|
||||||
|
|
||||||
nicks.push(socket.nick);
|
nicks.push(socket.nick);
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Description: Adds the target socket's ip to the ratelimiter
|
Description: Adds the target socket's ip to the ratelimiter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket, data) {
|
export async function run(core, server, socket, data) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (socket.uType === 'user') {
|
if (!UAC.isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket.address, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +30,7 @@ export async function run(core, server, socket, data) {
|
||||||
[badClient] = badClient;
|
[badClient] = badClient;
|
||||||
|
|
||||||
// i guess banning mods or admins isn't the best idea?
|
// i guess banning mods or admins isn't the best idea?
|
||||||
if (badClient.uType !== 'user') {
|
if (badClient.level >= socket.level) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn',
|
cmd: 'warn',
|
||||||
text: 'Cannot ban other mods, how rude',
|
text: 'Cannot ban other mods, how rude',
|
||||||
|
@ -44,13 +46,13 @@ export async function run(core, server, socket, data) {
|
||||||
server.broadcast({
|
server.broadcast({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: `Banned ${targetNick}`,
|
text: `Banned ${targetNick}`,
|
||||||
}, { channel: socket.channel, uType: 'user' });
|
}, { channel: socket.channel, level: (level) => level < UAC.levels.moderator });
|
||||||
|
|
||||||
// notify mods
|
// notify mods
|
||||||
server.broadcast({
|
server.broadcast({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}`,
|
text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}`,
|
||||||
}, { uType: 'mod' });
|
}, { level: UAC.isModerator });
|
||||||
|
|
||||||
// force connection closed
|
// force connection closed
|
||||||
badClient.terminate();
|
badClient.terminate();
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
* Author: simple
|
* Author: simple
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module constructor
|
// module constructor
|
||||||
export function init(core) {
|
export function init(core) {
|
||||||
if (typeof core.muzzledHashes === 'undefined') {
|
if (typeof core.muzzledHashes === 'undefined') {
|
||||||
|
@ -13,7 +15,7 @@ export function init(core) {
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket, data) {
|
export async function run(core, server, socket, data) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (socket.uType === 'user') {
|
if (!UAC.isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket.address, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ export async function run(core, server, socket, data) {
|
||||||
[badClient] = badClient;
|
[badClient] = badClient;
|
||||||
|
|
||||||
// likely dont need this, muting mods and admins is fine
|
// likely dont need this, muting mods and admins is fine
|
||||||
if (badClient.uType !== 'user') {
|
if (badClient.level >= socket.level) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn',
|
cmd: 'warn',
|
||||||
text: 'This trick wont work on mods and admin',
|
text: 'This trick wont work on mods and admin',
|
||||||
|
@ -56,7 +58,7 @@ export async function run(core, server, socket, data) {
|
||||||
server.broadcast({
|
server.broadcast({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: `${socket.nick} muzzled ${data.nick} in ${socket.channel}, userhash: ${badClient.hash}`,
|
text: `${socket.nick} muzzled ${data.nick} in ${socket.channel}, userhash: ${badClient.hash}`,
|
||||||
}, { uType: 'mod' });
|
}, { level: UAC.isModerator });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Description: Forces a change on the target(s) socket's channel, then broadcasts event
|
Description: Forces a change on the target(s) socket's channel, then broadcasts event
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket, data) {
|
export async function run(core, server, socket, data) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (socket.uType === 'user') {
|
if (!UAC.isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket.address, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +38,7 @@ export async function run(core, server, socket, data) {
|
||||||
// check if found targets are kickable, add them to the list if they are
|
// check if found targets are kickable, add them to the list if they are
|
||||||
const kicked = [];
|
const kicked = [];
|
||||||
for (let i = 0, j = badClients.length; i < j; i += 1) {
|
for (let i = 0, j = badClients.length; i < j; i += 1) {
|
||||||
if (badClients[i].uType !== 'user') {
|
if (badClients[i].level >= socket.level) {
|
||||||
server.reply({
|
server.reply({
|
||||||
cmd: 'warn',
|
cmd: 'warn',
|
||||||
text: 'Cannot kick other mods, how rude',
|
text: 'Cannot kick other mods, how rude',
|
||||||
|
@ -68,7 +70,7 @@ export async function run(core, server, socket, data) {
|
||||||
server.broadcast({
|
server.broadcast({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: `${kicked[i].nick} was banished to ?${destChannel}`,
|
text: `${kicked[i].nick} was banished to ?${destChannel}`,
|
||||||
}, { channel: socket.channel, uType: 'mod' });
|
}, { channel: socket.channel, level: UAC.isModerator });
|
||||||
|
|
||||||
console.log(`${socket.nick} [${socket.trip}] kicked ${kicked[i].nick} in ${socket.channel} to ${destChannel} `);
|
console.log(`${socket.nick} [${socket.trip}] kicked ${kicked[i].nick} in ${socket.channel} to ${destChannel} `);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +88,7 @@ export async function run(core, server, socket, data) {
|
||||||
server.broadcast({
|
server.broadcast({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: `Kicked ${kicked.map(k => k.nick).join(', ')}`,
|
text: `Kicked ${kicked.map(k => k.nick).join(', ')}`,
|
||||||
}, { channel: socket.channel, uType: 'user' });
|
}, { channel: socket.channel, level: (level) => level < UAC.levels.moderator });
|
||||||
|
|
||||||
// stats are fun
|
// stats are fun
|
||||||
core.stats.increment('users-kicked', kicked.length);
|
core.stats.increment('users-kicked', kicked.length);
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Description: Removes the target socket from the current channel and forces a join event in another
|
Description: Removes the target socket from the current channel and forces a join event in another
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket, data) {
|
export async function run(core, server, socket, data) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (socket.uType === 'user') {
|
if (!UAC.isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket.address, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +32,7 @@ export async function run(core, server, socket, data) {
|
||||||
|
|
||||||
const badClient = badClients[0];
|
const badClient = badClients[0];
|
||||||
|
|
||||||
if (badClient.uType !== 'user') {
|
if (badClient.level >= socket.level) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn',
|
cmd: 'warn',
|
||||||
text: 'Cannot move other mods, how rude',
|
text: 'Cannot move other mods, how rude',
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
* Author: simple
|
* Author: simple
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module constructor
|
// module constructor
|
||||||
export function init(core) {
|
export function init(core) {
|
||||||
if (typeof core.muzzledHashes === 'undefined') {
|
if (typeof core.muzzledHashes === 'undefined') {
|
||||||
|
@ -13,7 +15,7 @@ export function init(core) {
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket, data) {
|
export async function run(core, server, socket, data) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (socket.uType === 'user') {
|
if (!UAC.isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket.address, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ export async function run(core, server, socket, data) {
|
||||||
server.broadcast({
|
server.broadcast({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: `${socket.nick} unmuzzled : ${target}`,
|
text: `${socket.nick} unmuzzled : ${target}`,
|
||||||
}, { uType: 'mod' });
|
}, { level: UAC.isModerator });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Description: Removes a target ip from the ratelimiter
|
Description: Removes a target ip from the ratelimiter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket, data) {
|
export async function run(core, server, socket, data) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (socket.uType === 'user') {
|
if (!UAC.isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket.address, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +49,7 @@ export async function run(core, server, socket, data) {
|
||||||
server.broadcast({
|
server.broadcast({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: `${socket.nick} unbanned: ${target}`,
|
text: `${socket.nick} unbanned: ${target}`,
|
||||||
}, { uType: 'mod' });
|
}, { level: UAC.isModerator });
|
||||||
|
|
||||||
// stats are fun
|
// stats are fun
|
||||||
core.stats.decrement('users-banned');
|
core.stats.decrement('users-banned');
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
Description: Clears all bans and ratelimits
|
Description: Clears all bans and ratelimits
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as UAC from "../utility/UAC/info";
|
||||||
|
|
||||||
// module main
|
// module main
|
||||||
export async function run(core, server, socket) {
|
export async function run(core, server, socket) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (socket.uType === 'user') {
|
if (!UAC.isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket.address, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +26,7 @@ export async function run(core, server, socket) {
|
||||||
server.broadcast({
|
server.broadcast({
|
||||||
cmd: 'info',
|
cmd: 'info',
|
||||||
text: `${socket.nick} unbanned all ip addresses`,
|
text: `${socket.nick} unbanned all ip addresses`,
|
||||||
}, { uType: 'mod' });
|
}, { level: UAC.isModerator });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
32
server/src/commands/utility/UAC/info.js
Normal file
32
server/src/commands/utility/UAC/info.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
export const levels = {
|
||||||
|
admin : 9999999,
|
||||||
|
moderator : 999999,
|
||||||
|
|
||||||
|
channelOwner : 99999,
|
||||||
|
channelModerator : 9999,
|
||||||
|
|
||||||
|
user : 100,
|
||||||
|
};
|
||||||
|
|
||||||
|
export function isAdmin (level) {
|
||||||
|
return level >= levels.admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isModerator (level) {
|
||||||
|
return level >= levels.moderator;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isChannelOwner (level) {
|
||||||
|
return level >= levels.channelOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isChannelModerator (level) {
|
||||||
|
return level >= levels.channelModerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function run (core, server, socket, data) {}
|
||||||
|
|
||||||
|
export const info = {
|
||||||
|
name: 'uac_info',
|
||||||
|
description: 'This module contains information about UAC levels, and minor utility functions.',
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user