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:

  1. 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?

  2. 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); } 
  • notifications are sent to https? or do you interrogate yourself every time? - Anonymous
  • via web at https - zEvilz
  • great, does it come at the right time? logs inserted? hangup goes on client side? or does the mesaga not just come to him? - Anonymous
  • comes immediately. the log is just false instead of the json string. After a hang, the bot does not respond to any messages. in 5 minutes after sending the message, the responses to the previous button presses come immediately with a pack - zEvilz
  • Is such a situation possible? You are sending the wrong command. comes false. Everything is broken, since the processing is only for json. The server telegrams from you does not receive an answer that you received a message (since everything fell). he sends you false again and so 5-10 times (there’s a limit, I don’t remember the exact number). after 5 minutes, he marks this message as bad and stops sending it to you. after which the accumulated messages come in batches. Is such a situation possible? PS Please attach the logs. They will help a lot. - Anonymous

0