Untitled

 avatar
unknown
plain_text
3 years ago
1.0 kB
5
Indexable
<?php
ini_set ('display_errors', true);
$content = file_get_contents("php://input");

$log_file_path = 'log.txt';

if (is_file ($log_file_path)){
    $old_log = file_get_contents ($log_file_path);
}else{
    $old_log = '';
}
$new_log = $old_log .  PHP_EOL . $content;
file_put_contents ($log_file_path, $new_log);



$update = json_decode($content,true);

$chat_id = $update["message"]['chat']['id'];
$text = $update["message"]['text'];



// Change response (Text) here:
$response = '';
if ($text == 'salam'){
    $response = 'Salam chetori?';
}else if ($text == 'bye'){
    $response = 'Khodafez ):';
}else{
    $response = 'Chi migi?' . PHP_EOL . 'chimigi to chiye?' . PHP_EOL . $text;
}





$response = urlencode ($response);
$url = 'https://api.telegram.org/bot5724544375:AAHZaxveJswoa48N3nELNuo2XHclJx4TsTY/sendMessage?chat_id=' . $chat_id . '&text=' . $response;
// CURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); # for return $url results
$result = curl_exec($ch);
Editor is loading...