aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/core/invite.js
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2018-09-30 08:44:36 +0200
committermarzavec <admin@marzavec.com>2018-09-30 08:44:36 +0200
commitc719020e17cb1c98da55be6cc7efe0e50ab51ffa (patch)
tree4c1e7f05aec2b6a995e21d2bbecbb45c2ae14bd6 /server/src/commands/core/invite.js
parentMerge pull request #28 from henrywright/27 (diff)
downloadhackchat-c719020e17cb1c98da55be6cc7efe0e50ab51ffa.tar.gz
hackchat-c719020e17cb1c98da55be6cc7efe0e50ab51ffa.zip
Added hooks, modules and cleaned up code
Diffstat (limited to 'server/src/commands/core/invite.js')
-rw-r--r--server/src/commands/core/invite.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js
index d616193..f44779b 100644
--- a/server/src/commands/core/invite.js
+++ b/server/src/commands/core/invite.js
@@ -2,17 +2,17 @@
Description: Generates a semi-unique channel name then broadcasts it to each client
*/
+// module support functions
const verifyNickname = (nick) => /^[a-zA-Z0-9_]{1,24}$/.test(nick);
+// module main
exports.run = async (core, server, socket, data) => {
// check for spam
if (server._police.frisk(socket.remoteAddress, 2)) {
- server.reply({
+ return server.reply({
cmd: 'warn',
text: 'You are sending invites too fast. Wait a moment before trying again.'
}, socket);
-
- return;
}
// verify user input
@@ -34,16 +34,15 @@ exports.run = async (core, server, socket, data) => {
invite: channel,
text: `${socket.nick} invited you to ?${channel}`
};
+
let inviteSent = server.broadcast( payload, { channel: socket.channel, nick: data.nick });
// server indicates the user was not found
if (!inviteSent) {
- server.reply({
+ return server.reply({
cmd: 'warn',
text: 'Could not find user in channel'
}, socket);
-
- return;
}
// reply with common channel
@@ -56,10 +55,11 @@ exports.run = async (core, server, socket, data) => {
core.managers.stats.increment('invites-sent');
};
+// module meta
exports.requiredData = ['nick'];
-
exports.info = {
name: 'invite',
- usage: 'invite {nick}',
- description: 'Generates a unique (more or less) room name and passes it to two clients'
+ description: 'Generates a unique (more or less) room name and passes it to two clients',
+ usage: `
+ API: { cmd: 'invite', nick: '<target nickname>' }`
};