Mrs4s / go-cqhttp

cqhttp的golang实现,轻量、原生跨平台.
GNU Affero General Public License v3.0
10.32k stars 1.64k forks source link

[Bug]: nonebot2使用多个bot.send_private_msg会抛出异常,已咨询过nonebot2 #1540

Open Bearlele opened 2 years ago

Bearlele commented 2 years ago

请确保您已阅读以上注意事项,并勾选下方的确认框。

go-cqhttp 版本

cfa35b6

运行环境

Linux

运行架构

AMD64

连接方式

WebSocket (反向)

使用协议

1 | Android Phone

重现步骤

这是我在nonebot2那边发的issues:https://github.com/nonebot/nonebot2/issues/1043

一个handle()里使用多个bot.send_private_msg发送私信第一个bot.send_private_msg正常,但第二个bot.send_private_msg会抛出异常: nonebot.adapters.onebot.v11.exception.ActionFailed: <ActionFailed data=None, echo={'seq': 9}, msg=SEND_MSG_API_ERROR, retcode=100, status=failed, wording=请参考 go-cqhttp 端输出>

期望的结果是什么?

正常处理,不抛出异常

实际的结果是什么?

nonebot.adapters.onebot.v11.exception.ActionFailed: <ActionFailed data=None, echo={'seq': 9}, msg=SEND_MSG_API_ERROR, retcode=100, status=failed, wording=请参考 go-cqhttp 端输出>

简单的复现代码/链接(可选)

@private.handle()
async def _(bot: Bot, event: PrivateMessageEvent):
    await bot.send_private_msg(user_id=114514, message=Message('内容1'))
    反馈:
        [INFO] nonebot | Event will be handled by <Matcher from src.plugins.nonebot_plugin_Authenticate, type=message, priority=1, temp=False>

    await bot.send_private_msg(user_id=191810, message=Message('内容2'))
    反馈:
    nonebot.adapters.onebot.v11.exception.ActionFailed: <ActionFailed data=None, echo={'seq': 9}, msg=SEND_MSG_API_ERROR, retcode=100, status=failed, wording=请参考 go-cqhttp 端输出>

日志记录(可选)

go-cqhttp:
[2022-06-15 16:16:08] [INFO]: 收到来自群 XXX(474079782) 内 XXX(3001640272) 的临时会话消息: 2587342146 
[2022-06-15 16:16:08] [INFO]: 发送好友 2587342146(2587342146)  的消息: [{"type":  ... (2037020112) 

nonebot2:
06-15 16:11:06 [SUCCESS] nonebot | ONEBOT V11 2758026485 | [message.private.group]: Message 11580 from 3001640272 "2587342146"
06-15 16:11:06 [INFO] nonebot | Event will be handled by <Matcher from src.plugins.nonebot_plugin_Authenticate, type=message, priority=1, temp=False>
06-15 16:11:06 [INFO] nonebot | Matcher <Matcher from src.plugins.nonebot_plugin_Authenticate, type=message, priority=1, temp=False> running complete
06-15 16:11:06 [ERROR] nonebot | Running matcher <Matcher from src.plugins.nonebot_plugin_Authenticate, type=message, priority=1, temp=False> failed.
Traceback (most recent call last):
  File "/root/nonebot/src/plugins/nonebot_plugin_Authenticate/__init__.py", line 79, in _
    await bot.send_private_msg(user_id=user, message=Message('已给{0}({1})发送验证信息,请提醒对方及时进行验证\n您可以在3小时内发送新的QQ号以更改验证人'.format(info['card'],info['user_id'])))
  File "/usr/local/lib/python3.9/dist-packages/nonebot/adapters/onebot/v11/bot.py", line 208, in call_api
    return await super().call_api(api, **data)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/adapter/bot.py", line 117, in call_api
    raise exception
  File "/usr/local/lib/python3.9/dist-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/dist-packages/nonebot/adapters/onebot/v11/adapter.py", line 107, in _call_api
    return _handle_api_result(
  File "/usr/local/lib/python3.9/dist-packages/nonebot/adapters/onebot/v11/utils.py", line 81, in _handle_api_result
    raise ActionFailed(**result)
nonebot.adapters.onebot.v11.exception.ActionFailed: <ActionFailed data=None, echo={'seq': 23}, msg=SEND_MSG_API_ERROR, retcode=100, status=failed, wording=请参考 go-cqhttp 端输出>

补充说明(可选)

咨询过nonebot2疑似是昵昵埋的

Cyq20100313 commented 1 year ago

wording = 请参考go-cqhttp输出, go-cqhttp日志确定就这些? 你的简单复现代码明显不完整需要手动补充 代码中建议用注释注明反馈内容

Bearlele commented 1 year ago

代码就是连续两条 await bot.send_private_msg(user_id=123456789, message=Message("内容")) await bot.send_private_msg(user_id=123456789, message=Message("内容")) 第一条正常执行 第二条报错 nonebot.adapters.onebot.v11.exception.ActionFailed: <ActionFailed data=None, echo={'seq': 9}, msg=SEND_MSG_API_ERROR, retcode=100, status=failed, wording=请参考 go-cqhttp 端输出> 但内容正常发送出去 go-cqhttp端没有任何错误信息

Cyq20100313 commented 1 year ago

自己开http API,用Python requests库快速调用send_private_msg API试下?