admin管理员组

文章数量:1122832

I tried to make a bot that downloads files from Telegram channel, but except of good code I don't get files that may be downloaded in my directory. I tried this code:

@bot.message_handler(content_types=['document'])
def main(message):
    if message.document.file_name.startswith("schedule"):
        print(f"{Fore.GREEN}got this file: {message.document.file_name}")

        id = message.document.file_id
        info = bot.get_file(id)

        downloaded_file = bot.download_file(file_info.file_path)
        path = os.path.join(directory, message.document.file_name)

        with open(path, 'wb') as channel_file:
            channel_file.write(downloaded_file.content)

Is there any mistake that I've made?

本文标签: Is there any way to download files from TGchannel with using telebot python moduleStack Overflow