mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-29 10:14:02 +08:00
[core] Fix offline message source quote replying; fix #2501
This commit is contained in:
parent
d8ef9ad282
commit
e686a23f40
@ -10,7 +10,6 @@
|
|||||||
package net.mamoe.mirai.internal.message.protocol.impl
|
package net.mamoe.mirai.internal.message.protocol.impl
|
||||||
|
|
||||||
import net.mamoe.mirai.contact.AnonymousMember
|
import net.mamoe.mirai.contact.AnonymousMember
|
||||||
import net.mamoe.mirai.contact.Group
|
|
||||||
import net.mamoe.mirai.internal.message.protocol.MessageProtocol
|
import net.mamoe.mirai.internal.message.protocol.MessageProtocol
|
||||||
import net.mamoe.mirai.internal.message.protocol.ProcessorCollector
|
import net.mamoe.mirai.internal.message.protocol.ProcessorCollector
|
||||||
import net.mamoe.mirai.internal.message.protocol.decode.MessageDecoder
|
import net.mamoe.mirai.internal.message.protocol.decode.MessageDecoder
|
||||||
@ -20,7 +19,6 @@ import net.mamoe.mirai.internal.message.protocol.decode.MessageDecoderContext.Co
|
|||||||
import net.mamoe.mirai.internal.message.protocol.decode.MessageDecoderContext.Companion.MESSAGE_SOURCE_KIND
|
import net.mamoe.mirai.internal.message.protocol.decode.MessageDecoderContext.Companion.MESSAGE_SOURCE_KIND
|
||||||
import net.mamoe.mirai.internal.message.protocol.encode.MessageEncoder
|
import net.mamoe.mirai.internal.message.protocol.encode.MessageEncoder
|
||||||
import net.mamoe.mirai.internal.message.protocol.encode.MessageEncoderContext
|
import net.mamoe.mirai.internal.message.protocol.encode.MessageEncoderContext
|
||||||
import net.mamoe.mirai.internal.message.protocol.encode.MessageEncoderContext.Companion.contact
|
|
||||||
import net.mamoe.mirai.internal.message.protocol.outgoing.OutgoingMessagePreprocessor
|
import net.mamoe.mirai.internal.message.protocol.outgoing.OutgoingMessagePreprocessor
|
||||||
import net.mamoe.mirai.internal.message.protocol.serialization.MessageSerializer
|
import net.mamoe.mirai.internal.message.protocol.serialization.MessageSerializer
|
||||||
import net.mamoe.mirai.internal.message.source.*
|
import net.mamoe.mirai.internal.message.source.*
|
||||||
@ -154,9 +152,11 @@ internal class QuoteReplyProtocol : MessageProtocol(PRIORITY_METADATA) {
|
|||||||
private class Encoder : MessageEncoder<QuoteReply> {
|
private class Encoder : MessageEncoder<QuoteReply> {
|
||||||
override suspend fun MessageEncoderContext.process(data: QuoteReply) {
|
override suspend fun MessageEncoderContext.process(data: QuoteReply) {
|
||||||
val source = data.source as? MessageSourceInternal ?: return
|
val source = data.source as? MessageSourceInternal ?: return
|
||||||
|
val sourceCommon = source as MessageSource
|
||||||
|
|
||||||
markAsConsumed()
|
markAsConsumed()
|
||||||
collect(ImMsgBody.Elem(srcMsg = source.toJceData()))
|
collect(ImMsgBody.Elem(srcMsg = source.toJceData()))
|
||||||
if (contact is Group) {
|
if (sourceCommon.kind == MessageSourceKind.GROUP) {
|
||||||
if (source is OnlineMessageSource.Incoming.FromGroup) {
|
if (source is OnlineMessageSource.Incoming.FromGroup) {
|
||||||
val sender0 = source.sender
|
val sender0 = source.sender
|
||||||
if (sender0 !is AnonymousMember) {
|
if (sender0 !is AnonymousMember) {
|
||||||
@ -165,6 +165,9 @@ internal class QuoteReplyProtocol : MessageProtocol(PRIORITY_METADATA) {
|
|||||||
// transformOneMessage(PlainText(" "))
|
// transformOneMessage(PlainText(" "))
|
||||||
// removed by https://github.com/mamoe/mirai/issues/524
|
// removed by https://github.com/mamoe/mirai/issues/524
|
||||||
// 发送 QuoteReply 消息时无可避免的产生多余空格 #524
|
// 发送 QuoteReply 消息时无可避免的产生多余空格 #524
|
||||||
|
} else if (sourceCommon.fromId != 80000000L) {
|
||||||
|
// https://github.com/mamoe/mirai/issues/2501 OfflineMessageSource quote replying
|
||||||
|
processAlso(At(sourceCommon.fromId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,12 @@ internal class QuoteReplyProtocolTest : AbstractMessageProtocolTest() {
|
|||||||
// mirai's OfflineMessageSource has no enough information to create 'srcMsg'
|
// mirai's OfflineMessageSource has no enough information to create 'srcMsg'
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||||
|
text = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Text(
|
||||||
|
str = "@",
|
||||||
|
attr6Buf = "00 01 00 00 00 01 00 00 12 C4 B1 00 00".hexToBytes(),
|
||||||
|
),
|
||||||
|
),
|
||||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||||
text = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Text(
|
text = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Text(
|
||||||
str = "s",
|
str = "s",
|
||||||
|
Loading…
Reference in New Issue
Block a user