2022-06-18 20:25:21 -04:00
|
|
|
import {PluginInputHandler} from "./index";
|
2016-10-09 15:14:02 -04:00
|
|
|
|
2022-06-18 20:25:21 -04:00
|
|
|
const commands = ["notice"];
|
2016-03-14 00:21:42 -04:00
|
|
|
|
2022-06-18 20:25:21 -04:00
|
|
|
const input: PluginInputHandler = function (network, chan, cmd, args) {
|
2016-03-14 00:21:42 -04:00
|
|
|
if (!args[1]) {
|
2014-09-13 17:29:45 -04:00
|
|
|
return;
|
|
|
|
}
|
2016-01-17 16:18:43 -05:00
|
|
|
|
2019-07-31 17:16:00 -04:00
|
|
|
let targetName = args[0];
|
2018-01-11 06:33:36 -05:00
|
|
|
let message = args.slice(1).join(" ");
|
|
|
|
|
2019-07-31 17:16:00 -04:00
|
|
|
network.irc.notice(targetName, message);
|
2016-01-17 16:18:43 -05:00
|
|
|
|
2016-04-22 12:38:13 -04:00
|
|
|
if (!network.irc.network.cap.isEnabled("echo-message")) {
|
2019-07-31 17:16:00 -04:00
|
|
|
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 06:33:36 -05:00
|
|
|
network.irc.emit("notice", {
|
|
|
|
nick: network.irc.user.nick,
|
2019-07-31 17:16:00 -04:00
|
|
|
target: targetName,
|
|
|
|
group: targetGroup,
|
2017-11-15 01:35:15 -05:00
|
|
|
message: message,
|
2016-04-22 12:38:13 -04:00
|
|
|
});
|
|
|
|
}
|
2016-03-06 04:24:56 -05:00
|
|
|
|
|
|
|
return true;
|
2014-09-13 17:29:45 -04:00
|
|
|
};
|
2022-06-18 20:25:21 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
commands,
|
|
|
|
input,
|
|
|
|
};
|