From e35fff59ba30e78046c9212e74fce9aef56c6e93 Mon Sep 17 00:00:00 2001 From: marzavec Date: Mon, 4 Jun 2018 00:07:24 -0700 Subject: cleaned up and commented modules --- server/src/commands/mod/kick.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'server/src/commands/mod/kick.js') diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js index 157592d..75c0d40 100644 --- a/server/src/commands/mod/kick.js +++ b/server/src/commands/mod/kick.js @@ -1,19 +1,23 @@ /* - Description: Forces a change on the target socket's channel, then broadcasts event + Description: Forces a change on the target(s) socket's channel, then broadcasts event */ exports.run = async (core, server, socket, data) => { - if (socket.uType === 'user') { - // ignore if not mod or admin + // increase rate limit chance and ignore if not admin or mod + if (socket.uType == 'user') { + server._police.frisk(socket.remoteAddress, 10); + return; } + // check user input if (typeof data.nick !== 'string') { if (typeof data.nick !== 'object' && !Array.isArray(data.nick)) { return; } } + // find target user(s) let badClients = server.findSockets({ channel: socket.channel, nick: data.nick }); if (badClients.length === 0) { @@ -25,6 +29,7 @@ exports.run = async (core, server, socket, data) => { return; } + // check if found targets are kickable, commit kick let newChannel = ''; let kicked = []; for (let i = 0, j = badClients.length; i < j; i++) { @@ -66,6 +71,7 @@ exports.run = async (core, server, socket, data) => { text: `Kicked ${kicked.join(', ')}` }, { channel: socket.channel, uType: 'user' }); + // stats are fun core.managers.stats.increment('users-kicked', kicked.length); }; @@ -75,4 +81,4 @@ exports.info = { name: 'kick', usage: 'kick {nick}', description: 'Silently forces target client(s) into another channel. `nick` may be string or array of strings' -}; \ No newline at end of file +}; -- cgit v1.2.1