thelounge/src/plugins/inputs/ban.js
Alistair McKinlay b03d01b6eb Add ban/unban command
Fixes #1073
2017-04-26 08:54:25 +01:00

45 lines
787 B
JavaScript

"use strict";
var Chan = require("../../models/chan");
var Msg = require("../../models/msg");
exports.commands = [
"ban",
"unban",
"banlist"
];
exports.input = function(network, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(this, new Msg({
type: Msg.Type.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: Msg.Type.ERROR,
text: `Usage: /${cmd} <nick>`
}));
return;
}
}
switch (cmd) {
case "ban":
network.irc.ban(chan.name, args[0]);
break;
case "unban":
network.irc.unban(chan.name, args[0]);
break;
case "banlist":
network.irc.banlist(chan.name);
break;
}
};