[core] Make MessageSource.kind a member not extension

This commit is contained in:
Karlatemp 2023-03-24 16:27:47 +08:00
parent 9c77c22b32
commit 893fb3e9f6
No known key found for this signature in database
GPG Key ID: BA173CA2B9956C59
5 changed files with 56 additions and 23 deletions

View File

@ -4540,6 +4540,7 @@ public abstract class net/mamoe/mirai/message/data/MessageSource : net/mamoe/mir
public abstract fun getIds ()[I
public abstract fun getInternalIds ()[I
public final fun getKey ()Lnet/mamoe/mirai/message/data/MessageKey;
public abstract fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public abstract fun getOriginalMessage ()Lnet/mamoe/mirai/message/data/MessageChain;
public abstract fun getTargetId ()J
public abstract fun getTime ()I
@ -4666,8 +4667,8 @@ public final class net/mamoe/mirai/message/data/MessageUtils {
public static final synthetic fun getContent (Lnet/mamoe/mirai/message/data/Message;)Ljava/lang/String;
public static final synthetic fun getIds (Lnet/mamoe/mirai/message/data/MessageChain;)[I
public static final synthetic fun getInternalId (Lnet/mamoe/mirai/message/data/MessageChain;)[I
public static final fun getKind (Lnet/mamoe/mirai/message/data/MessageSource;)Lnet/mamoe/mirai/message/data/MessageSourceKind;
public static final fun getKind (Lnet/mamoe/mirai/message/data/OnlineMessageSource;)Lnet/mamoe/mirai/message/data/MessageSourceKind;
public static final synthetic fun getKind (Lnet/mamoe/mirai/message/data/MessageSource;)Lnet/mamoe/mirai/message/data/MessageSourceKind;
public static final synthetic fun getKind (Lnet/mamoe/mirai/message/data/OnlineMessageSource;)Lnet/mamoe/mirai/message/data/MessageSourceKind;
public static final synthetic fun getLengthDuration (Lnet/mamoe/mirai/message/data/OnlineAudio;)J
public static final synthetic fun getOrFail (Lnet/mamoe/mirai/message/data/MessageChain;Lnet/mamoe/mirai/message/data/MessageKey;Lkotlin/jvm/functions/Function1;)Lnet/mamoe/mirai/message/data/SingleMessage;
public static synthetic fun getOrFail$default (Lnet/mamoe/mirai/message/data/MessageChain;Lnet/mamoe/mirai/message/data/MessageKey;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lnet/mamoe/mirai/message/data/SingleMessage;
@ -4816,6 +4817,7 @@ public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromFriend : net/mamoe/mirai/message/data/OnlineMessageSource$Incoming {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromFriend$Key;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public abstract fun getSender ()Lnet/mamoe/mirai/contact/Friend;
public abstract fun getSubject ()Lnet/mamoe/mirai/contact/Friend;
public final synthetic fun getTarget ()Lnet/mamoe/mirai/Bot;
@ -4829,6 +4831,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$Fro
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromGroup : net/mamoe/mirai/message/data/OnlineMessageSource$Incoming {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromGroup$Key;
public final fun getGroup ()Lnet/mamoe/mirai/contact/Group;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public abstract fun getSender ()Lnet/mamoe/mirai/contact/Member;
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
public fun getSubject ()Lnet/mamoe/mirai/contact/Group;
@ -4842,6 +4845,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$Fro
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromStranger : net/mamoe/mirai/message/data/OnlineMessageSource$Incoming {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromStranger$Key;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public abstract fun getSender ()Lnet/mamoe/mirai/contact/Stranger;
public abstract fun getSubject ()Lnet/mamoe/mirai/contact/Stranger;
public final synthetic fun getTarget ()Lnet/mamoe/mirai/Bot;
@ -4855,6 +4859,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$Fro
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromTemp : net/mamoe/mirai/message/data/OnlineMessageSource$Incoming {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromTemp$Key;
public final fun getGroup ()Lnet/mamoe/mirai/contact/Group;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public abstract fun getSender ()Lnet/mamoe/mirai/contact/Member;
public abstract fun getSubject ()Lnet/mamoe/mirai/contact/Member;
public final synthetic fun getTarget ()Lnet/mamoe/mirai/Bot;
@ -4884,6 +4889,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$Key
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToFriend : net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToFriend$Key;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
public final fun getSubject ()Lnet/mamoe/mirai/contact/Friend;
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Friend;
@ -4895,6 +4901,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToF
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToGroup : net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToGroup$Key;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
public final fun getSubject ()Lnet/mamoe/mirai/contact/Group;
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Group;
@ -4906,6 +4913,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToG
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToStranger : net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToStranger$Key;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
public final fun getSubject ()Lnet/mamoe/mirai/contact/Stranger;
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Stranger;
@ -4918,6 +4926,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToS
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToTemp : net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToTemp$Key;
public final fun getGroup ()Lnet/mamoe/mirai/contact/Group;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
public final fun getSubject ()Lnet/mamoe/mirai/contact/Member;
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Member;

View File

@ -4540,6 +4540,7 @@ public abstract class net/mamoe/mirai/message/data/MessageSource : net/mamoe/mir
public abstract fun getIds ()[I
public abstract fun getInternalIds ()[I
public final fun getKey ()Lnet/mamoe/mirai/message/data/MessageKey;
public abstract fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public abstract fun getOriginalMessage ()Lnet/mamoe/mirai/message/data/MessageChain;
public abstract fun getTargetId ()J
public abstract fun getTime ()I
@ -4666,8 +4667,8 @@ public final class net/mamoe/mirai/message/data/MessageUtils {
public static final synthetic fun getContent (Lnet/mamoe/mirai/message/data/Message;)Ljava/lang/String;
public static final synthetic fun getIds (Lnet/mamoe/mirai/message/data/MessageChain;)[I
public static final synthetic fun getInternalId (Lnet/mamoe/mirai/message/data/MessageChain;)[I
public static final fun getKind (Lnet/mamoe/mirai/message/data/MessageSource;)Lnet/mamoe/mirai/message/data/MessageSourceKind;
public static final fun getKind (Lnet/mamoe/mirai/message/data/OnlineMessageSource;)Lnet/mamoe/mirai/message/data/MessageSourceKind;
public static final synthetic fun getKind (Lnet/mamoe/mirai/message/data/MessageSource;)Lnet/mamoe/mirai/message/data/MessageSourceKind;
public static final synthetic fun getKind (Lnet/mamoe/mirai/message/data/OnlineMessageSource;)Lnet/mamoe/mirai/message/data/MessageSourceKind;
public static final synthetic fun getLengthDuration (Lnet/mamoe/mirai/message/data/OnlineAudio;)J
public static final synthetic fun getOrFail (Lnet/mamoe/mirai/message/data/MessageChain;Lnet/mamoe/mirai/message/data/MessageKey;Lkotlin/jvm/functions/Function1;)Lnet/mamoe/mirai/message/data/SingleMessage;
public static synthetic fun getOrFail$default (Lnet/mamoe/mirai/message/data/MessageChain;Lnet/mamoe/mirai/message/data/MessageKey;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lnet/mamoe/mirai/message/data/SingleMessage;
@ -4816,6 +4817,7 @@ public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromFriend : net/mamoe/mirai/message/data/OnlineMessageSource$Incoming {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromFriend$Key;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public abstract fun getSender ()Lnet/mamoe/mirai/contact/Friend;
public abstract fun getSubject ()Lnet/mamoe/mirai/contact/Friend;
public final synthetic fun getTarget ()Lnet/mamoe/mirai/Bot;
@ -4829,6 +4831,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$Fro
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromGroup : net/mamoe/mirai/message/data/OnlineMessageSource$Incoming {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromGroup$Key;
public final fun getGroup ()Lnet/mamoe/mirai/contact/Group;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public abstract fun getSender ()Lnet/mamoe/mirai/contact/Member;
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
public fun getSubject ()Lnet/mamoe/mirai/contact/Group;
@ -4842,6 +4845,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$Fro
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromStranger : net/mamoe/mirai/message/data/OnlineMessageSource$Incoming {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromStranger$Key;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public abstract fun getSender ()Lnet/mamoe/mirai/contact/Stranger;
public abstract fun getSubject ()Lnet/mamoe/mirai/contact/Stranger;
public final synthetic fun getTarget ()Lnet/mamoe/mirai/Bot;
@ -4855,6 +4859,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$Fro
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromTemp : net/mamoe/mirai/message/data/OnlineMessageSource$Incoming {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Incoming$FromTemp$Key;
public final fun getGroup ()Lnet/mamoe/mirai/contact/Group;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public abstract fun getSender ()Lnet/mamoe/mirai/contact/Member;
public abstract fun getSubject ()Lnet/mamoe/mirai/contact/Member;
public final synthetic fun getTarget ()Lnet/mamoe/mirai/Bot;
@ -4884,6 +4889,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$Key
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToFriend : net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToFriend$Key;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
public final fun getSubject ()Lnet/mamoe/mirai/contact/Friend;
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Friend;
@ -4895,6 +4901,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToF
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToGroup : net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToGroup$Key;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
public final fun getSubject ()Lnet/mamoe/mirai/contact/Group;
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Group;
@ -4906,6 +4913,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToG
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToStranger : net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToStranger$Key;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
public final fun getSubject ()Lnet/mamoe/mirai/contact/Stranger;
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Stranger;
@ -4918,6 +4926,7 @@ public final class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToS
public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToTemp : net/mamoe/mirai/message/data/OnlineMessageSource$Outgoing {
public static final field Key Lnet/mamoe/mirai/message/data/OnlineMessageSource$Outgoing$ToTemp$Key;
public final fun getGroup ()Lnet/mamoe/mirai/contact/Group;
public final fun getKind ()Lnet/mamoe/mirai/message/data/MessageSourceKind;
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
public final fun getSubject ()Lnet/mamoe/mirai/contact/Member;
public abstract fun getTarget ()Lnet/mamoe/mirai/contact/Member;

View File

@ -207,6 +207,13 @@ public sealed class MessageSource : Message, MessageMetadata, ConstrainSingle {
*/
public abstract val isOriginalMessageInitialized: Boolean
/**
* 消息种类
*
* @since 2.15
*/
public abstract val kind: MessageSourceKind
public abstract override fun toString(): String
@MiraiInternalApi
@ -376,26 +383,18 @@ public enum class MessageSourceKind {
STRANGER
}
/**
* 获取 [MessageSourceKind]
/*
public static final net.mamoe.mirai.message.data.MessageSourceKind getKind(net.mamoe.mirai.message.data.MessageSource);
public static final net.mamoe.mirai.message.data.MessageSourceKind getKind(net.mamoe.mirai.message.data.OnlineMessageSource);
*/
public val MessageSource.kind: MessageSourceKind
get() = when (this) {
is OnlineMessageSource -> kind
is OfflineMessageSource -> kind
}
@JvmName("getKind")
@Deprecated("For ABI compatibility", level = DeprecationLevel.HIDDEN)
public fun getKindLegacy(source: MessageSource): MessageSourceKind = source.kind
@JvmName("getKind")
@Deprecated("For ABI compatibility", level = DeprecationLevel.HIDDEN)
public fun getKindLegacy(source: OnlineMessageSource): MessageSourceKind = source.kind
/**
* 获取 [MessageSourceKind]
*/
public val OnlineMessageSource.kind: MessageSourceKind
get() = when (subject) {
is Group -> MessageSourceKind.GROUP
is Friend -> MessageSourceKind.FRIEND
is Member -> MessageSourceKind.TEMP
is Stranger -> MessageSourceKind.STRANGER
else -> error("Internal error: OnlineMessageSource.kind reached an unexpected clause, subject=$subject")
}
// For MessageChain, no need to expose to Java.

View File

@ -37,7 +37,7 @@ public abstract class OfflineMessageSource : MessageSource() {
/**
* 消息种类
*/
public abstract val kind: MessageSourceKind
public abstract override val kind: MessageSourceKind
final override fun toString(): String {
return "[mirai:source:ids=${ids.contentToString()}, internalIds=${internalIds.contentToString()}, from $fromId to $targetId at $time]"

View File

@ -101,6 +101,8 @@ public sealed class OnlineMessageSource : MessageSource() {
public abstract override val target: Friend
public final override val subject: Friend get() = target
final override val kind: MessageSourceKind get() = MessageSourceKind.FRIEND
final override fun toString(): String {
return "[mirai:source:ids=${ids.contentToString()}, internalIds=${internalIds.contentToString()}, from $fromId to friend $targetId at $time]"
}
@ -114,6 +116,8 @@ public sealed class OnlineMessageSource : MessageSource() {
public abstract override val target: Stranger
public final override val subject: Stranger get() = target
final override val kind: MessageSourceKind get() = MessageSourceKind.STRANGER
final override fun toString(): String {
return "[mirai:source:ids=${ids.contentToString()}, internalIds=${internalIds.contentToString()}, from $fromId to stranger $targetId at $time]"
}
@ -127,6 +131,8 @@ public sealed class OnlineMessageSource : MessageSource() {
public val group: Group get() = target.group
public final override val subject: Member get() = target
final override val kind: MessageSourceKind get() = MessageSourceKind.TEMP
final override fun toString(): String {
return "[mirai:source:ids=${ids.contentToString()}, internalIds=${internalIds.contentToString()}, from $fromId to group temp $targetId at $time]"
}
@ -139,6 +145,8 @@ public sealed class OnlineMessageSource : MessageSource() {
public abstract override val target: Group
public final override val subject: Group get() = target
final override val kind: MessageSourceKind get() = MessageSourceKind.GROUP
final override fun toString(): String {
return "[mirai:source:ids=${ids.contentToString()}, internalIds=${internalIds.contentToString()}, from $fromId to group $targetId at $time]"
}
@ -179,6 +187,8 @@ public sealed class OnlineMessageSource : MessageSource() {
error("Message target isn't bot; $this")
}
final override val kind: MessageSourceKind get() = MessageSourceKind.FRIEND
final override fun toString(): String {
return "[mirai:source:ids=${ids.contentToString()}, internalIds=${internalIds.contentToString()}, from friend $fromId to $targetId at $time]"
}
@ -206,6 +216,8 @@ public sealed class OnlineMessageSource : MessageSource() {
error("Message target isn't bot; $this")
}
final override val kind: MessageSourceKind get() = MessageSourceKind.TEMP
final override fun toString(): String {
return "[mirai:source:ids=${ids.contentToString()}, internalIds=${internalIds.contentToString()}, from group temp $fromId to $targetId at $time]"
}
@ -232,6 +244,8 @@ public sealed class OnlineMessageSource : MessageSource() {
error("Message target isn't bot; $this")
}
final override val kind: MessageSourceKind get() = MessageSourceKind.STRANGER
final override fun toString(): String {
return "[mirai:source:ids=${ids.contentToString()}, internalIds=${internalIds.contentToString()}, from stranger $fromId to $targetId at $time]"
}
@ -250,6 +264,8 @@ public sealed class OnlineMessageSource : MessageSource() {
public final override val target: Group get() = subject
public inline val group: Group get() = subject
final override val kind: MessageSourceKind get() = MessageSourceKind.GROUP
final override fun toString(): String {
return "[mirai:source:ids=${ids.contentToString()}, internalIds=${internalIds.contentToString()}, from group $fromId to $targetId at $time]"
}