【发布时间】:2021-12-30 11:19:10
【问题描述】:
@dp.message_handler(content_types=types.ContentType.DOCUMENT)
async def scan_message(file: types.File):
print("downloading document")
file_path = file.file_path
destination = r"C:\users\aleks\PycharmProjects\pythonProject\file.pdf"
destination_file = bot.download_file(file_path, destination)
print("success")
我希望能够下载用户发送给我的机器人的文件(在本例中为 pdf)。但问题是机器人甚至不识别文件(当我发送文件时,它甚至不打印“下载文档”)
【问题讨论】:
-
@Abdul Muiz,对不起,但这没有帮助。当我运行这段代码时,我被告知我不能使用 await 关键字声明变量
标签: python bots telegram aiogram