Implement /kick and KICK handling in buffers

This commit is contained in:
Drew DeVault 2021-05-26 19:28:24 -04:00 committed by Simon Ser
parent 1d983bd142
commit d34bff9ed6
3 changed files with 37 additions and 0 deletions

View file

@ -56,6 +56,22 @@ export default {
getActiveClient(app).send({ command: "JOIN", params: [channel] });
},
},
"kick": {
usage: "<user>",
description: "Remove a user from the channel",
execute: (app, args) => {
var user = args[0];
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, user];
if (args.length > 1) {
params.push(args.slice(1).join(" "));
}
getActiveClient(app).send({ command: "KICK", params });
},
},
"me": {
usage: "<action>",
description: "Send an action message to the current buffer",

View file

@ -690,6 +690,22 @@ export default class App extends Component {
});
this.addMessage(netID, channel, msg);
if (msg.prefix.name == client.nick) {
this.receipts.delete(channel);
this.saveReceipts();
}
break;
case "KICK":
var channel = msg.params[0];
var user = msg.params[1];
this.setBufferState({ network: netID, name: channel }, (buf) => {
var members = new Map(buf.members);
members.delete(user);
return { members };
});
this.addMessage(netID, channel, msg);
if (msg.prefix.name == client.nick) {
this.receipts.delete(channel);
this.saveReceipts();

View file

@ -94,6 +94,11 @@ class LogLine extends Component {
${createNick(msg.prefix.name)} has left
`;
break;
case "KICK":
content = html`
${createNick(msg.params[1])} was kicked by ${createNick(msg.prefix.name)} (${msg.params.slice(2)})
`;
break;
case "QUIT":
content = html`
${createNick(msg.prefix.name)} has quit