Merge pull request #3339 from thelounge/xpaw/statusmsg

Parse target group for sent messages when echo-message is not enabled
This commit is contained in:
Pavel Djundik 2019-08-03 22:14:24 +03:00 committed by GitHub
commit 65713e5509
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 10 deletions

View file

@ -16,7 +16,7 @@ function getTarget(cmd, args, chan) {
} }
exports.input = function(network, chan, cmd, args) { exports.input = function(network, chan, cmd, args) {
const targetName = getTarget(cmd, args, chan); let targetName = getTarget(cmd, args, chan);
if (cmd === "query") { if (cmd === "query") {
if (!targetName) { if (!targetName) {
@ -92,6 +92,14 @@ exports.input = function(network, chan, cmd, args) {
network.irc.say(targetName, msg); network.irc.say(targetName, msg);
if (!network.irc.network.cap.isEnabled("echo-message")) { if (!network.irc.network.cap.isEnabled("echo-message")) {
const parsedTarget = network.irc.network.extractTargetGroup(targetName);
let targetGroup;
if (parsedTarget) {
targetName = parsedTarget.target;
targetGroup = parsedTarget.target_group;
}
const channel = network.getChannel(targetName); const channel = network.getChannel(targetName);
if (typeof channel !== "undefined") { if (typeof channel !== "undefined") {
@ -99,7 +107,8 @@ exports.input = function(network, chan, cmd, args) {
nick: network.irc.user.nick, nick: network.irc.user.nick,
ident: network.irc.user.username, ident: network.irc.user.username,
hostname: network.irc.user.host, hostname: network.irc.user.host,
target: channel.name, target: targetName,
group: targetGroup,
message: msg, message: msg,
}); });
} }

View file

@ -7,20 +7,30 @@ exports.input = function(network, chan, cmd, args) {
return; return;
} }
let targetChan = network.getChannel(args[0]); let targetName = args[0];
let message = args.slice(1).join(" "); let message = args.slice(1).join(" ");
network.irc.notice(args[0], message); network.irc.notice(targetName, message);
if (typeof targetChan === "undefined") {
message = "{to " + args[0] + "} " + message;
targetChan = chan;
}
if (!network.irc.network.cap.isEnabled("echo-message")) { if (!network.irc.network.cap.isEnabled("echo-message")) {
let targetGroup;
const parsedTarget = network.irc.network.extractTargetGroup(targetName);
if (parsedTarget) {
targetName = parsedTarget.target;
targetGroup = parsedTarget.target_group;
}
const targetChan = network.getChannel(targetName);
if (typeof targetChan === "undefined") {
message = "{to " + args[0] + "} " + message;
}
network.irc.emit("notice", { network.irc.emit("notice", {
nick: network.irc.user.nick, nick: network.irc.user.nick,
target: targetChan.name, target: targetName,
group: targetGroup,
message: message, message: message,
}); });
} }