aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/core
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/commands/core')
-rw-r--r--server/src/commands/core/changenick.js42
-rw-r--r--server/src/commands/core/chat.js7
-rw-r--r--server/src/commands/core/invite.js9
-rw-r--r--server/src/commands/core/join.js2
-rw-r--r--server/src/commands/core/whisper.js3
5 files changed, 55 insertions, 8 deletions
diff --git a/server/src/commands/core/changenick.js b/server/src/commands/core/changenick.js
index 6cc967c..28d8de3 100644
--- a/server/src/commands/core/changenick.js
+++ b/server/src/commands/core/changenick.js
@@ -55,6 +55,8 @@ exports.run = async (core, server, socket, data) => {
}
// build join and leave notices
+ // TODO: this is a legacy client holdover, name changes in the future will
+ // have thieir own event
let leaveNotice = {
cmd: 'onlineRemove',
nick: socket.nick
@@ -81,11 +83,49 @@ exports.run = async (core, server, socket, data) => {
socket.nick = newNick;
};
+// module hook functions
+exports.initHooks = (server) => {
+ server.registerHook('in', 'chat', this.nickCheck);
+};
+
+// hooks chat commands checking for /whisper
+exports.nickCheck = (core, server, socket, payload) => {
+ if (typeof payload.text !== 'string') {
+ return false;
+ }
+
+ if (payload.text.startsWith('/nick')) {
+ let input = payload.text.split(' ');
+
+ // If there is no nickname target parameter
+ if (input[1] === undefined) {
+ server.reply({
+ cmd: 'warn',
+ text: 'Refer to `/help nick` for instructions on how to use this command.'
+ }, socket);
+
+ return false;
+ }
+
+ let newNick = input[1].replace(/@/g, '');
+
+ this.run(core, server, socket, {
+ cmd: 'changenick',
+ nick: newNick
+ });
+
+ return false;
+ }
+
+ return payload;
+};
+
// module meta
exports.requiredData = ['nick'];
exports.info = {
name: 'changenick',
description: 'This will change your current connections nickname',
usage: `
- API: { cmd: 'changenick', nick: '<new nickname>' }`
+ API: { cmd: 'changenick', nick: '<new nickname>' }
+ Text: /nick <new nickname>`
};
diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js
index 70b9876..6f5c6a0 100644
--- a/server/src/commands/core/chat.js
+++ b/server/src/commands/core/chat.js
@@ -90,14 +90,12 @@ exports.commandCheckOut = (core, server, socket, payload) => {
return payload;
}
+ // TODO: make emotes their own module/event #lazydev
if (payload.text.startsWith('//me ')) {
payload.text = payload.text.substr(1, payload.text.length);
return payload;
- }
-
- // TODO: make emotes their own module #lazydev
- if (payload.text.startsWith('/me ')) {
+ } else if (payload.text.startsWith('/me ')) {
let emote = payload.text.substr(4);
if (emote.trim() === '') {
emote = 'fails at life';
@@ -106,6 +104,7 @@ exports.commandCheckOut = (core, server, socket, payload) => {
let newPayload = {
cmd: 'info',
type: 'emote',
+ nick: payload.nick,
text: `@${payload.nick} ${emote}`
};
diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js
index f44779b..8374309 100644
--- a/server/src/commands/core/invite.js
+++ b/server/src/commands/core/invite.js
@@ -31,11 +31,16 @@ exports.run = async (core, server, socket, data) => {
// build and send invite
let payload = {
cmd: 'info',
+ type: 'invite',
+ from: socket.nick,
invite: channel,
text: `${socket.nick} invited you to ?${channel}`
};
- let inviteSent = server.broadcast( payload, { channel: socket.channel, nick: data.nick });
+ let inviteSent = server.broadcast( payload, {
+ channel: socket.channel,
+ nick: data.nick
+ });
// server indicates the user was not found
if (!inviteSent) {
@@ -48,6 +53,8 @@ exports.run = async (core, server, socket, data) => {
// reply with common channel
server.reply({
cmd: 'info',
+ type: 'invite',
+ invite: channel,
text: `You invited ${data.nick} to ?${channel}`
}, socket);
diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js
index 21badaf..8b6a971 100644
--- a/server/src/commands/core/join.js
+++ b/server/src/commands/core/join.js
@@ -32,7 +32,7 @@ exports.parseNickname = (core, data) => {
}
let password = nickArray[1];
-
+
if (hash(password + core.config.tripSalt) === core.config.adminTrip) {
userInfo.uType = 'admin';
userInfo.trip = 'Admin';
diff --git a/server/src/commands/core/whisper.js b/server/src/commands/core/whisper.js
index 7173ae9..672db93 100644
--- a/server/src/commands/core/whisper.js
+++ b/server/src/commands/core/whisper.js
@@ -85,13 +85,14 @@ exports.whisperCheck = (core, server, socket, payload) => {
if (payload.text.startsWith('/whisper')) {
let input = payload.text.split(' ');
+
// If there is no nickname target parameter
if (input[1] === undefined) {
server.reply({
cmd: 'warn',
text: 'Refer to `/help whisper` for instructions on how to use this command.'
}, socket);
-
+
return false;
}