2

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

mr javad
  • 163
  • 2
  • 13
  • You should catch all the possible exceptions to avoid a non-ok (200) http status code in response to Telegram. – Ali Padida Jul 22 '20 at 06:32
  • 1
    In fact, before finding the answer of your question, you should immediately solve the vulnerability issue of your website at `http://birjandelectronic.shop/`. Your web server is not configured properly and directory listing is not disabled and even your bot token is exposed!! – Ali Khalili Jul 22 '20 at 18:44

1 Answers1

3

i create my own sendMessage like this

public function sendMessage($arr) {
     try {
         Telegram::sendMessage($arr);
     } catch (TelegramResponseException $e) {
         return "user has been blocked!";
     }
 }
mr javad
  • 163
  • 2
  • 13