atipugin / telegram-bot-ruby

Ruby wrapper for Telegram's Bot API
https://core.telegram.org/bots/api
Do What The F*ck You Want To Public License
1.35k stars 217 forks source link

How to receive Voice messages? #275

Closed syxanash closed 1 year ago

syxanash commented 1 year ago

Hi I've been following the format described in the docs, I have a valid Bot API Token and file ID for the voice message received in the message object but this URL still returns 404. I would assume that I can just visit that url and the download of the voice file would start but nothing happens.

"https://api.telegram.org/file/bot#{bot_api_token}/#{voice_file_id}"

I've been trying also with the getFile method by specifying the voice_file_id as string parameters but no luck... Is there anything I'm doing wrong?

syxanash commented 1 year ago

This stackoverflow solution answered my question: https://stackoverflow.com/a/32679930

first I need to get the file_path info with this url: https://api.telegram.org/bot<bot_token>/getFile?file_id=<the_file_id>

then I'll download the actual file with: https://api.telegram.org/file/bot<token>/<file_path>

It wasn't super clear from the docs or previous issues opened on this repo. Hope that'll clear things up for future reference.