true, 'user_id' => $ChatInfo['result']['user']['id'], 'first_name' => $ChatInfo['result']['user']['first_name'] ?? null, 'username' => $ChatInfo['result']['user']['username'] ?? null, 'status' => $ChatInfo['result']['status'], // 例如 creator / administrator / member / left / kicked 'raw' => $ChatInfo['result'] // 可选:保留原始数据 ]; } else { // 获取失败,回传错误信息 return [ 'ok' => false, 'error' => $ChatInfo['error'] ?? '未知错误', 'raw' => $ChatInfo ]; } } public static function GetChatInfo($msg){ $ApiUrl= "https://api.telegram.org/bot{$msg['token']}/getChat?chat_id={$msg['message_chat_id']}"; $ChatInfo=UserFun::CurlGet($ApiUrl); if($ChatInfo['ok'] && isset($ChatInfo['result']['id'])){ $ApiUrl= "https://api.telegram.org/bot{$msg['token']}/getChatAdministrators?chat_id={$ChatInfo['result']['id']}"; $AdminInfo=UserFun::CurlGet($ApiUrl); if ($AdminInfo['ok'] && isset($AdminInfo['result'])) { foreach ($AdminInfo['result'] as $admin) { if (isset($admin['status']) && $admin['status'] === 'creator') { // 找到群主,提取 user_id $ChatInfo['result']['creator'] = $admin['user']['id']; break; } } } } return $ChatInfo; } public static function getMe($msg){ $ApiUrl= "https://api.telegram.org/bot{$msg['token']}/getMe"; $BotInfo=UserFun::CurlGet($ApiUrl); if($BotInfo['ok'] && isset($BotInfo['result']['id'])){ return [ 'success' => true, 'bot_id' => $BotInfo['result']['id'], 'username' => $BotInfo['result']['username'] ?? null, 'first_name' => $BotInfo['result']['first_name'] ?? null, 'can_join_groups' => $BotInfo['result']['can_join_groups'] ?? null, 'can_read_all_group_messages' => $BotInfo['result']['can_read_all_group_messages'] ?? null, 'supports_inline_queries' => $BotInfo['result']['supports_inline_queries'] ?? null, ]; } else { return [ 'success' => false, 'error' => $BotInfo['description'] ?? 'Unknown error', ]; } } }