tdlib / telegram-bot-api

Telegram Bot API server
https://core.telegram.org/bots
Boost Software License 1.0
2.97k stars 574 forks source link

Error sending fileid of flac audio in inline request #609

Closed Rovniced closed 1 day ago

Rovniced commented 1 week ago

For audio files in flac format, if the file has a Content-Type set to audio/x-flac in the request, and then the fileid is used to reply in inline mode. An error BadRequest: audio_content_type_invalid will occur.

If you set the Content-Type to audio/mpeg, application/octet-stream, etc., the fileid you get can be used in inline mode.

Some third-party libraries upload with the file type labeled will cause an error, for example: https://github.com/python-telegram-bot/python-telegram-bot/issues/4352

The official api only supports mp3 and aac format, but flac format can be played normally, is it possible to do some support for inline mode?

levlam commented 1 week ago

See documentation of InlineQueryResultCachedAudio: "Represents a link to an MP3 audio file stored on the Telegram servers". If you pass parameters that don't conform to the documentation, then the request can fail or may not work in another way.

Rovniced commented 1 week ago

See documentation of InlineQueryResultCachedAudio: "Represents a link to an MP3 audio file stored on the Telegram servers". If you pass parameters that don't conform to the documentation, then the request can fail or may not work in another way.

The fileid are all obtained by sending in the group via sendAudio request, and after several tests, it is found that the fileid obtained from the request with Content-Type set to audio/x-flac will report an error in the inline request. The parameters are normal.

Including the test audio file is the same

levlam commented 1 week ago

See documentation of InlineQueryResultCachedAudio: "Represents a link to an MP3 audio file stored on the Telegram servers".

Rovniced commented 1 week ago

Thank you for your answer.

So I should mark the flac file as mp3 in the Content-Type to send it properly? Since flac files can be played normally, I would like to ask if the flac format can be supported.

levlam commented 1 week ago

FLAC files can't be played normally. If you try to pretend that a FLAC file is an MP3, then you pass parameters that don't conform to the documentation and the request can fail or may not work in another way in any Telegram app.

Rovniced commented 1 week ago

Ok, thanks for your answers.