上传和获取文件
约 256 字小于 1 分钟
2025-04-22
上传文件
发送文件。
提示
由于 NapCat 的一些原因, 发送视频建议以上传文件的形式进行.
通过文件消息发送
from ncatbot.core import BotClient
bot = BotClient()
api = bot.run_blocking(bt_uin="123456") # 这里写你 bot 的 QQ 号
api.post_private_file(user_id="123456", file = "path/to/file") # 这里写接收者的 QQ 号和文件的路径
api.post_private_file(user_id="123456", video = "path/to/video") # 这里写接收者的 QQ 号和视频的路径
- 路径一般写绝对路径,也可以写 url。写相对路径可能会出错。
- 发送群文件的文件消息,应该使用
api.post_group_file
和group_id
,其它格式一致。
通过专用上传接口发送
专用接口为 bot.upload_group_file
,群文件专用。
参考详细文档。
获取文件
下载文件,下载群文件,整理群文件。
版权所有
版权归属:huan-yp