mirror of
https://github.com/thelounge/thelounge
synced 2024-12-11 21:22:35 +00:00
Merge pull request #270 from thelounge/ircv3/echo-message
Add support for echo-message and znc.in/self-message caps
This commit is contained in:
commit
404bf2c4df
7 changed files with 43 additions and 26 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -16,11 +16,15 @@ exports.input = function(network, chan, cmd, args) {
|
|||
text = text || args.join(" ");
|
||||
|
||||
irc.say(chan.name, "\u0001ACTION " + text + "\u0001");
|
||||
|
||||
if (!network.irc.network.cap.isEnabled("echo-message")) {
|
||||
irc.emit("action", {
|
||||
nick: irc.user.nick,
|
||||
target: chan.name,
|
||||
message: text
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ exports.input = function(network, chan, cmd, args) {
|
|||
var msg = args.join(" ");
|
||||
irc.say(target, msg);
|
||||
|
||||
if (!network.irc.network.cap.isEnabled("echo-message")) {
|
||||
var channel = network.getChannel(target);
|
||||
if (typeof channel !== "undefined") {
|
||||
irc.emit("privmsg", {
|
||||
|
@ -27,6 +28,7 @@ exports.input = function(network, chan, cmd, args) {
|
|||
message: msg
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
|
|
@ -15,11 +15,13 @@ exports.input = function(network, chan, cmd, args) {
|
|||
targetChan = chan;
|
||||
}
|
||||
|
||||
if (!network.irc.network.cap.isEnabled("echo-message")) {
|
||||
irc.emit("notice", {
|
||||
nick: irc.user.nick,
|
||||
target: targetChan.name,
|
||||
message: message
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
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++;
|
||||
|
|
Loading…
Reference in a new issue