Answer the question
In order to leave comments, you need to log in
What is pending_update_count responsible for in the Telegram API?
I decided to create a bot using MVC, everything works fine for all messages. But after a while it completely stops responding to messages as if they do not come.
I decided to drop everything on pending_update_count, because after sending any message, it increases as a result it fills up and prevents other messages from working normally.
public function index(Request $request) {
$message = json_decode($request->getContent())->message;
$command = $this->constructCommand($message->text);
//КОМАНДЫ КОТОРЫЕ ОБЯЗАТЕЛЬНО ВЫЗОВУТ sendMessage
switch ($command[0]) {
case 'start':
/* ДРУГОЙ МЕТОД ДРУГОГО КЛАССА*/
break;
case 'help':
/* ДРУГОЙ МЕТОД ДРУГОГО КЛАССА */
break;
}
}
}
private function constructCommand($command) {
$substr = substr($command, 1);
$exploded = explode(' ', $substr);
$exploded[0] = explode('@', $exploded[0])[0];
return $exploded;
}
/* ФУНКЦИЯ ОТВЕЧАЮЩАЯ ЗА ОТПРАКУ СООБЩЕНИИ */
static public function sendMessage($group_id, $message) {
file_get_contents("https://api.telegram.org/bot".env('SECRET_TELEGRAM', null)."/sendMessage?parse_mode=markdown&chat_id=".$group_id."&text=".urlencode($message));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question