i'm trying to download some files with a telegram bot using telepot, but when I try to download it, it gives me this error:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\***\\Desktop'
This is the current code:
def on_chat_message(msg):
content_type, chat_type, chat_id = telepot.glance(msg)
file_id = msg['document']['file_id']
bot.download_file(file_id,os.getcwd())
You are attempting to save a file named
C:\Users\***\Desktop
. You can't do that becauseC:\Users\***\Desktop
is a directory.On Windows, you will get a permission-denied error attempting to open a directory for reading or writing as if it were a file.
You will have to specify the name of the file somehow. It may be in the
msg
object you receive, I don't know.Instead of writing
try