aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/mod/dumb.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/commands/mod/dumb.js')
-rw-r--r--server/src/commands/mod/dumb.js34
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',