Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: adapter-satori 无法发送消息 #177

Closed
initialencounter opened this issue Nov 3, 2023 · 7 comments
Closed

Bug: adapter-satori 无法发送消息 #177

initialencounter opened this issue Nov 3, 2023 · 7 comments
Labels
bug Something isn't working protocol

Comments

@initialencounter
Copy link

我使用 adapter-satori 对接 chronocat是绿灯,但是机器人无法发送消息

image

日志

2023-11-03 15:48:13 [W] session undefined
                        TypeError: Cannot read properties of undefined (reading 'startsWith')
                            at _Session.<anonymous> (/root/ks/node_modules/@koishijs/core/lib/index.cjs:1514:22)
                            at Proxy.emit (/root/ks/node_modules/cordis/lib/index.cjs:106:16)
                            at _Processor.attach (/root/ks/node_modules/@koishijs/core/lib/index.cjs:1007:14)
                            at next (/root/ks/node_modules/@koishijs/core/lib/index.cjs:1053:69)
                            at /root/ks/node_modules/@koishijs/plugin-auth/lib/index.js:177:16
                            at next (/root/ks/node_modules/@koishijs/core/lib/index.cjs:1053:69)
                            at _Processor._handleMessage (/root/ks/node_modules/@koishijs/core/lib/index.cjs:1064:28)
                            at Proxy.emit (/root/ks/node_modules/cordis/lib/index.cjs:106:16)
                            at _SatoriBot.dispatch (/root/ks/node_modules/@satorijs/core/lib/index.cjs:323:20)
                            at WebSocket.<anonymous> (/root/ks/node_modules/@satorijs/adapter-satori/lib/index.js:177:13)
System:

OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)

CPU: (2) x64 Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz

Binaries:

Node: 18.16.0

Yarn: 1.22.19

Koishi:

Core: 4.15.3

Console: 5.18.0

补充:
adapter-red 是可以发送消息的,不知是 chronocat 的问题还是 adapter-satori 的问题

@shigma
Copy link
Contributor

shigma commented Nov 3, 2023

能看下报错位置的代码吗

@initialencounter
Copy link
Author

我不确定是不是这里
image

这是完整的报错的调用堆栈

2023-11-04 09:28:54 [W] session undefined
                        TypeError: Cannot read properties of undefined (reading 'startsWith')
                            at _Session.<anonymous> (C:\Users\29115\dev\ks\node_modules\@koishijs\core\lib\index.cjs:1514:22)
                            at Proxy.emit (C:\Users\29115\dev\ks\node_modules\cordis\lib\index.cjs:106:16)
                            at _Processor.attach (C:\Users\29115\dev\ks\node_modules\@koishijs\core\lib\index.cjs:1007:14)
                            at next (C:\Users\29115\dev\ks\node_modules\@koishijs\core\lib\index.cjs:1053:69)
                            at _Processor._handleMessage (C:\Users\29115\dev\ks\node_modules\@koishijs\core\lib\index.cjs:1064:28)
                            at Proxy.emit (C:\Users\29115\dev\ks\node_modules\cordis\lib\index.cjs:106:16)
                            at _SatoriBot.dispatch (C:\Users\29115\dev\ks\node_modules\@satorijs\core\lib\index.cjs:323:20)
                            at WebSocket.<anonymous> (C:\Users\29115\dev\ks\node_modules\@satorijs\adapter-satori\lib\index.js:177:13)
                            at callListener (C:\Users\29115\dev\ks\node_modules\ws\lib\event-target.js:290:14)
                            at WebSocket.onMessage (C:\Users\29115\dev\ks\node_modules\ws\lib\event-target.js:209:9)
                            at WebSocket.emit (node:events:514:28)
                            at Receiver.receiverOnMessage (C:\Users\29115\dev\ks\node_modules\ws\lib\websocket.js:1192:20)
                            at Receiver.emit (node:events:514:28)
                            at Receiver.dataMessage (C:\Users\29115\dev\ks\node_modules\ws\lib\receiver.js:560:14)
                            at Receiver.getData (C:\Users\29115\dev\ks\node_modules\ws\lib\receiver.js:478:17)
                            at Receiver.startLoop (C:\Users\29115\dev\ks\node_modules\ws\lib\receiver.js:167:22)
                            at Receiver._write (C:\Users\29115\dev\ks\node_modules\ws\lib\receiver.js:93:10)
                            at writeOrBuffer (node:internal/streams/writable:447:12)
                            at _write (node:internal/streams/writable:389:10)
                            at Writable.write (node:internal/streams/writable:393:10)
                            at Socket.socketOnData (C:\Users\29115\dev\ks\node_modules\ws\lib\websocket.js:1286:35)
                            at Socket.emit (node:events:514:28)
                            at addChunk (node:internal/streams/readable:376:12)
                            at readableAddChunk (node:internal/streams/readable:349:9)
                            at Readable.push (node:internal/streams/readable:286:10)
                            at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

@Anillc
Copy link
Contributor

Anillc commented Nov 9, 2023

satori protocol 的 Message 中没有 elements 属性,但是 Session 中默认了有这个属性。stripped 是个 getter, 他在读取 session.elements 的时候发现没有就返回 {} 了,所以 contentundefined。出现这个报错是收消息的阶段,而不是发消息。

@shigma
Copy link
Contributor

shigma commented Nov 9, 2023

感谢捉虫,会尽快修复。

@Apricityx
Copy link

我也遇到了同样的问题

@shigma
Copy link
Contributor

shigma commented Jan 28, 2024

@initialencounter 抱歉把这事忘了,请尝试 1.0.4 版本看看是否修复。

@shigma shigma added bug Something isn't working protocol labels Jan 28, 2024
@Apricityx
Copy link

@initialencounter 抱歉把这事忘了,请尝试 1.0.4 版本看看是否修复。

读消息貌似是没问题了,但是发消息还存在问题
chronocat版本:0.0.54
image

@shigma shigma closed this as completed in ff233e1 Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working protocol
Projects
None yet
Development

No branches or pull requests

4 participants