Files
thelounge/server/plugins/inputs/notice.ts
Max Leiter d9236c80d8 lint
2026-04-18 11:38:35 -07:00

51 lines
1.2 KiB
TypeScript

import {PluginInputHandler} from "./index";
const commands = ["notice"];
const input: PluginInputHandler = function (network, chan, cmd, args) {
if (!args[1]) {
return;
}
let targetName = args[0];
let message = args.slice(1).join(" ");
const replyTo = this._pendingReplyTo;
const replyTags =
replyTo && network.serverOptions.supportsReply ? {"+reply": replyTo} : undefined;
network.irc.notice(targetName, message, replyTags);
// If the IRCd does not support echo-message, simulate the message
// being sent back to us.
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", {
nick: network.irc.user.nick,
target: targetName,
group: targetGroup,
message: message,
tags: replyTo ? {"+reply": replyTo} : undefined,
});
}
return true;
};
export default {
commands,
input,
};