koishijs / koishi

Cross-platform chatbot framework made with love
https://koishi.chat
MIT License
4.37k stars 237 forks source link

连接至go-cqhttp后报错 #982

Closed fatinghenji closed 1 year ago

fatinghenji commented 1 year ago
2023-02-15 07:55:47 [W] onebot TypeError: Cannot read properties of undefined (reading 'replace')
                            at Function.escape (/home/koishi-app/node_modules/@satorijs/element/lib/index.cjs:101:27)
                            at ElementConstructor.toString (/home/koishi-app/node_modules/@satorijs/element/lib/index.cjs:37:51)
                            at Array.join (<anonymous>)
                            at adaptMessage (/home/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:315:36)
                            at OneBotBot.getMessage (/home/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:804:18)
                            at processTicksAndRejections (node:internal/process/task_queues:96:5)
                            at async adaptMessage (/home/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:310:20)
                            at async adaptSession (/home/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:368:5)
                            at async dispatchSession (/home/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:355:19)
2023-02-15 07:55:47 [W] app TypeError: Cannot read properties of undefined (reading 'replace')
                            at Function.escape (/home/koishi-app/node_modules/@satorijs/element/lib/index.cjs:101:27)
                            at ElementConstructor.toString (/home/koishi-app/node_modules/@satorijs/element/lib/index.cjs:37:51)
                            at Array.join (<anonymous>)
                            at adaptMessage (/home/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:315:36)
                            at processTicksAndRejections (node:internal/process/task_queues:96:5)
                            at async adaptSession (/home/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:368:5)
                            at async dispatchSession (/home/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:355:19)\

上面还有一个插件市场的报错,不清楚是否与改问题相关:

023-02-15 07:47:35 [I] market ➤ YN0050: The --registry option is deprecated; prefer setting npmRegistryServer in your .yarnrc.yml file
2023-02-15 07:47:36 [I] market ➤ YN0000: ┌ Resolution step
2023-02-15 07:47:36 [I] market ➤ YN0002: │ @koishijs/plugin-adapter-discord@npm:3.5.1 [dd020] doesn't provide @satorijs/satori (p18fed), requested by @satorijs/adapter-discord
2023-02-15 07:47:36 [I] market ➤ YN0002: │ @koishijs/plugin-adapter-feishu@npm:1.1.3 [dd020] doesn't provide @satorijs/satori (p46e79), requested by @satorijs/adapter-feishu
2023-02-15 07:47:36 [I] market ➤ YN0002: │ @koishijs/plugin-adapter-kook@npm:3.5.2 [dd020] doesn't provide @satorijs/satori (pf945b), requested by @satorijs/adapter-kook
2023-02-15 07:47:36 [I] market ➤ YN0002: │ @koishijs/plugin-adapter-onebot@npm:5.5.4 [dd020] doesn't provide @satorijs/satori (p1efbc), requested by @satorijs/adapter-onebot
2023-02-15 07:47:36 [I] market ➤ YN0002: │ @koishijs/plugin-adapter-telegram@npm:3.6.7 [dd020] doesn't provide @satorijs/satori (pdbbd8), requested by @satorijs/adapter-telegram
2023-02-15 07:47:36 [I] market ➤ YN0002: │ @koishijs/plugin-database-sqlite@npm:3.3.2 [dd020] doesn't provide @minatojs/core (pec853), requested by @minatojs/driver-sqlite
2023-02-15 07:47:36 [I] market ➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
2023-02-15 07:47:36 [I] market ➤ YN0000: └ Completed in 0s 454ms
2023-02-15 07:47:36 [I] market ➤ YN0000: ┌ Fetch step
2023-02-15 07:47:36 [I] market ➤ YN0013: │ @koishijs/plugin-echo@npm:2.0.6 can't be found in the cache and will be fetched from the remote registry
2023-02-15 07:47:36 [I] market ➤ YN0000: └ Completed in 0s 397ms
2023-02-15 07:47:36 [I] market ➤ YN0000: ┌ Link step
2023-02-15 07:47:37 [I] market ➤ YN0000: └ Completed in 0s 261ms
2023-02-15 07:47:37 [I] market ➤ YN0000: Done with warnings in 1s 189ms
Anillc commented 1 year ago

我这边无法复现,请问可以提供更详细的信息吗,或者尝试重新安装 koishi 看是否会出现同样的问题

