From 92cc130e2bcf4522c274c9d5058074ef2dd61d92 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 20 Mar 2016 18:46:08 +0200 Subject: [PATCH] Always send notices that are not targeted at us into the server window --- src/plugins/irc-events/message.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/plugins/irc-events/message.js b/src/plugins/irc-events/message.js index 42a7aa9d..da5c1467 100644 --- a/src/plugins/irc-events/message.js +++ b/src/plugins/irc-events/message.js @@ -7,6 +7,12 @@ module.exports = function(irc, network) { var config = Helper.getConfig(); irc.on("notice", function(data) { + // Some servers send notices without any nickname + if (!data.nick) { + data.from_server = true; + data.nick = network.host; + } + data.type = Msg.Type.NOTICE; handleMessage(data); }); @@ -27,23 +33,30 @@ module.exports = function(irc, network) { chan = network.channels[0]; } else { var target = data.target; + var targetedAtUser = false; // If the message is targeted at us, use sender as target instead if (target.toLowerCase() === irc.user.nick.toLowerCase()) { + targetedAtUser = true; target = data.nick; } var chan = network.getChannel(target); if (typeof chan === "undefined") { - chan = new Chan({ - type: Chan.Type.QUERY, - name: target - }); - network.channels.push(chan); - client.emit("join", { - network: network.id, - chan: chan - }); + // Send notices that are not targeted at us into the server window + if (data.type === Msg.Type.NOTICE && !targetedAtUser) { + chan = network.channels[0]; + } else { + chan = new Chan({ + type: Chan.Type.QUERY, + name: target + }); + network.channels.push(chan); + client.emit("join", { + network: network.id, + chan: chan + }); + } } }