群临时会话发送消息send_private_msg报错

对接的框架是napcat,koishi这边使用的适配器是adapter-onebot,版本为6.8.0版本

koishi这边的报错日志为:
2025-08-17 13:28:35 [W] session Error: Error with request send_private_msg, args: {"user_id":3,"message":[{"type":"text","data":{"text":"点赞失败惹,今天可能已经赞过了,美酒虽好,不可贪杯哦~"}}]}, retcode: 1200 at _Internal._get (/koishi/node_modules/koishi-plugin-adapter-onebot/lib/index.js:119:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async _Internal.<computed> [as sendPrivateMsg] (/koishi/node_modules/koishi-plugin-adapter-onebot/lib/index.js:162:20) at async OneBotMessageEncoder.flush (/koishi/node_modules/koishi-plugin-adapter-onebot/lib/index.js:771:235) at async OneBotMessageEncoder.send (/koishi/node_modules/@satorijs/core/lib/index.cjs:755:5) at async Proxy.sendMessage (/koishi/node_modules/@satorijs/core/lib/index.cjs:487:22) at async /koishi/node_modules/@koishijs/core/lib/index.cjs:2050:7 at async Proxy.withScope (/koishi/node_modules/@koishijs/core/lib/index.cjs:1957:22) at async next (/koishi/node_modules/@koishijs/core/lib/index.cjs:827:16) at async next (/koishi/node_modules/@koishijs/core/lib/index.cjs:827:16)

在napcat的报错内容为:
[ERROR] 发生错误 Error: 无法获取用户信息 at createContext (file:///app/napcat/napcat.mjs:60933:13) at async SendPrivateMsg.base_handle (file:///app/napcat/napcat.mjs:60996:18) at async SendPrivateMsg.websocketHandle (file:///app/napcat/napcat.mjs:51444:23) at async OB11WebSocketClientAdapter.handleMessage (file:///app/napcat/napcat.mjs:51593:21)

从koishi的日志中看到适配器给napcat传递了一个user_id为3,而这个user的id的值正常不应该是用户的QQID吗?

2 个赞

显然不对。

自行检查代码

1 个赞

让他检查onebot适配器的代码嘛?会不会为难他了,这个临时回话调用很明显是我的赞我插件,其他作者插件调用时报错保持一致

1 个赞

首先,他的提问就是 群临时会话发送消息send_private_msg报错

那么我要回答的就是调用send_private_msg为什么会报错。

而我说 【显然不对。自行检查代码】意思是调用的时候 传入的userid不对,

这与 onebot适配器的代码 有什么关系?

他应该检查的是自己写的代码


另外

我不知道你这是从什么地方判断出来的

有点,臆断了


1 个赞

在koishi日志中"data":{“text”:“点赞失败惹,今天可能已经赞过了,美酒虽好,不可贪杯哦~”}这一段输出的内容,与我赞我插件中的默认回复一致

1 个赞

那你需要,看看问题在哪了。。。。

1 个赞

这可能是一些奇特的bug

需要帖主更多的信息

需要调试看一下当前userId到底是什么

也有可能是受到其他插件的影响导致的问题

1 个赞

?我在上面说的就是调用的是我的插件,并没有提及过其报错本身来源于我的插件,而且我赞我插件没有调用send_private_msg API

1 个赞

确实(zsbd

1 个赞

左脑攻击右脑

2 个赞

唔 的确没有直接调用

我估计是这个帖主是在私聊环境调用了【赞我】

然后插件返回提示语的时候 被adapter-onebot处理返回 所以间接调用了send_private_msg API


更详细的推断 需要帖主提供更多信息

1 个赞

是调用了赞我命令,调用其他插件也会这样,调用点歌插件也是类似的报错

2 个赞

应该是你安装了什么插件,导致session.userId不正确

试试看二分法关掉部分插件,定位一下导致问题的插件

2 个赞

现在就开了一个adapter-onebot和music-voice插件,其他插件都关了,QQ临时会话调用还是报错

2 个赞

那先尝试新开一个koishi实例,试试看是否还有这样的问题。

Koishi 多实例(双开/同时运行多个 Koishi)的方法 - 技术分享 - Koishi Forum

2 个赞

我直接重新下了一个koishi,把原来的关了,新的koishi就装了一个adapter-onebot和music-voice插件,外加启动了一个puppeteer,其他没动了。报错一致,还是这样

2 个赞

重新下?是双清了吗

2 个赞

我是在另一个目录重新下了一个开发版本koishi,重新安装了adapter-onebot和music-voice,重新配置并启动。然后还是出现了这样的报错

2 个赞

那么基本可以断定是协议端的问题,不太倾向于koishi的问题了

你对接的是onebot实现端是什么?

2 个赞

我用的NapCat

2 个赞