ExpinBot/.svn/pristine/56/56c4b9495311ec5ad38e611d2fd...

26 lines
962 B
Plaintext

<?php
namespace App\Services;
class TgApi{
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;
}
}