diff --git a/client/js/lounge.js b/client/js/lounge.js index a1068eb6..ad2194c8 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -770,8 +770,7 @@ $(function() { } var button = sidebar.find(".chan[data-target='" + target + "']"); - var isQuery = button.hasClass("query"); - if (msg.type === "invite" || msg.highlight || isQuery || (options.notifyAllMessages && msg.type === "message")) { + if (msg.highlight || (options.notifyAllMessages && msg.type === "message")) { if (!document.hasFocus() || !$(target).hasClass("active")) { if (options.notification) { pop.play(); @@ -787,7 +786,7 @@ $(function() { body = msg.from + " invited you to " + msg.channel; } else { title = msg.from; - if (!isQuery) { + if (!button.hasClass("query")) { title += " (" + button.data("title").trim() + ")"; } title += " says:"; @@ -830,7 +829,7 @@ $(function() { var i = (badge.data("count") || 0) + 1; badge.data("count", i); badge.html(i > 999 ? (i / 1000).toFixed(1) + "k" : i); - if (msg.highlight || isQuery) { + if (msg.highlight) { badge.addClass("highlight"); } } diff --git a/src/client.js b/src/client.js index 561492ce..3de28f23 100644 --- a/src/client.js +++ b/src/client.js @@ -170,6 +170,10 @@ Client.prototype.connect = function(args) { } network.irc = new ircFramework.Client(); + network.irc.requestCap([ + "echo-message", + "znc.in/self-message", + ]); network.irc.connect({ host: network.host, port: network.port, diff --git a/src/plugins/inputs/action.js b/src/plugins/inputs/action.js index 4f8376ce..986493f6 100644 --- a/src/plugins/inputs/action.js +++ b/src/plugins/inputs/action.js @@ -16,11 +16,15 @@ exports.input = function(network, chan, cmd, args) { text = text || args.join(" "); irc.say(chan.name, "\u0001ACTION " + text + "\u0001"); - irc.emit("action", { - nick: irc.user.nick, - target: chan.name, - message: text - }); + + if (!network.irc.network.cap.isEnabled("echo-message")) { + irc.emit("action", { + nick: irc.user.nick, + target: chan.name, + message: text + }); + } + break; } diff --git a/src/plugins/inputs/msg.js b/src/plugins/inputs/msg.js index a562b607..5fb0dd14 100644 --- a/src/plugins/inputs/msg.js +++ b/src/plugins/inputs/msg.js @@ -19,13 +19,15 @@ exports.input = function(network, chan, cmd, args) { var msg = args.join(" "); irc.say(target, msg); - var channel = network.getChannel(target); - if (typeof channel !== "undefined") { - irc.emit("privmsg", { - nick: irc.user.nick, - target: channel.name, - message: msg - }); + if (!network.irc.network.cap.isEnabled("echo-message")) { + var channel = network.getChannel(target); + if (typeof channel !== "undefined") { + irc.emit("privmsg", { + nick: irc.user.nick, + target: channel.name, + message: msg + }); + } } return true; diff --git a/src/plugins/inputs/notice.js b/src/plugins/inputs/notice.js index 33aeda00..aa20f237 100644 --- a/src/plugins/inputs/notice.js +++ b/src/plugins/inputs/notice.js @@ -15,11 +15,13 @@ exports.input = function(network, chan, cmd, args) { targetChan = chan; } - irc.emit("notice", { - nick: irc.user.nick, - target: targetChan.name, - message: message - }); + if (!network.irc.network.cap.isEnabled("echo-message")) { + irc.emit("notice", { + nick: irc.user.nick, + target: targetChan.name, + message: message + }); + } return true; }; diff --git a/src/plugins/irc-events/invite.js b/src/plugins/irc-events/invite.js index f13c8f3e..2d5a6181 100644 --- a/src/plugins/irc-events/invite.js +++ b/src/plugins/irc-events/invite.js @@ -14,6 +14,7 @@ module.exports = function(irc, network) { from: data.nick, invited: data.invited, channel: data.channel, + highlight: true, invitedYou: data.invited === irc.user.nick }); chan.pushMessage(client, msg); diff --git a/src/plugins/irc-events/message.js b/src/plugins/irc-events/message.js index 3d18cff3..0689b5a8 100644 --- a/src/plugins/irc-events/message.js +++ b/src/plugins/irc-events/message.js @@ -26,6 +26,9 @@ module.exports = function(irc, network) { }); function handleMessage(data) { + var highlight = false; + var self = data.nick === irc.user.nick; + // Server messages go to server window, no questions asked if (data.from_server) { chan = network.channels[0]; @@ -43,6 +46,7 @@ module.exports = function(irc, network) { if (data.type === Msg.Type.NOTICE) { chan = network.channels[0]; } else { + highlight = !self; chan = new Chan({ type: Chan.Type.QUERY, name: target @@ -56,13 +60,14 @@ module.exports = function(irc, network) { } } - var self = data.nick === irc.user.nick; - + // Query messages (unless self) always highlight // Self messages are never highlighted // Non-self messages are highlighted as soon as the nick is detected - var highlight = !self && data.message.split(" ").some(function(w) { - return (w.replace(/^@/, "").toLowerCase().indexOf(irc.user.nick.toLowerCase()) === 0); - }); + if (!highlight && !self) { + highlight = data.message.split(" ").some(function(w) { + return (w.replace(/^@/, "").toLowerCase().indexOf(irc.user.nick.toLowerCase()) === 0); + }); + } if (!self && chan.id !== client.activeChannel) { chan.unread++;