irazasyed / telegram-bot-sdk

🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
https://telegram-bot-sdk.com
BSD 3-Clause "New" or "Revised" License
3.04k stars 671 forks source link

Uncaught GuzzleHttp\Exception\ClientException: Client error #1134

Open chukey opened 3 months ago

chukey commented 3 months ago

PHP version

8.1

irazasyed/telegram-bot-sdk version

^3.9

Laravel version (if any)

No response

Code To Reproduce the bug

$bot->sendMessage([ 'chat_id'=>0, 'text'=>$text, 'parse_mode'=> 'html' ]);

Error stacktrace (if any)

i can not catch Exception i tried any type of exception \GuzzleHttp\Exception\ClientException \GuzzleHttp\Exception\RequestException TelegramSDKException

but always have fatal error chat_id is 0, because it send from server for notification and chat_id maybe bad and i need catch this error

 try {
                $bot->sendMessage([
                    'chat_id'=>0,
                    'text'=>$text,
                    'parse_mode'=> 'html'
                ]);
        } catch (\GuzzleHttp\Exception\RequestException $e){

        }
NikitinUser commented 3 months ago

What if catch (\Throwable $e)? "chat_id maybe bad" Why? You need to know chat_id to send a message. How else would Telegram understand who you're sending the message to?