From bac4a1f251e8c70ea8e5f30901c5b9f41b8f02af Mon Sep 17 00:00:00 2001 From: Darren Date: Mon, 1 Sep 2014 23:30:53 +0100 Subject: [PATCH] Correctly reading nicks from an IRC message prefix when without ident@host --- server/irc/commands/messaging.js | 4 ++-- server/irc/commands/registration.js | 4 ++++ server/irc/connection.js | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/irc/commands/messaging.js b/server/irc/commands/messaging.js index 6a44a9b..6f5b811 100644 --- a/server/irc/commands/messaging.js +++ b/server/irc/commands/messaging.js @@ -34,8 +34,8 @@ var handlers = { 'channel'; this.emit(namespace + ' ' + command.params[0] + ' notice', { - from_server: command.prefix ? true : false, - nick: command.nick || command.prefix || undefined, + from_server: command.prefix === this.irc_connection.server_name ? true : false, + nick: command.nick || undefined, ident: command.ident, hostname: command.hostname, target: command.params[0], diff --git a/server/irc/commands/registration.js b/server/irc/commands/registration.js index 4b58c40..024a036 100644 --- a/server/irc/commands/registration.js +++ b/server/irc/commands/registration.js @@ -10,6 +10,10 @@ module.exports = function AddCommandHandlers(command_controller) { var handlers = { RPL_WELCOME: function (command) { var nick = command.params[0]; + + // Get the server name so we know which messages are by the server in future + this.irc_connection.server_name = command.prefix; + this.cap_negotiation = false; this.emit('server ' + this.irc_connection.irc_host.hostname + ' connect', { nick: nick diff --git a/server/irc/connection.js b/server/irc/connection.js index c275feb..0c6f70c 100644 --- a/server/irc/connection.js +++ b/server/irc/connection.js @@ -892,8 +892,8 @@ function parseIrcLine(buffer_line) { msg_obj = { tags: tags, prefix: msg[2], - nick: msg[3], - ident: msg[4], + nick: msg[3] || msg[2], // Nick will be in the prefix slot if a full user mask is not used + ident: msg[4] || '', hostname: msg[5] || '', command: msg[6], params: msg[7] ? msg[7].split(/ +/) : [] -- 2.25.1