diff options
author | marzavec <admin@marzavec.com> | 2020-03-12 19:28:20 +0100 |
---|---|---|
committer | marzavec <admin@marzavec.com> | 2020-03-12 19:28:20 +0100 |
commit | 2b6e771383f4c6f392b32ce26e4d759b56791132 (patch) | |
tree | b8c1cefecbd7f5816a3fb5ddc4bdb6bdfe463ba2 /server/src/commands/mod/dumb.js | |
parent | Merge pull request #96 from MinusGix/fixKickHash (diff) | |
download | hackchat-2b6e771383f4c6f392b32ce26e4d759b56791132.tar.gz hackchat-2b6e771383f4c6f392b32ce26e4d759b56791132.zip |
Protocol Updates and Bug Fixes
Diffstat (limited to 'server/src/commands/mod/dumb.js')
-rw-r--r-- | server/src/commands/mod/dumb.js | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/server/src/commands/mod/dumb.js b/server/src/commands/mod/dumb.js index 51fc745..ba2886d 100644 --- a/server/src/commands/mod/dumb.js +++ b/server/src/commands/mod/dumb.js @@ -66,9 +66,9 @@ export async function run(core, server, socket, data) { // module hook functions export function initHooks(server) { - server.registerHook('in', 'chat', this.chatCheck.bind(this), 25); - server.registerHook('in', 'invite', this.inviteCheck.bind(this), 25); - // TODO: add whisper hook, need hook priorities todo finished first + server.registerHook('in', 'chat', this.chatCheck.bind(this), 10); + server.registerHook('in', 'invite', this.inviteCheck.bind(this), 10); + server.registerHook('in', 'whisper', this.whisperCheck.bind(this), 10); } // hook incoming chat commands, shadow-prevent chat if they are muzzled @@ -140,6 +140,34 @@ export function inviteCheck(core, server, socket, payload) { return payload; } +// shadow-prevent all whispers from muzzled users +export function whisperCheck(core, server, socket, payload) { + if (typeof payload.nick !== 'string') { + return false; + } + + if (typeof payload.text !== 'string') { + return false; + } + + if (core.muzzledHashes[socket.hash]) { + const targetNick = payload.nick; + + server.reply({ + cmd: 'info', + type: 'whisper', + text: `You whispered to @${targetNick}: ${payload.text}`, + }, socket); + + // blanket "spam" protection, may expose the ratelimiting lines from `chat` and use that, TODO: one day #lazydev + server.police.frisk(socket.address, 9); + + return false; + } + + return payload; +} + export const requiredData = ['nick']; export const info = { name: 'dumb', |