HibiKier / zhenxun_bot

基于 Nonebot2 开发,以 postgresql 作为数据库,非常可爱的绪山真寻bot
GNU Affero General Public License v3.0
3.3k stars 604 forks source link

帮助命令报错:无法打开文件 #1532

Closed For-Elyisa closed 3 weeks ago

For-Elyisa commented 4 months ago

系统版本:Ubuntu 22.04

真寻版本:1.6.7 (实际上是clone的最新代码)

错误

帮助指令没有回复

日志

Traceback (most recent call last): File "/home/zhenxun_bot/bot.py", line 22, in nonebot.run() File "/usr/local/lib/python3.9/site-packages/nonebot/init.py", line 261, in run get_driver().run(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/nonebot/drivers/fastapi.py", line 170, in run uvicorn.run( File "/usr/local/lib/python3.9/site-packages/uvicorn/main.py", line 576, in run server.run() File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.9/site-packages/nonebot/message.py", line 146, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "/usr/local/lib/python3.9/site-packages/nonebot/message.py", line 196, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 672, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/usr/local/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 639, in simple_run await handler( File "/usr/local/lib/python3.9/site-packages/nonebot/dependencies/init.py", line 92, in call return await self.call(values) File "/home/zhenxun_bot/basicplugins/help/init.py", line 58, in await simple_help.send(image(_image_path)) File "/usr/local/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 453, in send return await bot.send(event=event, message=_message, kwargs) File "/usr/local/lib/python3.9/site-packages/nonebot/adapters/onebot/v11/bot.py", line 220, in send return await self.class.send_handler(self, event, message, kwargs) File "/usr/local/lib/python3.9/site-packages/nonebot/adapters/onebot/v11/bot.py", line 175, in send return await bot.send_msg(params) File "/usr/local/lib/python3.9/site-packages/nonebot/internal/adapter/bot.py", line 117, in call_api raise exception File "/usr/local/lib/python3.9/site-packages/nonebot/internal/adapter/bot.py", line 94, in call_api result = await self.adapter._call_api(self, api, data) File "/usr/local/lib/python3.9/site-packages/nonebot/adapters/onebot/v11/adapter.py", line 132, in _call_api return handle_api_result( File "/usr/local/lib/python3.9/site-packages/nonebot/adapters/onebot/v11/utils.py", line 58, in handle_api_result raise ActionFailed(result) nonebot.adapters.onebot.v11.exception.ActionFailed: <ActionFailed status='failed', retcode=1200, data=None, message="Error: ENOENT: no such file or directory, open '/home/zhenxun_bot/data/group_help/798329703.png'", wording="Error: ENOENT: no such file or directory, open '/home/zhenxun_bot/data/group_help/798329703.png'", echo='4'>

错误说明

如果单独对一个功能使用帮助 例如:真寻帮助昵称系统 是可以发送帮助图片的。 我测试过的几个功能插件,不论是plugins里的插件还是my_plugins的手动添加的插件,使用帮助{功能} 指令是能够发送图片的。

报以上错误的指令包括: 群帮助指令 私聊帮助指令 超级用户帮助指令 管理员帮助指令

我已经确认这几个图片存在于正确的位置,但还是报错无法打开 我怀疑的一个方向是,指令执行开始时会删除旧的图片,生成新的图片。这是新图片还未生成写入目录,此时开始读取,就会发生错误。

验证这个猜测只需要在读取之前加上几秒的sleep,如果没问题就应该是这个原因。