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
session.execute("", true)
session.execute(___, true) 时,无法用字符串正确地表示的消息元素被错误地序列化成了字符串。
session.execute(___, true)
ctx.command("foo").action(() => ( <html> <div style={{ backgroundColor: green }}>Hello, world!</div> </html> )) ctx.command("bar").action(async ({ session }) => { return ( <> <p>foo 指令的执行结果:</p> {h.parse(await session.execute("foo", true))} // <-- <html><div style="[object Object]">Hello, world!</div></html> </> ) })
session.execute(___, true) 应提供一种方法以允许取得含有消息组件的指令结果的元素形式,或始终将消息组件展开成基本元素后以字符串形式返回,而不是直接将可能含有消息组件的内容序列化成字符串。
No response
koishi/packages/core/src/session.ts
Lines 395 to 398 in 5f1610e
一种可能的解决方案:对指令结果执行 session.transform() 展开成基本元素后再以字符串形式返回。
session.transform()
或许可以让 session.execute() 提供一个新的 transform?: boolean 参数,默认为 true;设为 false 时,直接将指令结果原样返回(或 h.parse 后返回)。这样即可在不改变 session.execute(___, true) 返回值类型,且保证其有一个合理的返回值的前提下,允许从外部获取指令所返回的未经解析的消息组件结构。
session.execute()
transform?: boolean
true
false
h.parse
The text was updated successfully, but these errors were encountered:
cc @MaikoTan
Sorry, something went wrong.
d69e934
Successfully merging a pull request may close this issue.
Describe the bug
session.execute(___, true)
时,无法用字符串正确地表示的消息元素被错误地序列化成了字符串。Steps to reproduce
Expected behavior
session.execute(___, true)
应提供一种方法以允许取得含有消息组件的指令结果的元素形式,或始终将消息组件展开成基本元素后以字符串形式返回,而不是直接将可能含有消息组件的内容序列化成字符串。Screenshots
No response
Versions
Additional context
koishi/packages/core/src/session.ts
Lines 395 to 398 in 5f1610e
一种可能的解决方案:对指令结果执行
session.transform()
展开成基本元素后再以字符串形式返回。或许可以让
session.execute()
提供一个新的transform?: boolean
参数,默认为true
;设为false
时,直接将指令结果原样返回(或h.parse
后返回)。这样即可在不改变session.execute(___, true)
返回值类型,且保证其有一个合理的返回值的前提下,允许从外部获取指令所返回的未经解析的消息组件结构。The text was updated successfully, but these errors were encountered: