2016-10-09 15:14:02 -04:00
|
|
|
"use strict";
|
|
|
|
|
2016-10-08 11:11:18 -04:00
|
|
|
var Chan = require("../../models/chan");
|
|
|
|
var Msg = require("../../models/msg");
|
|
|
|
|
|
|
|
exports.commands = [
|
|
|
|
"mode",
|
|
|
|
"op",
|
|
|
|
"deop",
|
|
|
|
"hop",
|
|
|
|
"dehop",
|
|
|
|
"voice",
|
|
|
|
"devoice",
|
|
|
|
];
|
2015-09-30 18:39:57 -04:00
|
|
|
|
2016-10-08 11:11:18 -04:00
|
|
|
exports.input = function(network, chan, cmd, args) {
|
2015-09-30 18:39:57 -04:00
|
|
|
if (cmd !== "mode") {
|
2016-10-08 11:11:18 -04: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.`
|
|
|
|
}));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-24 06:40:53 -04:00
|
|
|
if (args.length === 0) {
|
2016-10-08 11:11:18 -04:00
|
|
|
chan.pushMessage(this, new Msg({
|
|
|
|
type: Msg.Type.ERROR,
|
|
|
|
text: `Usage: /${cmd} <nick> [...nick]`
|
|
|
|
}));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const mode = {
|
2016-10-09 04:54:44 -04:00
|
|
|
op: "+o",
|
2016-10-08 11:11:18 -04:00
|
|
|
hop: "+h",
|
2016-10-09 04:54:44 -04:00
|
|
|
voice: "+v",
|
|
|
|
deop: "-o",
|
2016-10-08 11:11:18 -04:00
|
|
|
dehop: "-h",
|
2016-10-09 04:54:44 -04:00
|
|
|
devoice: "-v"
|
2014-09-13 17:29:45 -04:00
|
|
|
}[cmd];
|
2016-10-08 11:11:18 -04:00
|
|
|
|
|
|
|
args.forEach(function(target) {
|
|
|
|
network.irc.raw("MODE", chan.name, mode, target);
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args.length === 0 || args[0][0] === "+" || args[0][0] === "-") {
|
|
|
|
args.unshift(chan.type === Chan.Type.CHANNEL || chan.type === Chan.Type.QUERY ? chan.name : network.nick);
|
2014-09-13 17:29:45 -04:00
|
|
|
}
|
2016-03-08 08:36:25 -05:00
|
|
|
|
2016-10-08 11:11:18 -04:00
|
|
|
args.unshift("MODE");
|
2016-03-06 04:24:56 -05:00
|
|
|
|
2016-10-08 11:11:18 -04:00
|
|
|
network.irc.raw.apply(network.irc, args);
|
2014-09-13 17:29:45 -04:00
|
|
|
};
|