Merge pull request #1077 from thelounge/yamanickill/1073-ban-unban
Add ban/unban command
This commit is contained in:
commit
e3bd30b05f
@ -554,6 +554,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="help-item">
|
||||
<div class="subject">
|
||||
<code>/ban nick</code>
|
||||
</div>
|
||||
<div class="description">
|
||||
<p>Ban (<code>+b</code>) a user from the current channel.
|
||||
This can be a nickname or a hostmask.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="help-item">
|
||||
<div class="subject">
|
||||
<code>/banlist</code>
|
||||
@ -799,6 +809,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="help-item">
|
||||
<div class="subject">
|
||||
<code>/unban nick</code>
|
||||
</div>
|
||||
<div class="description">
|
||||
<p>Unban (<code>-b</code>) a user from the current channel.</p>
|
||||
This can be a nickname or a hostmask.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="help-item">
|
||||
<div class="subject">
|
||||
<code>/voice nick [...nick]</code>
|
||||
|
@ -3,6 +3,7 @@
|
||||
const commands = [
|
||||
"/away",
|
||||
"/back",
|
||||
"/ban",
|
||||
"/banlist",
|
||||
"/close",
|
||||
"/connect",
|
||||
@ -28,6 +29,7 @@ const commands = [
|
||||
"/server",
|
||||
"/slap",
|
||||
"/topic",
|
||||
"/unban",
|
||||
"/voice",
|
||||
"/whois"
|
||||
];
|
||||
|
@ -36,6 +36,7 @@ var events = [
|
||||
"whois"
|
||||
];
|
||||
var inputs = [
|
||||
"ban",
|
||||
"ctcp",
|
||||
"msg",
|
||||
"part",
|
||||
|
44
src/plugins/inputs/ban.js
Normal file
44
src/plugins/inputs/ban.js
Normal file
@ -0,0 +1,44 @@
|
||||
"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;
|
||||
}
|
||||
};
|
@ -4,7 +4,6 @@ var Chan = require("../../models/chan");
|
||||
var Msg = require("../../models/msg");
|
||||
|
||||
exports.commands = [
|
||||
"banlist",
|
||||
"mode",
|
||||
"op",
|
||||
"deop",
|
||||
@ -14,10 +13,6 @@ exports.commands = [
|
||||
"devoice",
|
||||
];
|
||||
|
||||
const chanCommands = [
|
||||
"banlist"
|
||||
];
|
||||
|
||||
exports.input = function(network, chan, cmd, args) {
|
||||
if (cmd !== "mode") {
|
||||
if (chan.type !== Chan.Type.CHANNEL) {
|
||||
@ -29,7 +24,7 @@ exports.input = function(network, chan, cmd, args) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length === 0 && chanCommands.indexOf(cmd) === -1) {
|
||||
if (args.length === 0) {
|
||||
chan.pushMessage(this, new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
text: `Usage: /${cmd} <nick> [...nick]`
|
||||
@ -39,7 +34,6 @@ exports.input = function(network, chan, cmd, args) {
|
||||
}
|
||||
|
||||
const mode = {
|
||||
banlist: "+b",
|
||||
op: "+o",
|
||||
hop: "+h",
|
||||
voice: "+v",
|
||||
@ -48,9 +42,6 @@ exports.input = function(network, chan, cmd, args) {
|
||||
devoice: "-v"
|
||||
}[cmd];
|
||||
|
||||
if (chanCommands.indexOf(cmd) > -1 && args.length === 0) {
|
||||
network.irc.raw("MODE", chan.name, mode);
|
||||
}
|
||||
args.forEach(function(target) {
|
||||
network.irc.raw("MODE", chan.name, mode, target);
|
||||
});
|
||||
|
@ -9,7 +9,7 @@ module.exports = function(irc, network) {
|
||||
irc.on("banlist", function(banlist) {
|
||||
const channel = banlist.channel;
|
||||
const bans = banlist.bans;
|
||||
if (!bans) {
|
||||
if (!bans || bans.length === 0) {
|
||||
const msg = new Msg({
|
||||
time: Date.now(),
|
||||
type: Msg.Type.ERROR,
|
||||
|
Loading…
Reference in New Issue
Block a user