aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/mod/ban.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/commands/mod/ban.js')
-rw-r--r--server/src/commands/mod/ban.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js
index e19efc2..721ad27 100644
--- a/server/src/commands/mod/ban.js
+++ b/server/src/commands/mod/ban.js
@@ -3,15 +3,19 @@
*/
exports.run = async (core, server, socket, data) => {
+ // increase rate limit chance and ignore if not admin or mod
if (socket.uType == 'user') {
- // ignore if not mod or admin
+ server._police.frisk(socket.remoteAddress, 10);
+
return;
}
+ // check user input
if (typeof data.nick !== 'string') {
return;
}
+ // find target user
let targetNick = data.nick;
let badClient = server.findSockets({ channel: socket.channel, nick: targetNick });
@@ -26,6 +30,7 @@ exports.run = async (core, server, socket, data) => {
badClient = badClient[0];
+ // i guess banning mods or admins isn't the best idea?
if (badClient.uType !== 'user') {
server.reply({
cmd: 'warn',
@@ -35,23 +40,27 @@ exports.run = async (core, server, socket, data) => {
return;
}
- let clientHash = server.getSocketHash(badClient);
- server._police.arrest(badClient.remoteAddress, clientHash);
+ // commit arrest record
+ server._police.arrest(badClient.remoteAddress, badClient.hash);
console.log(`${socket.nick} [${socket.trip}] banned ${targetNick} in ${socket.channel}`);
+ // notify normal users
server.broadcast({
cmd: 'info',
text: `Banned ${targetNick}`
}, { channel: socket.channel, uType: 'user' });
+ // notify mods
server.broadcast({
cmd: 'info',
- text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${clientHash}`
+ text: `${socket.nick} banned ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}`
}, { uType: 'mod' });
- badClient.close();
+ // force connection closed
+ badClient.terminate();
+ // stats are fun
core.managers.stats.increment('users-banned');
};