hardlounge/server/plugins/inputs/notice.ts
Max Leiter dd05ee3a65
TypeScript and Vue 3 (#4559)
Co-authored-by: Eric Nemchik <eric@nemchik.com>
Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
2022-06-18 17:25:21 -07:00

45 lines
898 B
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(" ");
network.irc.notice(targetName, 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", {
nick: network.irc.user.nick,
target: targetName,
group: targetGroup,
message: message,
});
}
return true;
};
export default {
commands,
input,
};