thelounge/server/plugins/inputs/ban.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

53 lines
1,014 B
TypeScript

import {ChanType} from "../../models/chan";
import Msg, {MessageType} from "../../models/msg";
import {PluginInputHandler} from "./index";
const commands = ["ban", "unban", "banlist", "kickban"];
const input: PluginInputHandler = function ({irc}, chan, cmd, args) {
if (chan.type !== ChanType.CHANNEL) {
chan.pushMessage(
this,
new Msg({
type: MessageType.ERROR,
text: `${cmd} command can only be used in channels.`,
})
);
return;
}
if (cmd !== "banlist" && args.length === 0) {
if (args.length === 0) {
chan.pushMessage(
this,
new Msg({
type: MessageType.ERROR,
text: `Usage: /${cmd} <nick>`,
})
);
return;
}
}
switch (cmd) {
case "kickban":
irc.raw("KICK", chan.name, args[0], args.slice(1).join(" "));
// fall through
case "ban":
irc.ban(chan.name, args[0]);
break;
case "unban":
irc.unban(chan.name, args[0]);
break;
case "banlist":
irc.banlist(chan.name);
break;
}
};
export default {
commands,
input,
};