Skip to content

请问图片消息无法序列化怎么办啊 #110

Answered by ForteScarlet
buliang9988 asked this question in Q&A
Discussion options

You must be logged in to vote

消息序列化参考 https://simbot.forte.love/docs/definition/message-overview/message-serialization

如果希望精准控制序列化中具体类型和对应方式,请自行遍历所有消息元素并自行处理

var messages = ...

for (var message : messages) {
    if (message instanceof MiraiImage image) {
        // 如果是mirai图片类型
    } else if (message instanceof Image<?> image) {
        // 其他未知的image类型
    } else if (message instanceof PlainText<?> text) {
        // 文本消息
    } else {
        // 其他...
    }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ForteScarlet
Comment options

Answer selected by buliang9988
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
组件:mirai 与mirai组件有关的内容
2 participants