shigma commented 1 year ago

我目前感觉这些报错都不影响使用。你目前有收发消息异常的情况吗?

此外:如果可以请至少提供报错时间前后几分钟内的 go-cqhttp 日志。

fatinghenji commented 1 year ago

似乎是 go-cqhttp 上报格式问题。array 报错,string 正常。

我目前感觉这些报错都没有影响使用。你目前有收发消息异常的情况吗?

此外:如果可以请至少提供报错时间前几分钟内的go-cqhttp日志。

在 array 下无法收发消息,string 下可以正常收发,我一会再测试下

fatinghenji commented 1 year ago

在 array 下无法收发消息,string 下可以正常收发,我一会再测试下

测试后确定是这个位置的问题,将string改为array后,报错复现。

023-02-20 15:29:43 [W] adapter failed to connect to ws://127.0.0.1:6700, code: 1006, will retry in 5s...
2023-02-20 15:29:48 [W] adapter failed to connect to ws://127.0.0.1:6700, code: 1006, will retry in 5s...
2023-02-20 15:29:53 [W] adapter failed to connect to ws://127.0.0.1:6700, code: 1006, will retry in 5s...
2023-02-20 15:29:58 [W] adapter failed to connect to ws://127.0.0.1:6700, code: 1006, will retry in 5s...
2023-02-20 15:30:03 [W] adapter failed to connect to ws://127.0.0.1:6700, code: 1006, will retry in 5s...
2023-02-20 15:30:08 [W] adapter failed to connect to ws://127.0.0.1:6700, code: 1006, will retry in 5s...
2023-02-20 15:30:13 [W] adapter failed to connect to ws://127.0.0.1:6700, code: 1006, will retry in 1m...
2023-02-20 15:31:14 [I] adapter connect to server: ws://127.0.0.1:6700
2023-02-20 15:31:21 [W] app TypeError: Cannot read properties of undefined (reading 'replace')
                            at Function.escape (/home/vanthoff/koishi-app/node_modules/@satorijs/core/node_modules/@satorijs/element/lib/index.cjs:101:27)
                            at ElementConstructor.toString (/home/vanthoff/koishi-app/node_modules/@satorijs/core/node_modules/@satorijs/element/lib/index.cjs:37:51)
                            at Array.join (<anonymous>)
                            at adaptMessage (/home/vanthoff/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:315:36)
                            at adaptSession (/home/vanthoff/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:368:11)
                            at dispatchSession (/home/vanthoff/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:355:25)
                            at WebSocket.<anonymous> (/home/vanthoff/koishi-app/node_modules/@satorijs/adapter-onebot/lib/index.js:610:7)
                            at WebSocket.emit (node:events:512:28)
                            at Receiver.receiverOnMessage (/home/vanthoff/koishi-app/node_modules/ws/lib/websocket.js:1180:20)
                            at Receiver.emit (node:events:512:28)

是更改go-cqhttp配置文件的这里:

message:
  # 上报数据类型
  # 可选: string,array
  post-format: array

string则正常,array则报错。文档:适配器onebot中并未提到应使用string而非array。我同时还在使用其他的bot终端,他们需求的都为array。 上面提到的go-cqhttp日志文件如下(提供的为更改为array后启动的日志):

