mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 19:05:01 -05:00
Implement /kick and KICK handling in buffers
This commit is contained in:
parent
1d983bd142
commit
d34bff9ed6
3 changed files with 37 additions and 0 deletions
16
commands.js
16
commands.js
|
@ -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",
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue