Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
800 stars 340 forks source link

How to prevent my bot from entering a loop? #239

Closed alejandroburgos97 closed 3 years ago

alejandroburgos97 commented 3 years ago

My bot has a functionality in which it pings another computer, when the user pings more than 60 times the bot takes a long time to do so, and I think it does not respond to Telegram with an http code 200, and therefore telegram returns to send the ping request 60 times, and the cycle never stops.

alejandroburgos97 commented 3 years ago

By the way, I already tried adding "http_response_code(200);" to my code, but It didn't work

alejandroburgos97 commented 3 years ago

In the end I managed to solve it myself, I searched all over the internet and found a clue from someone who had the same problem, adding http_response_code (200) was not enough. Now every time the something goes inside my function I clear the pending messages via drop_pending_updates parameter in the setWebhook method https://core.telegram.org/bots/api#setwebhook