From 291c9e177da3f7155f122f375ea36721e7dd19ad Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 3 Jun 2021 10:25:33 +0200 Subject: [PATCH] Add /unban --- commands.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/commands.js b/commands.js index aa7b225..d5f5f66 100644 --- a/commands.js +++ b/commands.js @@ -17,26 +17,21 @@ function getActiveChannel(app) { return activeBuffer.name; } -function ban(app, args) { +function setUserHostMode(app, args, mode) { var nick = args[0]; if (!nick) { throw new Error("Missing nick"); } var activeChannel = getActiveChannel(app); - var params = [activeChannel, nick]; - if (args.length > 1) { - params.push(args.slice(1).join(" ")); - } - const client = getActiveClient(app); + var client = getActiveClient(app); client.whois(nick).then((whois) => { const info = whois[irc.RPL_WHOISUSER].params; const user = info[2]; const host = info[3]; - client.send({ command: "MODE", params: [ - activeChannel, - "+b", - `*!${user}@${host}` - ]}); + client.send({ + command: "MODE", + params: [activeChannel, mode, `*!${user}@${host}`], + }); }); } @@ -91,7 +86,7 @@ export default { params: [activeChannel, "+b"], }); } else { - return ban(app, args); + return setUserHostMode(app, args, "+b"); } }, }, @@ -321,6 +316,13 @@ export default { getActiveClient(app).send({ command: "TOPIC", params }); }, }, + "unban": { + usage: "", + description: "Remove a user from the ban list", + execute: (app, args) => { + return setUserHostMode(app, args, "-b"); + }, + }, "voice": { usage: "", description: "Gives a user voiced status on this channel",