Skip to content

Commit

Permalink
fix: telegram bind
Browse files Browse the repository at this point in the history
  • Loading branch information
xboard committed Jan 18, 2025
1 parent 81ef1b8 commit 9973db2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/Plugins/Telegram/Commands/Bind.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@ public function handle($message, $match = []) {
}
$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('订阅地址无效');
}
Expand Down

0 comments on commit 9973db2

Please sign in to comment.