Add support for echo-message cap

This commit is contained in:
Pavel Djundik 2016-04-22 19:38:13 +03:00
parent 116dbc07be
commit 84685acdcd
4 changed files with 29 additions and 17 deletions

View File

@ -174,6 +174,10 @@ Client.prototype.connect = function(args) {
} }
network.irc = new ircFramework.Client(); network.irc = new ircFramework.Client();
network.irc.requestCap([
"echo-message",
"znc.in/self-message",
]);
network.irc.connect({ network.irc.connect({
host: network.host, host: network.host,
port: network.port, port: network.port,

View File

@ -16,11 +16,15 @@ exports.input = function(network, chan, cmd, args) {
text = text || args.join(" "); text = text || args.join(" ");
irc.say(chan.name, "\u0001ACTION " + text + "\u0001"); irc.say(chan.name, "\u0001ACTION " + text + "\u0001");
irc.emit("action", {
nick: irc.user.nick, if (!network.irc.network.cap.isEnabled("echo-message")) {
target: chan.name, irc.emit("action", {
message: text nick: irc.user.nick,
}); target: chan.name,
message: text
});
}
break; break;
} }

View File

@ -19,13 +19,15 @@ exports.input = function(network, chan, cmd, args) {
var msg = args.join(" "); var msg = args.join(" ");
irc.say(target, msg); irc.say(target, msg);
var channel = network.getChannel(target); if (!network.irc.network.cap.isEnabled("echo-message")) {
if (typeof channel !== "undefined") { var channel = network.getChannel(target);
irc.emit("privmsg", { if (typeof channel !== "undefined") {
nick: irc.user.nick, irc.emit("privmsg", {
target: channel.name, nick: irc.user.nick,
message: msg target: channel.name,
}); message: msg
});
}
} }
return true; return true;

View File

@ -15,11 +15,13 @@ exports.input = function(network, chan, cmd, args) {
targetChan = chan; targetChan = chan;
} }
irc.emit("notice", { if (!network.irc.network.cap.isEnabled("echo-message")) {
nick: irc.user.nick, irc.emit("notice", {
target: targetChan.name, nick: irc.user.nick,
message: message target: targetChan.name,
}); message: message
});
}
return true; return true;
}; };