<?php
ob_start();

$API_KEY = '821618580:AAE-T8rY9S9jqfmuUPKE01LasQbU5B7E4Qc';
define('API_KEY',$API_KEY);
function bot($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,$datas);
    $res = curl_exec($ch);
    if(curl_error($ch)){
        var_dump(curl_error($ch));
    }else{
        return json_decode($res);
    }
}



function SendMessage($chat_id,$text){
    bot('sendMessage',[
        'chat_id'=>$chat_id,
        'text'=>$text,
    ]);
}

function SendAction($chat_id, $action){
	bot('sendchataction',[
	'chat_id'=>$chat_id,
	'action'=>$action
	]);
	}
	


## Telegram Variables ##
$update = json_decode(file_get_contents('php://input'));
$message = $update->message;
$data = $update->callback_query->data;
$from_id = $message->from->id;
$chat_id = $message->chat->id;
$message_id = $message->message_id;
$document = $message->document;
$first_name = $message->from->first_name;
$last_name = $message->from->last_name;
$username = $message->from->username;
$text = $message->text;
$file = $update->message->document->file_id;
## Telegram Variables ##

bot('sendMessage',[
        'chat_id'=>$chat_id,
        'text'=>$text,
    ]);


?>