mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 20:12:52 +08:00
fix: harden TeamSpeak detection and clean up departed speakers
This commit is contained in:
1 parent
84bdf63514
commit
180bfeb52f
11 files changed
+133
-10
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user