koishijs / koishi

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

Bug: `chat` 在 Bot 发图时报错 #703

Closed ilharp closed 2 years ago

ilharp commented 2 years ago

Describe the bug

6|harperneko  | 2022-05-28 17:50:18 [D] message [调试组] Eqluid: 猫猫
6|harperneko  | d2e.image]
6|harperneko  | 2022-05-28 17:50:18 [W] app TypeError: Cannot read properties of undefined (reading 'startsWith')
6|harperneko  |                             at null.<anonymous> (/files/proj/harperneko/node_modules/@koishijs/plugin-chat/src/index.ts:103:49)
6|harperneko  |                             at Array.some (<anonymous>)
6|harperneko  |                             at null.image (/files/proj/harperneko/node_modules/@koishijs/plugin-chat/src/index.ts:103:25)
6|harperneko  |                             at null.<anonymous> (/files/proj/harperneko/node_modules/@koishijs/segment/src/index.ts:107:53)
6|harperneko  |                             at Array.map (<anonymous>)
6|harperneko  |                             at Function.transform (/files/proj/harperneko/node_modules/@koishijs/segment/src/index.ts:104:18)
6|harperneko  |                             at null.<anonymous> (/files/proj/harperneko/node_modules/@koishijs/plugin-chat/src/index.ts:101:33)
6|harperneko  |                             at null.<anonymous> (/files/proj/harperneko/node_modules/cordis/src/lifecycle.ts:73:24)
6|harperneko  |                             at Array.map (<anonymous>)
6|harperneko  |                             at Lifecycle.parallel (/files/proj/harperneko/node_modules/cordis/src/lifecycle.ts:71:57)

Steps to reproduce

在 4.7.2 安装 chatassets-local,使用 teach 等插件调用 assets 发个图

Versions

# uname -a
Linux VM-4-12-ubuntu 5.4.0-77-generic #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
# node -v
v16.13.1
# yarn koishi -v
yarn run v1.22.17
$ koishi -v
koishi/4.7.0 linux-x64 node-v16.13.1

Additional context

除报了奇怪的错以外,日志显示貌似也不正常

不影响正常使用

shigma commented 2 years ago

可使用以下解决方案:

  1. 打开你的 gocqhttp 的配置文件,将 report-self-message 设置为 true
  2. 同时将 bot.reportSelfMessage 设置为 true

现版本为了兼容性 bot.reportSelfMessage 默认是 false,在下一个大版本会移除此配置项并强制 true。