telegram-bot-api icon indicating copy to clipboard operation
telegram-bot-api copied to clipboard

[Bug] Sending channel-photo by file_id error

Open realkarych opened this issue 3 years ago • 4 comments

I tried to execute avatar-photo from channel and send it to another chat by file_id. So, Bot is Admin in this channel and has privileges to get it. Sending photo/document by big_file_id or small_file_id causes TypeOfFileMismatch API Exception.

This error can be avoided if we download file and send it from local-storage. But, we will lose a lot in performance.

realkarych avatar Aug 06 '22 11:08 realkarych

https://core.telegram.org/bots/api#chatphoto: "This file_id can be used only for photo download and only for as long as the photo is not changed".

levlam avatar Aug 06 '22 18:08 levlam

Sorry, it's my mistake. So, how about raising another type of Exception? I got stuck on "types mismatch".

realkarych avatar Aug 06 '22 19:08 realkarych

The type of the file is actually "profile_photo", which you can see in the path returned by getFile. And only "photo" files can be used in sendPhoto. I will change the error message to include expected and received file types, but I doubt that this change will actually help. It will just change the question to "why is it impossible to use profile_photo in sendPhoto?"

levlam avatar Aug 06 '22 20:08 levlam

"why is it impossible to use profile_photo in sendPhoto?" — This question references user to api limitations docs. And in my opinion it's clearer. So, thanks that helped me!

realkarych avatar Aug 06 '22 21:08 realkarych