diff options
author | marzavec <admin@marzavec.com> | 2018-06-01 21:50:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-01 21:50:38 +0200 |
commit | 71e940ddbae9b08c542ed7873d5adfaf51f28cd1 (patch) | |
tree | 3517a08cf3ab1a6adc81f3eadeff476b9dc931a9 /server/src/commands/mod | |
parent | formatting fix (diff) | |
parent | Array checking made constructor safe (diff) | |
download | hackchat-71e940ddbae9b08c542ed7873d5adfaf51f28cd1.tar.gz hackchat-71e940ddbae9b08c542ed7873d5adfaf51f28cd1.zip |
Merge pull request #16 from OpSimple/master
A new way to handle the spammers
Diffstat (limited to '')
-rw-r--r-- | server/src/commands/mod/dumb.js | 63 | ||||
-rw-r--r-- | server/src/commands/mod/speak.js | 43 |
2 files changed, 106 insertions, 0 deletions
diff --git a/server/src/commands/mod/dumb.js b/server/src/commands/mod/dumb.js new file mode 100644 index 0000000..ef2c5b2 --- /dev/null +++ b/server/src/commands/mod/dumb.js @@ -0,0 +1,63 @@ +/* + * 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 badClient = server.findSockets({ channel: socket.channel, nick: data.nick }); + + 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; + } + + let record = core.muzzledHashes[badClient.hash] = { + dumb:true + } + + if(data.allies && Array.isArray(data.allies)){ + record.allies = data.allies; + } + + server.broadcast({ + cmd: 'info', + text: `${socket.nick} muzzled ${data.nick} in ${socket.channel}, userhash: ${badClient.hash}` + }, { uType: 'mod' }); + +} + +exports.requiredData = ['nick']; + +exports.info = { + name: 'dumb', + usage: 'dumb {nick} [allies...]', + description: 'Cleanly disable a user messages and make him dumb' +}; diff --git a/server/src/commands/mod/speak.js b/server/src/commands/mod/speak.js new file mode 100644 index 0000000..422ad2c --- /dev/null +++ b/server/src/commands/mod/speak.js @@ -0,0 +1,43 @@ +/* + * Description: Pardon a dumb user to be able to speak again + * Author: simple + */ + + +exports.run = async (core, server, socket, data) => { + if (socket.uType == 'user') { + // ignore if not mod or admin + return; + } + + if (typeof data.ip !== 'string' && typeof data.hash !== 'string') { + server.reply({ + cmd: 'warn', + text: "hash:'targethash' or ip:'1.2.3.4' is required" + }, socket); + + return; + } + + let target; + + if (typeof data.ip === 'string') { + target = getSocketHash(data.ip); + } else { + target = data.hash; + } + + delete core.muzzledHashes[target]; + + server.broadcast({ + cmd: 'info', + text: `${socket.nick} unmuzzled : ${target}` + }, { uType: 'mod' }); + +} + +exports.info = { + name: 'speak', + usage: 'speak {[ip || hash]}', + description: 'Pardon a dumb user to be able to speak again' +}; |