Add /unban

This commit is contained in:
Simon Ser 2021-06-03 10:25:33 +02:00
parent a2dc045683
commit 291c9e177d

View file

@ -17,26 +17,21 @@ function getActiveChannel(app) {
return activeBuffer.name; return activeBuffer.name;
} }
function ban(app, args) { function setUserHostMode(app, args, mode) {
var nick = args[0]; var nick = args[0];
if (!nick) { if (!nick) {
throw new Error("Missing nick"); throw new Error("Missing nick");
} }
var activeChannel = getActiveChannel(app); var activeChannel = getActiveChannel(app);
var params = [activeChannel, nick]; var client = getActiveClient(app);
if (args.length > 1) {
params.push(args.slice(1).join(" "));
}
const client = getActiveClient(app);
client.whois(nick).then((whois) => { client.whois(nick).then((whois) => {
const info = whois[irc.RPL_WHOISUSER].params; const info = whois[irc.RPL_WHOISUSER].params;
const user = info[2]; const user = info[2];
const host = info[3]; const host = info[3];
client.send({ command: "MODE", params: [ client.send({
activeChannel, command: "MODE",
"+b", params: [activeChannel, mode, `*!${user}@${host}`],
`*!${user}@${host}` });
]});
}); });
} }
@ -91,7 +86,7 @@ export default {
params: [activeChannel, "+b"], params: [activeChannel, "+b"],
}); });
} else { } else {
return ban(app, args); return setUserHostMode(app, args, "+b");
} }
}, },
}, },
@ -321,6 +316,13 @@ export default {
getActiveClient(app).send({ command: "TOPIC", params }); getActiveClient(app).send({ command: "TOPIC", params });
}, },
}, },
"unban": {
usage: "<nick>",
description: "Remove a user from the ban list",
execute: (app, args) => {
return setUserHostMode(app, args, "-b");
},
},
"voice": { "voice": {
usage: "<nick>", usage: "<nick>",
description: "Gives a user voiced status on this channel", description: "Gives a user voiced status on this channel",