go-cqhttp
go-cqhttp copied to clipboard
[Bug]: nonebot2使用多个bot.send_private_msg会抛出异常,已咨询过nonebot2
请确保您已阅读以上注意事项,并勾选下方的确认框。
- [X] 我已经仔细阅读上述教程和 "提问前需知"
- [X] 我已经使用 dev分支版本 测试过,问题依旧存在。
- [X] 我已经在 Issue Tracker 中找过我要提出的问题,没有找到相同问题的ISSUE。
- [X] 我已知晓并同意,此处仅用于汇报程序中存在的问题。若这个 Issue 是关于其他非程序本身问题,则我的 Issue 可能会被无条件自动关闭或/并锁定。(这些问题应当在 Discussion 板块提出。)
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疑似是昵昵埋的坑?
wording = 请参考go-cqhttp输出, go-cqhttp日志确定就这些? 你的简单复现代码明显不完整需要手动补充 代码中建议用注释注明反馈内容
代码就是连续两条 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端没有任何错误信息
自己开http API,用Python requests库快速调用send_private_msg API试下?