diff --git a/commands.js b/commands.js index 390473a..25de7f2 100644 --- a/commands.js +++ b/commands.js @@ -9,35 +9,31 @@ function getActiveClient(app) { return app.clients.get(buf.network); } -const ban = { - usage: "", - description: "Bans a user from the channel", - execute: (app, args) => { - var nick = args[0]; - if (!nick) { - throw new Error("Missing nick"); - } - var activeBuffer = app.state.buffers.get(app.state.activeBuffer); - if (!activeBuffer || !app.isChannel(activeBuffer.name)) { - throw new Error("Not in a channel"); - } - var params = [activeBuffer.name, nick]; - if (args.length > 1) { - params.push(args.slice(1).join(" ")); - } - const 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: [ - activeBuffer.name, - "+b", - `*!${user}@${host}` - ]}); - }); - }, -}; +function ban(app, args) { + var nick = args[0]; + if (!nick) { + throw new Error("Missing nick"); + } + var activeBuffer = app.state.buffers.get(app.state.activeBuffer); + if (!activeBuffer || !app.isChannel(activeBuffer.name)) { + throw new Error("Not in a channel"); + } + var params = [activeBuffer.name, nick]; + if (args.length > 1) { + params.push(args.slice(1).join(" ")); + } + const 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: [ + activeBuffer.name, + "+b", + `*!${user}@${host}` + ]}); + }); +} const join = { usage: "", @@ -84,7 +80,24 @@ function givemode(app, args, mode) { } 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": { usage: "", description: "Switch to a buffer", diff --git a/components/app.js b/components/app.js index 53ae60c..e9c4122 100644 --- a/components/app.js +++ b/components/app.js @@ -898,6 +898,11 @@ export default class App extends Component { } }); break; + case irc.RPL_BANLIST: + case irc.RPL_ENDOFBANLIST: + var channel = msg.params[1]; + this.addMessage(netID, channel, msg); + break; case "CAP": case "AUTHENTICATE": case "PING": diff --git a/lib/irc.js b/lib/irc.js index fe9559a..eeae4d5 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -17,6 +17,8 @@ export const RPL_TOPICWHOTIME = "333"; export const RPL_WHOREPLY = "352"; export const RPL_NAMREPLY = "353"; export const RPL_ENDOFNAMES = "366"; +export const RPL_BANLIST = "367"; +export const RPL_ENDOFBANLIST = "368"; export const RPL_MOTD = "372"; export const RPL_MOTDSTART = "375"; export const RPL_ENDOFMOTD = "376";