From d64eac54ed9ac9e114e681f61f3b63b8700a9646 Mon Sep 17 00:00:00 2001 From: marzavec Date: Fri, 26 Oct 2018 08:26:36 -0500 Subject: added auto reply to whisper using /r text hook --- server/src/commands/core/whisper.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'server/src/commands') diff --git a/server/src/commands/core/whisper.js b/server/src/commands/core/whisper.js index 2ad2df0..e089b45 100644 --- a/server/src/commands/core/whisper.js +++ b/server/src/commands/core/whisper.js @@ -63,6 +63,8 @@ exports.run = async (core, server, socket, payload) => { text: `${socket.nick} whispered: ${text}` }, targetClient); + targetClient.whisperReply = socket.nick; + server.reply({ cmd: 'info', type: 'whisper', @@ -96,6 +98,29 @@ exports.whisperCheck = (core, server, socket, payload) => { return false; } + if (payload.text.startsWith('/r ')) { + if (typeof socket.whisperReply === 'undefined') { + server.reply({ + cmd: 'warn', + text: 'Cannot reply to nobody' + }, socket); + + return false; + } + + let input = payload.text.split(' '); + input.splice(0, 1); + let whisperText = input.join(' '); + + this.run(core, server, socket, { + cmd: 'whisper', + nick: socket.whisperReply, + text: whisperText + }); + + return false; + } + return payload; }; @@ -106,5 +131,6 @@ exports.info = { description: 'Display text on targets screen that only they can see', usage: ` API: { cmd: 'whisper', nick: '', text: '' } - Text: /whisper ` + Text: /whisper + Alt Text: /r ` }; -- cgit v1.2.1