Search code examples
laraveltelegramtelegram-botlaravel-6telegram-api

Forbidden: Bot was blocked by the user - laravel irazasyed/telegram-bot-sdk


Recently I get a lot of this exception:

[2020-07-21 00:00:51] local.ERROR: Forbidden: bot was blocked by the user {"exception":"[object] (Telegram\\Bot\\Exceptions\\TelegramResponseException(code: 403): Forbidden: bot was blocked by the user at /home/birjande/public_html/tel.birjandelectronic.shop/packages/irazasyed/telegram-bot-sdk/src/Exceptions/TelegramResponseException.php:58)

in my case when a user block the botm my bot fails in a infinite loop and send a message again and again and !

I got was this kind or error, Just times 10000!

in fact if I got a error it's repeat over 1000 times !

i use laravel 6 and irazasyed/telegram-bot-sdk


Solution

  • i create my own sendMessage like this

    public function sendMessage($arr) {
         try {
             Telegram::sendMessage($arr);
         } catch (TelegramResponseException $e) {
             return "user has been blocked!";
         }
     }