hardlounge/src/plugins/inputs/mode.js

62 lines
1.1 KiB
JavaScript
Raw Normal View History

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