mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
Add TS6 clientinit version middleware and fix playNext retry bug
clientinit compatibility: - Analyzed @honeybbq/teamspeak-client's clientinit: it already sends a clean 14-field payload without problematic fields (no badges, integrations, security_hash, etc.) - The key difference vs NeteaseTSBot is client_version: our library sends 3.5.3, NeteaseTSBot sends 3.6.2. TS6 servers may reject older versions. - Add ts6-compat.ts with CommandMiddleware that patches clientinit to use version 3.6.2 + matching ECDSA signature when connecting to detected TS6 servers - Middleware is automatically applied when detectedProtocol === "ts6" Pre-existing bug fix: - Fix playNext() in instance.ts where successful retry still fell through to player.stop(), killing the just-started playback https://claude.ai/code/session_016WhH58avUD9xy2dgADJgTh
This commit is contained in:
4 files changed
+143
-4
No files matched your search
@@ -10,14 +10,15 @@ import {
|
||||
type Identity,
|
||||
type TextMessage,
|
||||
type ClientInfo,
|
||||
type CommandMiddleware,
|
||||
} from "@honeybbq/teamspeak-client";
|
||||
import type { Logger } from "../logger.js";
|
||||
import {
|
||||
detectServerProtocol,
|
||||
type ServerProtocol,
|
||||
type ProtocolDetectResult,
|
||||
} from "./protocol-detect.js";
|
||||
import { TS6HttpQuery } from "./http-query.js";
|
||||
import { ts6VersionMiddleware } from "./ts6-compat.js";
|
||||
|
||||
export { CODEC_OPUS_MUSIC } from "./voice.js";
|
||||
export type { ServerProtocol } from "./protocol-detect.js";
|
||||
@@ -153,6 +154,13 @@ export class TS3Client extends EventEmitter {
|
||||
this.logger.warn(msg);
|
||||
};
|
||||
|
||||
// Apply TS6 version middleware if connecting to a TS6 server
|
||||
const commandMiddleware: CommandMiddleware[] = [];
|
||||
if (this.detectedProtocol === "ts6") {
|
||||
commandMiddleware.push(ts6VersionMiddleware("3.6.2"));
|
||||
this.logger.info("Applying TS6 compatibility: upgrading client_version to 3.6.2");
|
||||
}
|
||||
|
||||
this.client = new TS3FullClient(this.identity, addr, this.options.nickname, {
|
||||
logger: {
|
||||
debug: (msg) => this.logger.debug(msg),
|
||||
@@ -160,6 +168,7 @@ export class TS3Client extends EventEmitter {
|
||||
warn: throttledWarn,
|
||||
error: (msg) => this.logger.error(msg),
|
||||
},
|
||||
commandMiddleware,
|
||||
});
|
||||
|
||||
this.client.on("textMessage", (msg: TextMessage) => {
|
||||
|
||||
Reference in new issue
Block a user