From 9973db24d08837ba9229786cd8b2e70ca6d9d9a3 Mon Sep 17 00:00:00 2001 From: xboard Date: Sat, 18 Jan 2025 17:21:31 +0800 Subject: [PATCH] fix: telegram bind --- app/Plugins/Telegram/Commands/Bind.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Plugins/Telegram/Commands/Bind.php b/app/Plugins/Telegram/Commands/Bind.php index 93b62b8..303b778 100644 --- a/app/Plugins/Telegram/Commands/Bind.php +++ b/app/Plugins/Telegram/Commands/Bind.php @@ -17,8 +17,19 @@ class Bind extends Telegram { } $subscribeUrl = $message->args[0]; $subscribeUrl = parse_url($subscribeUrl); - parse_str($subscribeUrl['query'], $query); - $token = $query['token']; + + // 首先尝试从查询参数获取token + $token = null; + if (isset($subscribeUrl['query'])) { + parse_str($subscribeUrl['query'], $query); + $token = $query['token'] ?? null; + } + + if (!$token && isset($subscribeUrl['path'])) { + $pathParts = explode('/', trim($subscribeUrl['path'], '/')); + $token = end($pathParts); + } + if (!$token) { throw new ApiException('订阅地址无效'); }