thelounge/server/plugins/inputs/ctcp.ts
Reto Brunner 3eb19135f5 wip: msg
2024-04-21 15:10:41 +02:00

38 lines
708 B
TypeScript

import Msg from "../../models/msg";
import {PluginInputHandler} from "./index";
import {MessageType} from "../../../shared/types/msg";
const commands = ["ctcp"];
const input: PluginInputHandler = function ({irc}, chan, cmd, args) {
if (args.length < 2) {
chan.pushMessage(
this,
new Msg({
type: MessageType.ERROR,
text: "Usage: /ctcp <nick> <ctcp_type>",
})
);
return;
}
const target = args.shift()!;
const type = args.shift()!;
chan.pushMessage(
this,
new Msg({
type: MessageType.CTCP_REQUEST,
ctcpMessage: `"${type}" to ${target}`,
from: chan.getUser(irc.user.nick),
})
);
irc.ctcpRequest(target, type, ...args);
};
export default {
commands,
input,
};