➜  qq go-cqhttp -faststart
[2023-02-20 15:30:11] [INFO]: 当前版本:1.0.0-rc4
[2023-02-20 15:30:11] [INFO]: 将使用 device.json 内的设备信息运行Bot.
[2023-02-20 15:30:11] [INFO]: 开始尝试登录并同步消息...
[2023-02-20 15:30:11] [INFO]: 使用协议: Android Phone
[2023-02-20 15:30:17] [INFO]: Protocol -> connect to server: 116.130.229.12:8080
[2023-02-20 15:30:17] [WARNING]: Protocol -> device lock is disable. http api may fail.
[2023-02-20 15:30:20] [INFO]: 收到服务器地址更新通知, 将在下一次重连时应用.
[2023-02-20 15:30:21] [INFO]: 登录成功 欢迎使用: BOT
[2023-02-20 15:30:21] [INFO]: 开始加载好友列表...
[2023-02-20 15:30:21] [INFO]: 共加载 121 个好友.
[2023-02-20 15:30:21] [INFO]: 开始加载群列表...
[2023-02-20 15:30:22] [INFO]: 共加载 24 个群.
[2023-02-20 15:30:22] [INFO]: 资源初始化完成, 开始处理信息.
[2023-02-20 15:30:22] [INFO]: アトリは、高性能ですから!
[2023-02-20 15:30:22] [INFO]: 正在检查更新.
[2023-02-20 15:30:22] [INFO]: 开始尝试连接到反向WebSocket Universal服务器: wss://xn--v9x.net:443/ws/
[2023-02-20 15:30:22] [INFO]: 开始尝试连接到反向WebSocket Universal服务器: ws://127.0.0.1:8069/onebot/v11/ws/
[2023-02-20 15:30:22] [INFO]: 开始尝试连接到反向WebSocket Universal服务器: ws://127.0.0.1:20000/onebot/v11/ws
[2023-02-20 15:30:22] [INFO]: CQ HTTP 服务器已启动: [::]:5702
[2023-02-20 15:30:22] [INFO]: CQ WebSocket 服务器已启动: [::]:6700
[2023-02-20 15:30:22] [INFO]: CQ WebSocket 服务器已启动: [::]:5701
[2023-02-20 15:30:22] [INFO]: 已连接到反向WebSocket Universal服务器 ws://127.0.0.1:8069/onebot/v11/ws/
[2023-02-20 15:30:22] [INFO]: 已连接到反向WebSocket Universal服务器 ws://127.0.0.1:20000/onebot/v11/ws
[2023-02-20 15:30:22] [WARNING]: 检查更新失败!
[2023-02-20 15:30:22] [INFO]: 检查更新完成. 当前已运行最新版本.
[2023-02-20 15:30:22] [INFO]: 开始诊断网络情况
[2023-02-20 15:30:23] [INFO]: 接受 WebSocket 连接: 192.168.123.146:46536 (/)
[2023-02-20 15:30:25] [INFO]: 网络诊断完成. 未发现问题
[2023-02-20 15:30:29] [INFO]: 已连接到反向WebSocket Universal服务器 wss://xn--v9x.net:443/ws/
[2023-02-20 15:30:39] [INFO]: 收到群 明日方舟博士交流研讨(963856164) 内 兔兔妈(2909954314) 的消息: 兔兔 (2046914481)
[2023-02-20 15:30:40] [INFO]: 发送群 明日方舟博士交流研讨会(963856164) 的消息: [{"type":  ... (-485999093)
[2023-02-20 15:30:44] [INFO]: 收到群 明日方舟博士交流研讨(963856164) 内 兔兔妈(2909954314) 的消息: 好了 (-1810952547)
[2023-02-20 15:31:05] [INFO]: 收到群 BOT、酷推、Пулемет (601022072) 内 Пулемет РП-46 (2909954314) 的消息: help (1755532220)
[2023-02-20 15:31:13] [INFO]: 接受 WebSocket 连接: 127.0.0.1:45894 (/)
[2023-02-20 15:31:21] [INFO]: 收到群 BOT、酷推、Пулемет (601022072) 内 Пулемет РП-46 (2909954314) 的消息: help (140821081)

注意时间点,go-cqhttp成功链接到了koishi-bot,并接收到了消息:

[2023-02-20 15:31:13] [INFO]: 接受 WebSocket 连接: 127.0.0.1:45894 (/)
[2023-02-20 15:31:05] [INFO]: 收到群 BOT、酷推、Пулемет (601022072) 内 Пулемет РП-46 (2909954314) 的消息: help 

稍后koishi控制台抛出错误:

2023-02-20 15:31:21 [W] app TypeError: Cannot read properties of undefined (reading 'replace')
fatinghenji commented 1 year ago

我这边无法复现,请问可以提供更详细的信息吗,或者尝试重新安装 koishi 看是否会出现同样的问题

我尝试了两种方法,一种是使用koishi-android,另一种是直接安装,都存在这个问题。我是不是在错误的地方提出issue了?是否应该归为koishi项目下?

shigma commented 1 year ago

确实可能是 array 的问题。我之后看一下。

我尝试了两种方法,一种是使用koishi-android,另一种是直接安装,都存在这个问题。我是不是在错误的地方提出issue了?是否应该归为koishi项目下?

是的。我来 transfer。

shigma commented 1 year ago

此问题已修复。@koishijs/plugin-adapter-onebot 刚刚发布了 5.5.5 版本。