php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.9k stars 955 forks source link

non-ok replies from Telegram API stops execution #354

Closed jacklul closed 7 years ago

jacklul commented 7 years ago

I could swear I mentioned this already...

Basically all fail replies from Telegram throw an exception, this is very bad behavior. This prevents usage of any mass messaging commands (like announcements), because when one of the users blocks the bot library will throw exception and stop.

exception 'Longman\TelegramBot\Exception\TelegramException' with message 'Client error: `POST https://api.telegram.org/bot123/editMessageText` resulted in a `400 Bad Request` response:
{"ok":false,"error_code":400,"description":"Bot was blocked by the user"}

This is seriously annoying and makes

$result = Request::sendMessage($data)

useless because any fail will stop the execution, so the developer can't properly react to failures.

Can we have this fixed? This must have something to do with Guzzle and I wasn't been able to figure it out.

noplanman commented 7 years ago

Yes, I remember you mentioning this at some point. I'll look into this too 👍

jacklul commented 7 years ago

BTW: Seems like it doesn't happen now! (on latest dev)

I will try some kind of test tho in free time to confirm this!

noplanman commented 7 years ago

Yes, a test would be great, because I haven't actively changed anything to fix this yet...

jacklul commented 7 years ago

Tested it, it's fixed now! :thumbsup:

Maybe it was fixed at Guzzle's side?

noplanman commented 7 years ago

Possibly. If you feel like it, you could test different versions of Guzzle and see if the issue pops up at a certain version.

Anyway, if it happens again, just reopen here 😊