We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
bot.editMessage
同样一个 message elements,直接 session.send 发送能正常渲染,但是 editMessage 无法正确渲染。
session.send
editMessage
this.ctx.command('test <prompt:string>') .action(async (argv: Argv, prompt: string) => { const msgStr = '"city 4" - <at id="4444" />'; const msg = h.parse(msgStr); await this.ctx.bots[0].editMessage( '4444', '4444', msg, ); await argv.session.send(msgStr); });
见上述代码。
预期和 session.send 有一致的渲染表现。
No response
The text was updated successfully, but these errors were encountered:
主要问题就是在 Discord 的 editMessage 不会将 Satori 的 Fragment 转换为对应平台的格式 然后直接发送出去了, 然后平台 (Discord) 不认 Satori Elements, 就直接显示了
session.send 调用 bot.sendMessage L150
bot.sendMessage
koishi/packages/core/src/session.ts
Lines 147 to 154 in eb42c4d
然后看这边, 调用了 bot.createMessage L167 https://github.com/satorijs/satori/blob/5c0b8d6d715df11908ec3be8efbfe9bf31868bc3/packages/core/src/bot.ts#L167
bot.createMessage
然后用了 MessageEncoder 进行转换 - 将 Satori Elements 转换成对应平台的东西, L163 https://github.com/satorijs/satori/blob/5c0b8d6d715df11908ec3be8efbfe9bf31868bc3/packages/core/src/message.ts#L26
然后 MessageEncoder DiscordMessageEncoder 的 .flush() 再调用 Discord 内部的 API 发送出去 https://github.com/satorijs/satori/blob/5c0b8d6d715df11908ec3be8efbfe9bf31868bc3/packages/core/src/bot.ts#L163
MessageEncoder
.flush()
拿到 session, 直接调用 bot.editMessage https://github.com/satorijs/satori/blob/5c0b8d6d715df11908ec3be8efbfe9bf31868bc3/adapters/discord/src/bot.ts#L71-L81 这边用 h.normalize 确保了是 Satori Elements... L72 然后直接 toString 了??? L63 这边可以看到没有做任何对应平台的转换 https://github.com/satorijs/satori/blob/5c0b8d6d715df11908ec3be8efbfe9bf31868bc3/adapters/discord/src/bot.ts#L72-L73 然后调用了内部的 editMessage 方法, 向 Discord 的 Bot API 发送请求来 edit https://github.com/satorijs/satori/blob/5c0b8d6d715df11908ec3be8efbfe9bf31868bc3/adapters/discord/src/bot.ts#L78 然而 Discord 肯定是不认 Satori Elements 的, 然后就直接显示出来了
session
h.normalize
Sorry, something went wrong.
这是 bug,会修。
No branches or pull requests
Describe the bug
同样一个 message elements,直接
session.send
发送能正常渲染,但是editMessage
无法正确渲染。Steps to reproduce
见上述代码。
Expected behavior
预期和
session.send
有一致的渲染表现。Screenshots
No response
Versions
Additional context
No response
The text was updated successfully, but these errors were encountered: