2022-06-19 00:25:21 +00:00
|
|
|
import {ChanType} from "../../models/chan";
|
|
|
|
import Msg, {MessageType} from "../../models/msg";
|
|
|
|
import {PluginInputHandler} from "./index";
|
2017-04-24 10:40:53 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
const commands = ["ban", "unban", "banlist", "kickban"];
|
2017-04-24 10:40:53 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
const input: PluginInputHandler = function ({irc}, chan, cmd, args) {
|
|
|
|
if (chan.type !== ChanType.CHANNEL) {
|
2019-07-17 09:33:59 +00:00
|
|
|
chan.pushMessage(
|
|
|
|
this,
|
|
|
|
new Msg({
|
2022-06-19 00:25:21 +00:00
|
|
|
type: MessageType.ERROR,
|
2019-07-17 09:33:59 +00:00
|
|
|
text: `${cmd} command can only be used in channels.`,
|
|
|
|
})
|
|
|
|
);
|
2017-04-24 10:40:53 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd !== "banlist" && args.length === 0) {
|
|
|
|
if (args.length === 0) {
|
2019-07-17 09:33:59 +00:00
|
|
|
chan.pushMessage(
|
|
|
|
this,
|
|
|
|
new Msg({
|
2022-06-19 00:25:21 +00:00
|
|
|
type: MessageType.ERROR,
|
2019-07-17 09:33:59 +00:00
|
|
|
text: `Usage: /${cmd} <nick>`,
|
|
|
|
})
|
|
|
|
);
|
2017-04-24 10:40:53 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cmd) {
|
2021-11-18 10:00:40 +00:00
|
|
|
case "kickban":
|
|
|
|
irc.raw("KICK", chan.name, args[0], args.slice(1).join(" "));
|
|
|
|
// fall through
|
2019-07-17 09:33:59 +00:00
|
|
|
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;
|
2017-04-24 10:40:53 +00:00
|
|
|
}
|
|
|
|
};
|
2022-06-19 00:25:21 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
commands,
|
|
|
|
input,
|
|
|
|
};
|