<?php 
require_once('../config.php');
$update = json_decode(file_get_contents('php://input'));

if(!$update) exit();

if(isset($update->message)){
    $messages = $update->message;
    $chat_id = $messages->chat->id;
    $chat_username = $messages->chat->title;
    $chat_usern = $messages->chat->username;
    $chat_fusername = $messages->from->username;
    $chat_fid = $messages->from->id;
    $chat_type = $messages->chat->type;
    $message_id = $messages->message_id;
    $text = $messages->text;
    $file_id = isset($messages->photo[0]->file_id) ? $messages->photo[0]->file_id : "";
    $datass = "";
}
// Removed callback_query handling to revert to URL-based button logic

$bott = $TGBO;
define('API_KEY',$TGBO);

function makereq($method,$datas=[]){
    $url = "https://api.telegram.org/bot".API_KEY."/".$method;
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($datas));
    $res = curl_exec($ch);
    return json_decode($res);
}

if($text && strpos($text, "/start") === 0){
    makereq('sendMessage',[
        'chat_id'=>$chat_id,
        'text'=>"Active.",
        'parse_mode'=>'MarkDown'
    ]); 
}

// This part seems to be related to admin panel checks and not direct bot actions, keeping as is.
$file="../Admin/load.json";
$ud=file_get_contents($file);
$udarray = json_decode($ud);

if(!$udarray){
    $udarray = (object) array();
}

// Simplified logic as callback_query is no longer handled here.
// The original logic for message handling is preserved.
// The critical part for the URL button issue is that Admin/tele.php should not interfere with direct URL calls.
?>
