diff --git a/client/index.html b/client/index.html index 362688ba..1b40bfce 100644 --- a/client/index.html +++ b/client/index.html @@ -554,6 +554,16 @@ +
+
+ /ban nick +
+
+

Ban (+b) a user from the current channel. + This can be a nickname or a hostmask.

+
+
+
/banlist @@ -799,6 +809,16 @@
+
+
+ /unban nick +
+
+

Unban (-b) a user from the current channel.

+ This can be a nickname or a hostmask.

+
+
+
/voice nick [...nick] diff --git a/client/js/constants.js b/client/js/constants.js index 546637fd..c9587709 100644 --- a/client/js/constants.js +++ b/client/js/constants.js @@ -3,6 +3,7 @@ const commands = [ "/away", "/back", + "/ban", "/banlist", "/close", "/connect", @@ -28,6 +29,7 @@ const commands = [ "/server", "/slap", "/topic", + "/unban", "/voice", "/whois" ]; diff --git a/src/client.js b/src/client.js index 0d3caffa..aa3b7045 100644 --- a/src/client.js +++ b/src/client.js @@ -36,6 +36,7 @@ var events = [ "whois" ]; var inputs = [ + "ban", "ctcp", "msg", "part", diff --git a/src/plugins/inputs/ban.js b/src/plugins/inputs/ban.js new file mode 100644 index 00000000..b6745652 --- /dev/null +++ b/src/plugins/inputs/ban.js @@ -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} ` + })); + + 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; + } +}; diff --git a/src/plugins/inputs/mode.js b/src/plugins/inputs/mode.js index 8395da15..4e1227ad 100644 --- a/src/plugins/inputs/mode.js +++ b/src/plugins/inputs/mode.js @@ -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]` @@ -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); }); diff --git a/src/plugins/irc-events/banlist.js b/src/plugins/irc-events/banlist.js index d45d81cc..fa5993ea 100644 --- a/src/plugins/irc-events/banlist.js +++ b/src/plugins/irc-events/banlist.js @@ -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,