Add support for /ban without argument

This commit is contained in:
Simon Ser 2021-06-03 10:11:48 +02:00
parent 5004f6c89c
commit a4294975a2
3 changed files with 50 additions and 30 deletions

View File

@ -9,10 +9,7 @@ function getActiveClient(app) {
return app.clients.get(buf.network); return app.clients.get(buf.network);
} }
const ban = { function ban(app, args) {
usage: "<nick>",
description: "Bans a user from the channel",
execute: (app, args) => {
var nick = args[0]; var nick = args[0];
if (!nick) { if (!nick) {
throw new Error("Missing nick"); throw new Error("Missing nick");
@ -36,8 +33,7 @@ const ban = {
`*!${user}@${host}` `*!${user}@${host}`
]}); ]});
}); });
}, }
};
const join = { const join = {
usage: "<name>", usage: "<name>",
@ -84,7 +80,24 @@ function givemode(app, args, mode) {
} }
export default { export default {
"ban": ban, "ban": {
usage: "[nick]",
description: "Bans a user from the channel, or displays the current ban list",
execute: (app, args) => {
if (args.length == 0) {
var activeBuffer = app.state.buffers.get(app.state.activeBuffer);
if (!activeBuffer || !app.isChannel(activeBuffer.name)) {
throw new Error("Not in a channel");
}
getActiveClient(app).send({
command: "MODE",
params: [activeBuffer.name, "+b"],
});
} else {
return ban(app, args);
}
},
},
"buffer": { "buffer": {
usage: "<name>", usage: "<name>",
description: "Switch to a buffer", description: "Switch to a buffer",

View File

@ -898,6 +898,11 @@ export default class App extends Component {
} }
}); });
break; break;
case irc.RPL_BANLIST:
case irc.RPL_ENDOFBANLIST:
var channel = msg.params[1];
this.addMessage(netID, channel, msg);
break;
case "CAP": case "CAP":
case "AUTHENTICATE": case "AUTHENTICATE":
case "PING": case "PING":

View File

@ -17,6 +17,8 @@ export const RPL_TOPICWHOTIME = "333";
export const RPL_WHOREPLY = "352"; export const RPL_WHOREPLY = "352";
export const RPL_NAMREPLY = "353"; export const RPL_NAMREPLY = "353";
export const RPL_ENDOFNAMES = "366"; export const RPL_ENDOFNAMES = "366";
export const RPL_BANLIST = "367";
export const RPL_ENDOFBANLIST = "368";
export const RPL_MOTD = "372"; export const RPL_MOTD = "372";
export const RPL_MOTDSTART = "375"; export const RPL_MOTDSTART = "375";
export const RPL_ENDOFMOTD = "376"; export const RPL_ENDOFMOTD = "376";