thelounge/src/plugins/inputs/ban.js

45 lines
764 B
JavaScript
Raw Normal View History

2017-04-24 12:40:53 +02:00
"use strict";
var Chan = require("../../models/chan");
var Msg = require("../../models/msg");
exports.commands = [
"ban",
"unban",
"banlist",
2017-04-24 12:40:53 +02:00
];
exports.input = function({irc}, chan, cmd, args) {
2017-04-24 12:40:53 +02:00
if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels.`,
2017-04-24 12:40:53 +02:00
}));
return;
}
if (cmd !== "banlist" && args.length === 0) {
if (args.length === 0) {
chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: `Usage: /${cmd} <nick>`,
2017-04-24 12:40:53 +02:00
}));
return;
}
}
switch (cmd) {
case "ban":
irc.ban(chan.name, args[0]);
2017-04-24 12:40:53 +02:00
break;
case "unban":
irc.unban(chan.name, args[0]);
2017-04-24 12:40:53 +02:00
break;
case "banlist":
irc.banlist(chan.name);
2017-04-24 12:40:53 +02:00
break;
}
};