fix: harden TeamSpeak detection and clean up departed speakers

This commit is contained in:
illusia committed 2026-10-17 14:55:25 +08:00
1 parent 84bdf63514
commit 180bfeb52f
11 files changed
+133 -10

No files matched your search

+9 -3
View File
@@ -152,8 +152,14 @@ export class TeamSpeakAdapter {
}
export function detectTeamSpeakProtocol(versionText: string): TeamSpeakProtocol | null {
const text = versionText.trim().toLocaleLowerCase();
if (/teamspeak\s*6|(?:^|\D)6\.\d+/.test(text)) return "ts6";
if (/teamspeak\s*3|(?:^|\D)3\.\d+/.test(text)) return "ts3";
const text = versionText.trim().toLowerCase();
// The `version` command starts with the server version, optionally preceded
// by the product name. Match only that leading major version: scanning the
// whole string mistakes TeamSpeak 3.6.7 for TeamSpeak 6.
const match = /^(?:teamspeak\s*)?(\d+)/.exec(text);
if (!match) return null;
const major = Number(match[1]);
if (major === 6) return "ts6";
if (major === 3) return "ts3";
return null;
}