HibiKier / nonebot-plugin-zxreport

可爱的小真寻记者为你献上今日报道!
GNU Affero General Public License v3.0
5 stars 1 forks source link

[bug] NoneBot和OneBot服务部署在不同环境时无法发送 #3

Closed ssttkkl closed 17 hours ago

ssttkkl commented 2 days ago

猜测是因为通过本地路径发送图片,建议改成通过base64编码发送

https://github.com/HibiKier/nonebot-plugin-zxreport/blob/7d9a6c63d4b879d5680bf156e2dec8097a6d01b9/nonebot_plugin_zxreport/__init__.py#L54

日志:

10-20 01:29:14 [SUCCESS] nonebot | OneBot V11 ***| [message.private.friend]: Message *** from *** '真 寻日报'
10-20 01:29:14 [INFO] nonebot | Event will be handled by AlconnaMatcher(type='', module=nonebot_plugin_zxreport, lineno=34)
10-20 01:29:31 [INFO] nonebot | AlconnaMatcher(type='', module=nonebot_plugin_zxreport, lineno=34) running complete
10-20 01:29:31 [ERROR] nonebot | Running AlconnaMatcher(type='', module=nonebot_plugin_zxreport, lineno=34) failed.
Traceback (most recent call last):
  File "/usr/local/bin/gunicorn", line 8, in <module>
    sys.exit(run())
  File "/usr/local/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 66, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]", prog=prog).run()
  File "/usr/local/lib/python3.11/site-packages/gunicorn/app/base.py", line 235, in run
    super().run()
  File "/usr/local/lib/python3.11/site-packages/gunicorn/app/base.py", line 71, in run
    Arbiter(self).run()
  File "/usr/local/lib/python3.11/site-packages/gunicorn/arbiter.py", line 201, in run
    self.manage_workers()
  File "/usr/local/lib/python3.11/site-packages/gunicorn/arbiter.py", line 570, in manage_workers
    self.spawn_workers()
  File "/usr/local/lib/python3.11/site-packages/gunicorn/arbiter.py", line 641, in spawn_workers
    self.spawn_worker()
  File "/usr/local/lib/python3.11/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.11/site-packages/uvicorn/workers.py", line 75, in init_process
    super().init_process()
  File "/usr/local/lib/python3.11/site-packages/gunicorn/workers/base.py", line 143, in init_process
    self.run()
  File "/usr/local/lib/python3.11/site-packages/uvicorn/workers.py", line 107, in run
    return asyncio.run(self._serve())
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "/usr/local/lib/python3.11/site-packages/nonebot/message.py", line 476, in check_and_run_matcher
    await _run_matcher(
> File "/usr/local/lib/python3.11/site-packages/nonebot/message.py", line 428, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "/usr/local/lib/python3.11/site-packages/nonebot/internal/matcher/matcher.py", line 850, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "/usr/local/lib/python3.11/site-packages/nonebot/internal/matcher/matcher.py", line 825, in simple_run
    await handler(
  File "/usr/local/lib/python3.11/site-packages/nonebot/dependencies/__init__.py", line 94, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "/usr/local/lib/python3.11/site-packages/nonebot_plugin_zxreport/__init__.py", line 54, in _
    await UniMessage(Image(path=path)).send()
  File "/usr/local/lib/python3.11/site-packages/nonebot_plugin_alconna/uniseg/message.py", line 1417, in send
    res = await fn.send_to(target, bot, msg, **kwargs)
  File "/usr/local/lib/python3.11/site-packages/nonebot_plugin_alconna/uniseg/adapters/onebot11/exporter.py", line 154, in send_to
    return await bot.send(target, message, **kwargs)  # type: ignore
  File "/usr/local/lib/python3.11/site-packages/nonebot/adapters/onebot/v11/bot.py", line 237, in send
    return await self.__class__.send_handler(self, event, message, **kwargs)
  File "/usr/local/lib/python3.11/site-packages/nonebot/adapters/onebot/v11/bot.py", line 190, in send
    return await bot.send_msg(**params)
  File "/usr/local/lib/python3.11/site-packages/nonebot_plugin_escape_url/onebot_v11.py", line 30, in call_api
    return await _origin_call_api(self, api, **data)
  File "/usr/local/lib/python3.11/site-packages/nonebot/internal/adapter/bot.py", line 122, in call_api
    raise exception
  File "/usr/local/lib/python3.11/site-packages/nonebot/internal/adapter/bot.py", line 97, in call_api
    result = await self.adapter._call_api(self, api, **data)
  File "/usr/local/lib/python3.11/site-packages/nonebot/adapters/onebot/v11/adapter.py", line 147, in _call_api
    return handle_api_result(await self._result_store.fetch(seq, timeout))
  File "/usr/local/lib/python3.11/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, copyfile '/root/.cache/nonebot2/nonebot_plugin_zxreport/mahiro_report/2024-10-20.png' -> '/app/.config/QQ/NapCat/temp/526c5f49-7498-4cce-b0db-113a0598220e.png'\n    at Object.copyFileSync (node:fs:3013:11)\n    at Object.func [as copyFileSync] (node:electron/js2c/node_init:2:3119)\n    at uri2local (file:///app/napcat/napcat.mjs:5621:10)\n    at async OneBotMsgApi.handleOb11FileLikeMessage (file:///app/napcat/napcat.mjs:23978:9)\n    at async Object.image (file:///app/napcat/napcat.mjs:23670:10)\n    at async Promise.all (index 0)\n    at async OneBotMsgApi.createSendElements (file:///app/napcat/napcat.mjs:23923:17)\n    at async SendMsg._handle (file:///app/napcat/napcat.mjs:30689:52)\n    at async SendMsg.websocketHandle (file:///app/napcat/napcat.mjs:30589:23)\n    at async OB11ActiveWebSocketAdapter.handleMessage (file:///app/napcat/napcat.mjs:12815:21)", wording="Error: ENOENT: no such file or directory, copyfile '/root/.cache/nonebot2/nonebot_plugin_zxreport/mahiro_report/2024-10-20.png' -> '/app/.config/QQ/NapCat/temp/526c5f49-7498-4cce-b0db-113a0598220e.png'\n    at Object.copyFileSync (node:fs:3013:11)\n    at Object.func [as copyFileSync] (node:electron/js2c/node_init:2:3119)\n    at uri2local (file:///app/napcat/napcat.mjs:5621:10)\n    at async OneBotMsgApi.handleOb11FileLikeMessage (file:///app/napcat/napcat.mjs:23978:9)\n    at async Object.image (file:///app/napcat/napcat.mjs:23670:10)\n    at async Promise.all (index 0)\n    at async OneBotMsgApi.createSendElements (file:///app/napcat/napcat.mjs:23923:17)\n    at async SendMsg._handle (file:///app/napcat/napcat.mjs:30689:52)\n    at async SendMsg.websocketHandle (file:///app/napcat/napcat.mjs:30589:23)\n    at async OB11ActiveWebSocketAdapter.handleMessage (file:///app/napcat/napcat.mjs:12815:21)", echo='7')
HibiKier commented 2 days ago

97b8ea5b5e9495cb82db6e887f3215b1b08d6e1a