From c30b3a285a736e29a13670e4c69de0f2cf6574e9 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 14 Jan 2022 20:15:03 +0000 Subject: [PATCH] Move MessageSource implementations from `.message` to `.message.source` --- mirai-core/src/commonMain/kotlin/MiraiImpl.kt | 8 ++++++++ .../src/commonMain/kotlin/contact/NormalMemberImpl.kt | 2 +- .../commonMain/kotlin/contact/SendMessageHandler.kt | 2 ++ .../src/commonMain/kotlin/contact/StrangerImpl.kt | 2 +- .../commonMain/kotlin/message/MessageSourceInternal.kt | 1 + .../commonMain/kotlin/message/ReceiveMessageHandler.kt | 1 + .../kotlin/message/{ => source}/incomingSourceImpl.kt | 5 ++++- .../kotlin/message/{ => source}/offlineSourceImpl.kt | 6 +++++- .../kotlin/message/{ => source}/outgoingSourceImpl.kt | 6 +++++- .../network/notice/priv/OtherClientNoticeProcessor.kt | 10 +++++----- .../packet/chat/receive/MessageSvc.PbSendMsg.kt | 8 +++++++- .../message/CleanupRubbishMessageElementsTest.kt | 3 ++- .../commonTest/kotlin/notice/processors/RecallTest.kt | 4 ++-- .../jvmTest/kotlin/message/data/MessageReceiptTest.kt | 10 ++++++---- .../jvmTest/kotlin/message/data/MessageRefineTest.kt | 10 +++++----- 15 files changed, 55 insertions(+), 23 deletions(-) rename mirai-core/src/commonMain/kotlin/message/{ => source}/incomingSourceImpl.kt (97%) rename mirai-core/src/commonMain/kotlin/message/{ => source}/offlineSourceImpl.kt (95%) rename mirai-core/src/commonMain/kotlin/message/{ => source}/outgoingSourceImpl.kt (97%) diff --git a/mirai-core/src/commonMain/kotlin/MiraiImpl.kt b/mirai-core/src/commonMain/kotlin/MiraiImpl.kt index f7503a9ba..a27671144 100644 --- a/mirai-core/src/commonMain/kotlin/MiraiImpl.kt +++ b/mirai-core/src/commonMain/kotlin/MiraiImpl.kt @@ -35,6 +35,14 @@ import net.mamoe.mirai.internal.event.EventChannelToEventDispatcherAdapter import net.mamoe.mirai.internal.event.InternalEventMechanism import net.mamoe.mirai.internal.message.* import net.mamoe.mirai.internal.message.DeepMessageRefiner.refineDeep +import net.mamoe.mirai.internal.message.source.* +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceFromFriendImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceFromGroupImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceFromStrangerImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceFromTempImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToFriendImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToStrangerImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToTempImpl import net.mamoe.mirai.internal.network.components.EventDispatcher import net.mamoe.mirai.internal.network.highway.ChannelKind import net.mamoe.mirai.internal.network.highway.ResourceKind diff --git a/mirai-core/src/commonMain/kotlin/contact/NormalMemberImpl.kt b/mirai-core/src/commonMain/kotlin/contact/NormalMemberImpl.kt index 05177e0bb..3cc1ea58e 100644 --- a/mirai-core/src/commonMain/kotlin/contact/NormalMemberImpl.kt +++ b/mirai-core/src/commonMain/kotlin/contact/NormalMemberImpl.kt @@ -19,8 +19,8 @@ import net.mamoe.mirai.contact.* import net.mamoe.mirai.data.MemberInfo import net.mamoe.mirai.event.broadcast import net.mamoe.mirai.event.events.* -import net.mamoe.mirai.internal.message.OnlineMessageSourceToTempImpl import net.mamoe.mirai.internal.message.createMessageReceipt +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToTempImpl import net.mamoe.mirai.internal.network.protocol.packet.chat.TroopManagement import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.message.data.Message diff --git a/mirai-core/src/commonMain/kotlin/contact/SendMessageHandler.kt b/mirai-core/src/commonMain/kotlin/contact/SendMessageHandler.kt index f26b387ae..a7c0eab43 100644 --- a/mirai-core/src/commonMain/kotlin/contact/SendMessageHandler.kt +++ b/mirai-core/src/commonMain/kotlin/contact/SendMessageHandler.kt @@ -20,6 +20,8 @@ import net.mamoe.mirai.event.nextEvent import net.mamoe.mirai.internal.asQQAndroidBot import net.mamoe.mirai.internal.getMiraiImpl import net.mamoe.mirai.internal.message.* +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToFriendImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToGroupImpl import net.mamoe.mirai.internal.network.Packet import net.mamoe.mirai.internal.network.QQAndroidClient import net.mamoe.mirai.internal.network.components.ClockHolder.Companion.clock diff --git a/mirai-core/src/commonMain/kotlin/contact/StrangerImpl.kt b/mirai-core/src/commonMain/kotlin/contact/StrangerImpl.kt index 26213da79..a5e9dea93 100644 --- a/mirai-core/src/commonMain/kotlin/contact/StrangerImpl.kt +++ b/mirai-core/src/commonMain/kotlin/contact/StrangerImpl.kt @@ -25,8 +25,8 @@ import net.mamoe.mirai.data.StrangerInfo import net.mamoe.mirai.event.events.StrangerMessagePostSendEvent import net.mamoe.mirai.event.events.StrangerMessagePreSendEvent import net.mamoe.mirai.internal.QQAndroidBot -import net.mamoe.mirai.internal.message.OnlineMessageSourceToStrangerImpl import net.mamoe.mirai.internal.message.createMessageReceipt +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToStrangerImpl import net.mamoe.mirai.internal.network.protocol.packet.list.StrangerList import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.message.data.Message diff --git a/mirai-core/src/commonMain/kotlin/message/MessageSourceInternal.kt b/mirai-core/src/commonMain/kotlin/message/MessageSourceInternal.kt index fc5c6cff7..cc6917d74 100644 --- a/mirai-core/src/commonMain/kotlin/message/MessageSourceInternal.kt +++ b/mirai-core/src/commonMain/kotlin/message/MessageSourceInternal.kt @@ -14,6 +14,7 @@ import net.mamoe.mirai.contact.Contact import net.mamoe.mirai.internal.contact.SendMessageHandler import net.mamoe.mirai.internal.message.LightMessageRefiner.dropMiraiInternalFlags import net.mamoe.mirai.internal.message.LightMessageRefiner.refineLight +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToGroupImpl import net.mamoe.mirai.internal.message.visitor.ex import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody import net.mamoe.mirai.message.MessageReceipt diff --git a/mirai-core/src/commonMain/kotlin/message/ReceiveMessageHandler.kt b/mirai-core/src/commonMain/kotlin/message/ReceiveMessageHandler.kt index 68699a7ff..db01953f2 100644 --- a/mirai-core/src/commonMain/kotlin/message/ReceiveMessageHandler.kt +++ b/mirai-core/src/commonMain/kotlin/message/ReceiveMessageHandler.kt @@ -19,6 +19,7 @@ import net.mamoe.mirai.internal.message.LightMessageRefiner.refineLight import net.mamoe.mirai.internal.message.ReceiveMessageTransformer.cleanupRubbishMessageElements import net.mamoe.mirai.internal.message.ReceiveMessageTransformer.joinToMessageChain import net.mamoe.mirai.internal.message.ReceiveMessageTransformer.toAudio +import net.mamoe.mirai.internal.message.source.* import net.mamoe.mirai.internal.network.protocol.data.proto.* import net.mamoe.mirai.internal.utils.io.serialization.loadAs import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf diff --git a/mirai-core/src/commonMain/kotlin/message/incomingSourceImpl.kt b/mirai-core/src/commonMain/kotlin/message/source/incomingSourceImpl.kt similarity index 97% rename from mirai-core/src/commonMain/kotlin/message/incomingSourceImpl.kt rename to mirai-core/src/commonMain/kotlin/message/source/incomingSourceImpl.kt index b57d1856d..3e02d7162 100644 --- a/mirai-core/src/commonMain/kotlin/message/incomingSourceImpl.kt +++ b/mirai-core/src/commonMain/kotlin/message/source/incomingSourceImpl.kt @@ -9,7 +9,7 @@ @file:Suppress("EXPERIMENTAL_API_USAGE", "EXPERIMENTAL_OVERRIDE", "INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") -package net.mamoe.mirai.internal.message +package net.mamoe.mirai.internal.message.source import kotlinx.serialization.Serializable import kotlinx.serialization.Transient @@ -22,6 +22,9 @@ import net.mamoe.mirai.internal.contact.GroupImpl import net.mamoe.mirai.internal.contact.checkIsGroupImpl import net.mamoe.mirai.internal.contact.newAnonymous import net.mamoe.mirai.internal.getGroupByUinOrCodeOrFail +import net.mamoe.mirai.internal.message.IncomingMessageSourceInternal +import net.mamoe.mirai.internal.message.MessageSourceSerializerImpl +import net.mamoe.mirai.internal.message.toMessageChainNoSource import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm import net.mamoe.mirai.internal.network.protocol.data.proto.SourceMsg diff --git a/mirai-core/src/commonMain/kotlin/message/offlineSourceImpl.kt b/mirai-core/src/commonMain/kotlin/message/source/offlineSourceImpl.kt similarity index 95% rename from mirai-core/src/commonMain/kotlin/message/offlineSourceImpl.kt rename to mirai-core/src/commonMain/kotlin/message/source/offlineSourceImpl.kt index 5775316f0..31e173a50 100644 --- a/mirai-core/src/commonMain/kotlin/message/offlineSourceImpl.kt +++ b/mirai-core/src/commonMain/kotlin/message/source/offlineSourceImpl.kt @@ -8,11 +8,15 @@ */ -package net.mamoe.mirai.internal.message +package net.mamoe.mirai.internal.message.source import kotlinx.serialization.Serializable import kotlinx.serialization.Transient import net.mamoe.mirai.Bot +import net.mamoe.mirai.internal.message.MessageSourceInternal +import net.mamoe.mirai.internal.message.MessageSourceSerializerImpl +import net.mamoe.mirai.internal.message.toMessageChainNoSource +import net.mamoe.mirai.internal.message.toRichTextElems import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm import net.mamoe.mirai.internal.network.protocol.data.proto.SourceMsg diff --git a/mirai-core/src/commonMain/kotlin/message/outgoingSourceImpl.kt b/mirai-core/src/commonMain/kotlin/message/source/outgoingSourceImpl.kt similarity index 97% rename from mirai-core/src/commonMain/kotlin/message/outgoingSourceImpl.kt rename to mirai-core/src/commonMain/kotlin/message/source/outgoingSourceImpl.kt index bed5f7734..c4da8df82 100644 --- a/mirai-core/src/commonMain/kotlin/message/outgoingSourceImpl.kt +++ b/mirai-core/src/commonMain/kotlin/message/source/outgoingSourceImpl.kt @@ -9,7 +9,7 @@ @file:Suppress("EXPERIMENTAL_API_USAGE", "EXPERIMENTAL_OVERRIDE", "INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") -package net.mamoe.mirai.internal.message +package net.mamoe.mirai.internal.message.source import kotlinx.coroutines.* import kotlinx.serialization.Serializable @@ -19,6 +19,10 @@ import net.mamoe.mirai.event.EventPriority import net.mamoe.mirai.event.GlobalEventChannel import net.mamoe.mirai.event.syncFromEvent import net.mamoe.mirai.internal.contact.uin +import net.mamoe.mirai.internal.message.MessageSourceInternal +import net.mamoe.mirai.internal.message.MessageSourceSerializerImpl +import net.mamoe.mirai.internal.message.OutgoingMessageSourceInternal +import net.mamoe.mirai.internal.message.toRichTextElems import net.mamoe.mirai.internal.network.notice.group.GroupMessageProcessor.SendGroupMessageReceipt import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm diff --git a/mirai-core/src/commonMain/kotlin/network/notice/priv/OtherClientNoticeProcessor.kt b/mirai-core/src/commonMain/kotlin/network/notice/priv/OtherClientNoticeProcessor.kt index 855fdbe48..c76e5f7be 100644 --- a/mirai-core/src/commonMain/kotlin/network/notice/priv/OtherClientNoticeProcessor.kt +++ b/mirai-core/src/commonMain/kotlin/network/notice/priv/OtherClientNoticeProcessor.kt @@ -1,10 +1,10 @@ /* - * Copyright 2019-2021 Mamoe Technologies and contributors. + * Copyright 2019-2022 Mamoe Technologies and contributors. * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * - * https://github.com/mamoe/mirai/blob/master/LICENSE + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ package net.mamoe.mirai.internal.network.notice.priv @@ -22,8 +22,8 @@ import net.mamoe.mirai.event.events.OtherClientOfflineEvent import net.mamoe.mirai.event.events.OtherClientOnlineEvent import net.mamoe.mirai.internal.contact.appId import net.mamoe.mirai.internal.contact.createOtherClient -import net.mamoe.mirai.internal.message.OnlineMessageSourceFromFriendImpl import net.mamoe.mirai.internal.message.contextualBugReportException +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceFromFriendImpl import net.mamoe.mirai.internal.network.components.ContactUpdater import net.mamoe.mirai.internal.network.components.MixedNoticeProcessor import net.mamoe.mirai.internal.network.components.NoticePipelineContext diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt index 4a3f1c84f..ba49a761d 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt @@ -20,7 +20,13 @@ import net.mamoe.mirai.contact.Stranger import net.mamoe.mirai.internal.QQAndroidBot import net.mamoe.mirai.internal.contact.groupCode import net.mamoe.mirai.internal.contact.uin -import net.mamoe.mirai.internal.message.* +import net.mamoe.mirai.internal.message.ForwardMessageInternal +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToFriendImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToGroupImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToStrangerImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToTempImpl +import net.mamoe.mirai.internal.message.toPtt +import net.mamoe.mirai.internal.message.toRichTextElems import net.mamoe.mirai.internal.network.Packet import net.mamoe.mirai.internal.network.QQAndroidClient import net.mamoe.mirai.internal.network.components.ClockHolder.Companion.clock diff --git a/mirai-core/src/commonTest/kotlin/message/CleanupRubbishMessageElementsTest.kt b/mirai-core/src/commonTest/kotlin/message/CleanupRubbishMessageElementsTest.kt index 14a358075..c3bc5bddc 100644 --- a/mirai-core/src/commonTest/kotlin/message/CleanupRubbishMessageElementsTest.kt +++ b/mirai-core/src/commonTest/kotlin/message/CleanupRubbishMessageElementsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 Mamoe Technologies and contributors. + * Copyright 2019-2022 Mamoe Technologies and contributors. * * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. @@ -10,6 +10,7 @@ package net.mamoe.mirai.internal.message import net.mamoe.mirai.internal.message.ReceiveMessageTransformer.cleanupRubbishMessageElements +import net.mamoe.mirai.internal.message.source.OfflineMessageSourceImplData import net.mamoe.mirai.message.data.* import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance diff --git a/mirai-core/src/commonTest/kotlin/notice/processors/RecallTest.kt b/mirai-core/src/commonTest/kotlin/notice/processors/RecallTest.kt index a93c9411f..958da8c43 100644 --- a/mirai-core/src/commonTest/kotlin/notice/processors/RecallTest.kt +++ b/mirai-core/src/commonTest/kotlin/notice/processors/RecallTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 Mamoe Technologies and contributors. + * Copyright 2019-2022 Mamoe Technologies and contributors. * * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. @@ -13,7 +13,7 @@ import net.mamoe.mirai.Bot import net.mamoe.mirai.Mirai import net.mamoe.mirai.contact.MemberPermission import net.mamoe.mirai.contact.PermissionDeniedException -import net.mamoe.mirai.internal.message.OnlineMessageSourceFromGroupImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceFromGroupImpl import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm import net.mamoe.mirai.message.data.OnlineMessageSource diff --git a/mirai-core/src/jvmTest/kotlin/message/data/MessageReceiptTest.kt b/mirai-core/src/jvmTest/kotlin/message/data/MessageReceiptTest.kt index 49896a086..33e4f9a80 100644 --- a/mirai-core/src/jvmTest/kotlin/message/data/MessageReceiptTest.kt +++ b/mirai-core/src/jvmTest/kotlin/message/data/MessageReceiptTest.kt @@ -17,7 +17,7 @@ import net.mamoe.mirai.internal.MockBot import net.mamoe.mirai.internal.contact.* import net.mamoe.mirai.internal.contact.info.GroupInfoImpl import net.mamoe.mirai.internal.message.ForwardMessageInternal -import net.mamoe.mirai.internal.message.OnlineMessageSourceToGroupImpl +import net.mamoe.mirai.internal.message.source.OnlineMessageSourceToGroupImpl import net.mamoe.mirai.internal.network.QQAndroidClient import net.mamoe.mirai.internal.network.protocol.data.jce.StTroopNum import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket @@ -69,9 +69,11 @@ internal class MessageReceiptTest : AbstractTestWithMiraiImpl() { sender = bot, target = group, time = currentTimeSeconds().toInt(), - originalMessage = message //, - // sourceMessage = message - ))) + originalMessage = message //, + // sourceMessage = message + ) + ) + ) listOf() } } diff --git a/mirai-core/src/jvmTest/kotlin/message/data/MessageRefineTest.kt b/mirai-core/src/jvmTest/kotlin/message/data/MessageRefineTest.kt index c739ee441..3d19c2020 100644 --- a/mirai-core/src/jvmTest/kotlin/message/data/MessageRefineTest.kt +++ b/mirai-core/src/jvmTest/kotlin/message/data/MessageRefineTest.kt @@ -1,10 +1,10 @@ /* - * Copyright 2019-2021 Mamoe Technologies and contributors. + * Copyright 2019-2022 Mamoe Technologies and contributors. * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * - * https://github.com/mamoe/mirai/blob/master/LICENSE + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @@ -18,10 +18,10 @@ import net.mamoe.mirai.internal.MockBot import net.mamoe.mirai.internal.getMiraiImpl import net.mamoe.mirai.internal.message.DeepMessageRefiner.refineDeep import net.mamoe.mirai.internal.message.LightMessageRefiner.refineLight -import net.mamoe.mirai.internal.message.OfflineMessageSourceImplData import net.mamoe.mirai.internal.message.ReceiveMessageTransformer import net.mamoe.mirai.internal.message.RefinableMessage import net.mamoe.mirai.internal.message.RefineContext +import net.mamoe.mirai.internal.message.source.OfflineMessageSourceImplData import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm import net.mamoe.mirai.internal.network.protocol.data.proto.MsgTransmit