diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt index e76a0b03d..269203099 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt @@ -270,7 +270,7 @@ interface MessageMetadata : SingleMessage { */ @SinceMirai("0.34.0") @MiraiExperimentalAPI -interface ConstrainSingle : MessageMetadata { +interface ConstrainSingle : MessageMetadata { val key: Message.Key } diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/MessageSource.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/MessageSource.kt index 2edbbfbb4..0fbf2ef61 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/MessageSource.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/MessageSource.kt @@ -39,12 +39,12 @@ import kotlin.jvm.JvmSynthetic */ @OptIn(MiraiExperimentalAPI::class) @SinceMirai("0.33.0") -sealed class MessageSource : Message, MessageMetadata, ConstrainSingle { +sealed class MessageSource : Message, MessageMetadata, ConstrainSingle { companion object Key : Message.Key { override val typeName: String get() = "MessageSource" } - final override val key: Message.Key get() = OnlineMessageSource + final override val key: Message.Key get() = Key /** * 所属 [Bot] @@ -153,13 +153,6 @@ sealed class OnlineMessageSource : MessageSource() { abstract override val target: QQ final override val subject: QQ get() = target // final override fun toString(): String = "OnlineMessageSource.ToFriend(target=${target.id})" - - @PlannedRemoval("1.0.0") - @Deprecated("for binary compatibility until 1.0.0", level = DeprecationLevel.HIDDEN) - @get:JvmName("sender") - @get:JvmSynthetic - final override val sender2: Bot - get() = sender } abstract class ToTemp : Outgoing() { @@ -188,8 +181,7 @@ sealed class OnlineMessageSource : MessageSource() { */ sealed class Incoming : OnlineMessageSource() { companion object Key : Message.Key { - override val typeName: String - get() = "OnlineMessageSource.Incoming" + override val typeName: String get() = "OnlineMessageSource.Incoming" } abstract override val sender: QQ // out QQ @@ -199,8 +191,7 @@ sealed class OnlineMessageSource : MessageSource() { abstract class FromFriend : Incoming() { companion object Key : Message.Key { - override val typeName: String - get() = "OnlineMessageSource.Incoming.FromFriend" + override val typeName: String get() = "OnlineMessageSource.Incoming.FromFriend" } abstract override val sender: QQ @@ -211,8 +202,7 @@ sealed class OnlineMessageSource : MessageSource() { abstract class FromTemp : Incoming() { companion object Key : Message.Key { - override val typeName: String - get() = "OnlineMessageSource.Incoming.FromTemp" + override val typeName: String get() = "OnlineMessageSource.Incoming.FromTemp" } abstract override val sender: Member @@ -223,8 +213,7 @@ sealed class OnlineMessageSource : MessageSource() { abstract class FromGroup : Incoming() { companion object Key : Message.Key { - override val typeName: String - get() = "OnlineMessageSource.Incoming.FromGroup" + override val typeName: String get() = "OnlineMessageSource.Incoming.FromGroup" } abstract override val sender: Member diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt index e19fce819..122b7a929 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt @@ -9,11 +9,12 @@ @file:JvmMultifileClass @file:JvmName("MessageUtils") -@file:Suppress("NOTHING_TO_INLINE") +@file:Suppress("NOTHING_TO_INLINE", "unused") package net.mamoe.mirai.message.data import kotlinx.coroutines.Job +import net.mamoe.mirai.Bot import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.utils.MiraiExperimentalAPI import net.mamoe.mirai.utils.SinceMirai @@ -47,6 +48,31 @@ class QuoteReply(val source: MessageSource) : Message, MessageMetadata, Constrai override fun contentToString(): String = "" } +@get:JvmSynthetic +inline val QuoteReply.id: Int + get() = source.id + +@get:JvmSynthetic +inline val QuoteReply.fromId: Long + get() = source.fromId + +@get:JvmSynthetic +inline val QuoteReply.targetId: Long + get() = source.targetId + +@get:JvmSynthetic +inline val QuoteReply.originalMessage: MessageChain + get() = source.originalMessage + +@get:JvmSynthetic +inline val QuoteReply.time: Int + get() = source.time + +@get:JvmSynthetic +inline val QuoteReply.bot: Bot + get() = source.bot + + @JvmSynthetic suspend inline fun QuoteReply.recall() = this.source.recall()