mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
Merge upstream/main into GreenTeaSpeak main to resolve PR #4 conflicts.
Keep TeaSpeak/GTS multi-tab work while integrating channel-password prompts and the Pulse theme. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
3db5d90d89
7 files changed
+719
-20
No files matched your search
@@ -134,7 +134,7 @@ wss.on("connection", (socket: WebSocket) => {
|
||||
case "switchChannel": {
|
||||
const channelId = Number(msg.channelId);
|
||||
if (Number.isFinite(channelId)) {
|
||||
await connection?.switchChannel(channelId);
|
||||
await connection?.switchChannel(channelId, msg.channelPassword);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -131,6 +131,7 @@ export type Ts3ConnectionEvent =
|
||||
| { type: "talkers"; clients: number[] }
|
||||
| { type: "disconnected"; reason: string }
|
||||
| { type: "error"; message: string }
|
||||
| { type: "channelPasswordRequired"; channelId: number }
|
||||
| ({ type: "serverLog" } & ServerLogEntry)
|
||||
| {
|
||||
type: "clientConnectionInfo";
|
||||
@@ -293,6 +294,7 @@ export class Ts3Connection {
|
||||
| { type: "talkers"; clients: number[] }
|
||||
| { type: "disconnected"; reason: string }
|
||||
| { type: "error"; message: string }
|
||||
| { type: "channelPasswordRequired"; channel_id: number }
|
||||
| ({ type: "serverLog" } & ServerLogEntry)
|
||||
| {
|
||||
type: "clientConnectionInfo";
|
||||
@@ -516,6 +518,8 @@ export class Ts3Connection {
|
||||
message: event.message,
|
||||
timestamp: event.timestamp,
|
||||
});
|
||||
} else if (event.type === "channelPasswordRequired") {
|
||||
this.emit({ type: "channelPasswordRequired", channelId: event.channel_id });
|
||||
} else {
|
||||
this.emit(event);
|
||||
}
|
||||
@@ -537,10 +541,13 @@ export class Ts3Connection {
|
||||
});
|
||||
}
|
||||
|
||||
async switchChannel(channelId: number): Promise<void> {
|
||||
async switchChannel(channelId: number, channelPassword?: string): Promise<void> {
|
||||
const id = Number(channelId);
|
||||
if (!Number.isFinite(id)) return;
|
||||
this.child?.stdin.write(`switch ${id}\n`);
|
||||
// The password travels base64-encoded on this line-based stdin protocol
|
||||
// so it can safely contain spaces or other characters.
|
||||
const passwordArg = channelPassword ? ` ${Buffer.from(channelPassword, "utf8").toString("base64")}` : "";
|
||||
this.child?.stdin.write(`switch ${id}${passwordArg}\n`);
|
||||
}
|
||||
|
||||
async getClientConnectionInfo(clientId: number): Promise<void> {
|
||||
|
||||
Reference in new issue
Block a user