php-telegram-bot / core

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

exception: first_name is empty! #250

Closed MBoretto closed 8 years ago

MBoretto commented 8 years ago

This update: {"update_id":632831207,"message":{"message_id":13069,"from":{"id":11487,"first_name":"Name","last_name":"it","username":"it"},"chat":{"id":-10000000000,"title":"chatname","type":"supergroup"},"date":1463284673,"left_chat_participant":{"id":195958188,"first_name":""},"left_chat_member":{"id":195958188,"first_name":""}}} trown:

exception 'Longman\TelegramBot\Exception\TelegramException' with message 'first_name is empty!' in /data/grocerylist/vendor/mboretto/php-telegram-bot/src/Entities/User.php:38

This is due to the empty name in left_chat_member and left_chat_participant I was thinking to remove the is_empty check and just leave the isset one here:

https://github.com/akalongman/php-telegram-bot/blob/master/src/Entities/User.php#L37

@jacklul @noplanman what do you think?

lindeskun commented 8 years ago

I had same problem with empty width in Video.php, all library failed over.

MBoretto commented 8 years ago

@DestroyKun Can you retrieve the raw update? Can be that the height is equal to 0?

lindeskun commented 8 years ago

I have not raw log, sorry.

jacklul commented 8 years ago

BTW: Sometimes video thumb doesn't get send with the update and library fails as well in this case.

lindeskun commented 8 years ago

But Telegram tries to send it again and again, and that's delaying all other messages.

jacklul commented 8 years ago

It shouldn't be checking if the data is valid whenever it comes from Telegram anyway.

noplanman commented 8 years ago

@jacklul I would totally agree with you on that! But is the data coming from Telegram always "good"? You mentioned above that sometimes certain data is missing in the update. We need to manage it somehow, right? Otherwise there will possibly be inconsistencies and corrupt data.

jacklul commented 8 years ago

For example for User object as long telegram provides valid id rest we could ignore.

MBoretto commented 8 years ago

first_name is empty has been fixed closing