thelounge/src/plugins/inputs/notice.js

40 lines
812 B
JavaScript
Raw Normal View History

"use strict";
exports.commands = ["notice"];
exports.input = function (network, chan, cmd, args) {
if (!args[1]) {
2014-09-13 23:29:45 +02:00
return;
}
2016-01-17 22:18:43 +01:00
let targetName = args[0];
2018-01-11 12:33:36 +01:00
let message = args.slice(1).join(" ");
network.irc.notice(targetName, message);
2016-01-17 22:18:43 +01:00
2016-04-22 18:38:13 +02:00
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;
}
2018-01-11 12:33:36 +01:00
network.irc.emit("notice", {
nick: network.irc.user.nick,
target: targetName,
group: targetGroup,
message: message,
2016-04-22 18:38:13 +02:00
});
}
2016-03-06 10:24:56 +01:00
return true;
2014-09-13 23:29:45 +02:00
};