请问图片消息无法序列化怎么办啊 #110
Answered
by
ForteScarlet
buliang9988
asked this question in
Q&A
-
涉及的编程语言Java 涉及的组件库mirai (QQ) 疑问描述在弄一个自定义词库模块,普通消息可以通过序列化的方式存入数据库,但是一旦有图片就无法继续了 |
Beta Was this translation helpful? Give feedback.
Answered by
ForteScarlet
Mar 15, 2023
Replies: 1 comment 1 reply
-
消息序列化参考 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 {
// 其他...
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
buliang9988
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
消息序列化参考 https://simbot.forte.love/docs/definition/message-overview/message-serialization
如果希望精准控制序列化中具体类型和对应方式,请自行遍历所有消息元素并自行处理