ExpinBot/.svn/pristine/b7/b751ab3a16b64fcb5dc3533887a...

26 lines
1.0 KiB
Plaintext

<?php
namespace App\Http\Controllers;
use App\Models\tg_Msg;
use App\Services\TgApi;
use App\Services\UserFun;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class TgController extends Controller
{
public function Msg($token,Request $request)
{
$data = $request->all();
// $data='{"update_id":240447110,"message":{"message_id":1356,"from":{"id":5909523353,"is_bot":false,"first_name":"流浪的","last_name":"阿江","username":"winchen1688","language_code":"zh-hans"},"chat":{"id":-937402821,"title":"易利机器人测试群","type":"group","all_members_are_administrators":true},"date":1745980807,"text":"@xiongia +2000","entities":[{"offset":0,"length":8,"type":"mention"}]}}';
$msg=UserFun::Json2Arr($data); //将JSON转换成一維扁平陣列
$msg['token']=$token;
$tgmsg=tg_Msg::storeFromWebhookJson($msg);
$chat_id=TgApi::GetChatInfo($msg);
return $chat_id;
return $tgmsg;
// return response()->json(['status' => 'ok']);
}
}