diff options
author | marzavec <admin@marzavec.com> | 2018-10-26 15:26:36 +0200 |
---|---|---|
committer | marzavec <admin@marzavec.com> | 2018-10-26 15:26:36 +0200 |
commit | d64eac54ed9ac9e114e681f61f3b63b8700a9646 (patch) | |
tree | 25f49a0f95e9d0a67319fa7f96ba9db4dd817ef8 /server/src/commands/core | |
parent | removed frontpage links, updated wording (diff) | |
download | hackchat-d64eac54ed9ac9e114e681f61f3b63b8700a9646.tar.gz hackchat-d64eac54ed9ac9e114e681f61f3b63b8700a9646.zip |
added auto reply to whisper using /r text hook
Diffstat (limited to 'server/src/commands/core')
-rw-r--r-- | server/src/commands/core/whisper.js | 28 |
1 files changed, 27 insertions, 1 deletions
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: '<target name>', text: '<text to whisper>' } - Text: /whisper <target name> <text to whisper>` + Text: /whisper <target name> <text to whisper> + Alt Text: /r <text to whisper, this will auto reply to the last person who whispered to you>` }; |