From 30576accacc23e0985f22ee40cd83a590dbe78b7 Mon Sep 17 00:00:00 2001 From: "Nico B." Date: Thu, 6 Aug 2026 13:48:32 +0200 Subject: [PATCH] Support GreenTeaSpeak protocol identifiers Add GREENTEA_PROTO_IDENT and GREENTEA_MOTD_PREFIX constants to TeamSpeak3 and update ServerQuery, MockServerQuery, and ServerQuery\Reply to recognize GreenTeaSpeak protocol greetings and MOTD prefix. This allows the adapter to accept GreenTeaSpeak server initial greetings and strip its MOTD like existing TS3/TEA handling. --- src/Adapter/MockServerQuery.php | 2 +- src/Adapter/ServerQuery.php | 2 +- src/Adapter/ServerQuery/Reply.php | 2 +- src/TeamSpeak3.php | 10 ++++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Adapter/MockServerQuery.php b/src/Adapter/MockServerQuery.php index 3a4e71dc..92b8fc5b 100644 --- a/src/Adapter/MockServerQuery.php +++ b/src/Adapter/MockServerQuery.php @@ -26,7 +26,7 @@ protected function syn(): void $rdy = $this->getTransport()->readLine(); - if (!$rdy->startsWith(TeamSpeak3::TS3_PROTO_IDENT) && !$rdy->startsWith(TeamSpeak3::TEA_PROTO_IDENT) && !(defined("CUSTOM_PROTO_IDENT") && $rdy->startsWith(CUSTOM_PROTO_IDENT))) { + if (!$rdy->startsWith(TeamSpeak3::TS3_PROTO_IDENT) && !$rdy->startsWith(TeamSpeak3::TEA_PROTO_IDENT) && !$rdy->startsWith(TeamSpeak3::GREENTEA_PROTO_IDENT) && !(defined("CUSTOM_PROTO_IDENT") && $rdy->startsWith(CUSTOM_PROTO_IDENT))) { throw new AdapterException("invalid reply from the server (" . $rdy . ")"); } diff --git a/src/Adapter/ServerQuery.php b/src/Adapter/ServerQuery.php index e0ecde2c..d0243439 100644 --- a/src/Adapter/ServerQuery.php +++ b/src/Adapter/ServerQuery.php @@ -64,7 +64,7 @@ protected function syn(): void $rdy = $this->getTransport()->readLine(); - if (!$rdy->startsWith(TeamSpeak3::TS3_PROTO_IDENT) && !$rdy->startsWith(TeamSpeak3::TEA_PROTO_IDENT) && !(defined("CUSTOM_PROTO_IDENT") && $rdy->startsWith(CUSTOM_PROTO_IDENT))) { + if (!$rdy->startsWith(TeamSpeak3::TS3_PROTO_IDENT) && !$rdy->startsWith(TeamSpeak3::TEA_PROTO_IDENT) && !$rdy->startsWith(TeamSpeak3::GREENTEA_PROTO_IDENT) && !(defined("CUSTOM_PROTO_IDENT") && $rdy->startsWith(CUSTOM_PROTO_IDENT))) { throw new AdapterException("invalid reply from the server (" . $rdy . ")"); } diff --git a/src/Adapter/ServerQuery/Reply.php b/src/Adapter/ServerQuery/Reply.php index 68872f80..0209d99f 100644 --- a/src/Adapter/ServerQuery/Reply.php +++ b/src/Adapter/ServerQuery/Reply.php @@ -300,7 +300,7 @@ protected function fetchError(StringHelper $err): void protected function fetchReply(array $rpl): void { foreach ($rpl as $key => $val) { - if ($val->startsWith(TeamSpeak3::TS3_MOTD_PREFIX) || $val->startsWith(TeamSpeak3::TEA_MOTD_PREFIX) || (defined("CUSTOM_MOTD_PREFIX") && $val->startsWith(CUSTOM_MOTD_PREFIX))) { + if ($val->startsWith(TeamSpeak3::TS3_MOTD_PREFIX) || $val->startsWith(TeamSpeak3::TEA_MOTD_PREFIX) || $val->startsWith(TeamSpeak3::GREENTEA_MOTD_PREFIX) || (defined("CUSTOM_MOTD_PREFIX") && $val->startsWith(CUSTOM_MOTD_PREFIX))) { unset($rpl[$key]); } elseif ($val->startsWith(TeamSpeak3::EVENT)) { $this->evt[] = new Event($val, $this->con); diff --git a/src/TeamSpeak3.php b/src/TeamSpeak3.php index d54a49c2..e00705d4 100644 --- a/src/TeamSpeak3.php +++ b/src/TeamSpeak3.php @@ -69,6 +69,16 @@ class TeamSpeak3 */ public const TEA_MOTD_PREFIX = "Welcome"; + /** + * GreenTeaSpeak protocol welcome message. + */ + public const GREENTEA_PROTO_IDENT = "GreenTeaSpeak"; + + /** + * GreenTeaSpeak protocol greeting message prefix. + */ + public const GREENTEA_MOTD_PREFIX = "Welcome"; + /** * TeamSpeak 3 protocol error message prefix. */