-
使用MessageEvent接收消息,任何单条消息都有2长度,以下是打印出来的详情:
他不是序列号也不是时间也不是发送者的QQ号甚至还有负数,mirai:source也不在 https://github.com/mamoe/mirai/blob/master/docs/mirai-code-specification.md 中有解释。 请问应该如何处理?size() = 2 时必定为单条消息?直接取MessageChain.get(1)? |
Beta Was this translation helpful? Give feedback.
Answered by
Karlatemp
Dec 12, 2020
Replies: 2 comments 1 reply
-
这是 可以 filter is MessageContent 然后判断 size |
Beta Was this translation helpful? Give feedback.
0 replies
-
这是 // kotlin
// message: MessageChain
val msg = message.filterIsInstance<MessageContent>() // java
@SuppressWarnings({"rawtypes", "unchecked"})
private static List<MessageContent> content(MessageChain msg) {
return (List) msg.stream()
.filter(it -> it instanceof MessageContent)
.collect(Collectors.toList());
} 另注: |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Him188
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
这是
MessageSource
, 存放该信息来源, 若只需要信息内容, 请参考以下代码另注:
size() = 2
时也不一定是一条信息, 可能还会存在QuoteReply
(回复信息)