There is a bot assistant who answers questions. The principle of operation - the type of quest, the bot responds and displays new buttons. Everything works fine, except for 2 moments:
After 10-20 clicks on the buttons (interval of 5 seconds), the bot hangs for 5 minutes. In the API response, only false. Hangup occurs randomly and can occur at any step. Has anyone come across this?
Remove_keyboard does not work
Part of the bot code:
function get_updates($token) { $content = file_get_contents("php://input"); $update = json_decode($content, TRUE); file_put_contents('bot.log', json_encode($content)); $message = $update["message"]; return $update; } function get_api_url($token) { $api_url = "https://api.telegram.org/bot".$token; return $api_url; } function send_message($message, $keyboard = false) { global $data; global $api_url; global $update; if ($update['callback_query']) $params['chat_id'] = $update['callback_query']['message']['chat']['id']; else $params['chat_id'] = $data["chat"]["id"]; $params['text'] = strip_tags($message); if ($keyboard !== false) { $params['reply_markup'] = json_encode([ 'keyboard' => $keyboard, 'resize_keyboard' => true, 'one_time_keyboard' => true ]); } else { $params['reply_markup'] = json_encode([ 'remove_keyboard' => true ]); } $result = file_get_contents($api_url.'/sendmessage?'.http_build_query($params)); file_put_contents('send.log', json_encode($result)); } $token = "1234"; $update = get_updates($token); $data = $update['message']; $api_url = get_api_url($token); $user_message = $data["text"]; $user = get_user_info(); $callback = $update['callback_query']['data']; // ΠΏΡΠΈΠΌΠ΅Ρ ΠΎΡΠΏΡΠ°Π²ΠΊΠΈ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ if ($user_message == 'ΡΠ΅ΠΊΡΡ_ΠΊΠ½ΠΎΠΏΠΊΠΈ' && /* Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΡΡΠ»ΠΎΠ²ΠΈΡ */) { $message = "ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅"; $keyboard = [ ['1'], ['2'] ]; send_message($message, $keyboard); }