mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
Add kick and ban to the client context menu
Wires up "Aus dem Channel kicken", "Vom Server kicken", and "Bannen" (previously disabled placeholders). Kick uses tsclientlib's typed Client::kick() builder; ban has no typed wrapper so it's built as a raw "banclient" command (same OutCommand::write_arg approach used for the connection-info requests). Both use send_with_result() so a missing-permission rejection surfaces as a visible error. "Channel-Gruppe zuweisen"/"Server-Gruppe zuweisen" remain disabled - they need the server's group list threaded through first, left for a follow-up. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
74f688aba8
commit
330ecccadb
6 files changed
+287
-3
No files matched your search
@@ -130,6 +130,18 @@ wss.on("connection", (socket: WebSocket) => {
|
||||
await connection?.getServerConnectionInfo();
|
||||
break;
|
||||
}
|
||||
case "kickFromChannel": {
|
||||
await connection?.kickFromChannel(msg.clientId, msg.reason ?? "");
|
||||
break;
|
||||
}
|
||||
case "kickFromServer": {
|
||||
await connection?.kickFromServer(msg.clientId, msg.reason ?? "");
|
||||
break;
|
||||
}
|
||||
case "banClient": {
|
||||
await connection?.banClient(msg.clientId, msg.seconds ?? 0, msg.reason ?? "");
|
||||
break;
|
||||
}
|
||||
case "disconnect": {
|
||||
await connection?.disconnect(msg.message ?? "");
|
||||
break;
|
||||
|
||||
@@ -312,6 +312,21 @@ export class Ts3Connection {
|
||||
this.child?.stdin.write(`serverconninfo\n`);
|
||||
}
|
||||
|
||||
async kickFromChannel(clientId: number, reason: string): Promise<void> {
|
||||
const sanitized = reason.replace(/[\r\n]+/g, " ").trim();
|
||||
this.child?.stdin.write(`kickchannel ${clientId} ${sanitized}\n`);
|
||||
}
|
||||
|
||||
async kickFromServer(clientId: number, reason: string): Promise<void> {
|
||||
const sanitized = reason.replace(/[\r\n]+/g, " ").trim();
|
||||
this.child?.stdin.write(`kickserver ${clientId} ${sanitized}\n`);
|
||||
}
|
||||
|
||||
async banClient(clientId: number, seconds: number, reason: string): Promise<void> {
|
||||
const sanitized = reason.replace(/[\r\n]+/g, " ").trim();
|
||||
this.child?.stdin.write(`banclient ${clientId} ${Math.max(0, Math.floor(seconds))} ${sanitized}\n`);
|
||||
}
|
||||
|
||||
async sendChatMessage(message: string): Promise<void> {
|
||||
const sanitized = message.replace(/[\r\n]+/g, " ").trim();
|
||||
if (sanitized) this.child?.stdin.write(`chat ${sanitized}\n`);
|
||||
|
||||
Reference in new issue
Block a user