mirror of
https://github.com/hack-chat/main.git
synced 2024-03-22 13:20:33 +08:00
Created dumb.js
This command module adds a new way to cleanly get rid of unwanted spams.
This commit is contained in:
parent
cf9fd316e9
commit
c615992efa
58
server/src/commands/mod/dumb.js
Normal file
58
server/src/commands/mod/dumb.js
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Description: Make a user (spammer) dumb
|
||||
* Author: simple
|
||||
*/
|
||||
|
||||
exports.init = (core) => {
|
||||
core.muzzledHashes = {};
|
||||
}
|
||||
|
||||
exports.run = async (core, server, socket, data) => {
|
||||
if (socket.uType == 'user') {
|
||||
// ignore if not mod or admin
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof data.nick !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
let targetNick = data.nick;
|
||||
let badClient = server.findSockets({ channel: socket.channel, nick: targetNick });
|
||||
|
||||
if (badClient.length === 0) {
|
||||
server.reply({
|
||||
cmd: 'warn',
|
||||
text: 'Could not find user in channel'
|
||||
}, socket);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
badClient = badClient[0];
|
||||
|
||||
if (badClient.uType !== 'user') {
|
||||
server.reply({
|
||||
cmd: 'warn',
|
||||
text: 'This trick wont work on mods and admin'
|
||||
}, socket);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
core.muzzledHashes[badClient.hash] = true;
|
||||
|
||||
server.broadcast({
|
||||
cmd: 'info',
|
||||
text: `${socket.nick} muzzled ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}`
|
||||
}, { uType: 'mod' });
|
||||
|
||||
}
|
||||
|
||||
exports.requiredData = ['nick'];
|
||||
|
||||
exports.info = {
|
||||
name: 'dumb',
|
||||
usage: 'dumb {nick}',
|
||||
description: 'Cleanly disable a user messages and make him dumb'
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user