Closed thomasfire closed 5 years ago
You can download a file following these steps:
If you can get this working, please submit the example for anyone else :) Thanks!
I solved it, but the example is rather complicated, see https://github.com/thomasfire/teleprint/blob/ed53c584101d8f49cb79bf4dfd052b94e2506334/src/bot.rs at the bottom where get_stream
is.
Yeah you don't have to call the Telegram Bot api directly for getting the download link, for example you could do:
bot.get_stream()
.filter_map(|(bot, update)|) update.message.map(|x| (bot, x)))
.and_then(|(bot, document)| {
bot.get_file(document.file_id).send()
})
.and_then(|res| {
FavouriteDownloader::download(res.file_path.unwrap())
})
I haven't tested it, but the general concept is like this. You can filter at the beginning for your relevant information, then issue a get_file call to Telegram and finally call your downloader to begin an HTTP download process.
Please report if you still need help, thanks!
I found nothing about how to receive a file on event, like bot.unknown_cmd() or bot.new_cmd(). Is there any opportunity to receive a file from a user?