mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 14:00:21 +00:00
dd05ee3a65
Co-authored-by: Eric Nemchik <eric@nemchik.com> Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
53 lines
1,014 B
TypeScript
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,
|
|
};
|