Last active
May 3, 2017 22:36
-
-
Save JosXa/9368a9cfa4707f8b1b34744c67ab08c2 to your computer and use it in GitHub Desktop.
Sending an audio file without actually downloading it to hard disk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def some_handler(bot, update): | |
chat_id = update.message.chat_id | |
import urllib.request | |
import io | |
url = "https://talkpython.fm/episodes/download/110/data-democratization-with-redash.mp3" | |
response = urllib.request.urlopen(url) | |
bytestring = response.read() # a `bytes` object | |
file_like_object = io.BytesIO(bytestring) # convert `bytes` to file-like object | |
bot.sendAudio(chat_id, file_like_object) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment