aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/core/invite.js
diff options
context:
space:
mode:
authorNeel Kamath <neelkamath@protonmail.com>2018-05-13 12:39:55 +0200
committerNeel Kamath <neelkamath@protonmail.com>2018-05-13 12:39:55 +0200
commit2bb5ced363b692a5696b176bc317fe525c0c05df (patch)
tree1532d9456c5f2b25ac05f7cec620a3af890eff83 /server/src/commands/core/invite.js
parentRe-add module documentation (diff)
downloadhackchat-2bb5ced363b692a5696b176bc317fe525c0c05df.tar.gz
hackchat-2bb5ced363b692a5696b176bc317fe525c0c05df.zip
Flatten
Diffstat (limited to 'server/src/commands/core/invite.js')
-rw-r--r--server/src/commands/core/invite.js65
1 files changed, 0 insertions, 65 deletions
diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js
deleted file mode 100644
index bcf9097..0000000
--- a/server/src/commands/core/invite.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Description: Generates a semi-unique channel name then broadcasts it to each client
-*/
-
-const verifyNickname = (nick) => {
- return /^[a-zA-Z0-9_]{1,24}$/.test(nick);
-};
-
-exports.run = async (core, server, socket, data) => {
- if (server._police.frisk(socket.remoteAddress, 2)) {
- server.reply({
- cmd: 'warn',
- text: 'You are sending invites too fast. Wait a moment before trying again.'
- }, socket);
-
- return;
- }
-
- if (typeof data.nick !== 'string') {
- return;
- }
-
- if (!verifyNickname(data.nick)) {
- // Not a valid nickname? Chances are we won't find them
- return;
- }
-
- if (data.nick == socket.nick) {
- // They invited themself
- return;
- }
-
- let channel = Math.random().toString(36).substr(2, 8);
-
- let payload = {
- cmd: 'info',
- invite: channel,
- text: `${socket.nick} invited you to ?${channel}`
- };
- let inviteSent = server.broadcast( payload, { channel: socket.channel, nick: data.nick });
-
- if (!inviteSent) {
- server.reply({
- cmd: 'warn',
- text: 'Could not find user in channel'
- }, socket);
-
- return;
- }
-
- server.reply({
- cmd: 'info',
- text: `You invited ${data.nick} to ?${channel}`
- }, socket);
-
- core.managers.stats.increment('invites-sent');
-};
-
-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'
-}; \ No newline at end of file