[core] Add MessageChain.deserializeFromMiraiCode without redundant receiver MessageChain.

This commit is contained in:
Him188 2022-10-14 16:00:31 +01:00
parent 4276b67b2b
commit 4595f937e4
No known key found for this signature in database
GPG Key ID: BA439CDDCF652375
4 changed files with 30 additions and 2 deletions

View File

@ -4309,6 +4309,7 @@ public abstract interface class net/mamoe/mirai/message/data/MessageChain : java
public fun contains (Lnet/mamoe/mirai/message/data/MessageKey;)Z
public static fun deserializeFromJsonString (Ljava/lang/String;)Lnet/mamoe/mirai/message/data/MessageChain;
public static fun deserializeFromJsonString (Ljava/lang/String;Lkotlinx/serialization/json/Json;)Lnet/mamoe/mirai/message/data/MessageChain;
public static fun deserializeFromMiraiCode (Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;)Lnet/mamoe/mirai/message/data/MessageChain;
public static fun deserializeFromMiraiCode (Lnet/mamoe/mirai/message/data/MessageChain;Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;)Lnet/mamoe/mirai/message/data/MessageChain;
public static synthetic fun deserializeJsonToMessageChain (Ljava/lang/String;)Lnet/mamoe/mirai/message/data/MessageChain;
public static synthetic fun deserializeJsonToMessageChain (Ljava/lang/String;Lkotlinx/serialization/json/Json;)Lnet/mamoe/mirai/message/data/MessageChain;
@ -4322,7 +4323,9 @@ public final class net/mamoe/mirai/message/data/MessageChain$Companion {
public final fun deserializeFromJsonString (Ljava/lang/String;)Lnet/mamoe/mirai/message/data/MessageChain;
public final fun deserializeFromJsonString (Ljava/lang/String;Lkotlinx/serialization/json/Json;)Lnet/mamoe/mirai/message/data/MessageChain;
public static synthetic fun deserializeFromJsonString$default (Lnet/mamoe/mirai/message/data/MessageChain$Companion;Ljava/lang/String;Lkotlinx/serialization/json/Json;ILjava/lang/Object;)Lnet/mamoe/mirai/message/data/MessageChain;
public final fun deserializeFromMiraiCode (Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;)Lnet/mamoe/mirai/message/data/MessageChain;
public final fun deserializeFromMiraiCode (Lnet/mamoe/mirai/message/data/MessageChain;Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;)Lnet/mamoe/mirai/message/data/MessageChain;
public static synthetic fun deserializeFromMiraiCode$default (Lnet/mamoe/mirai/message/data/MessageChain$Companion;Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;ILjava/lang/Object;)Lnet/mamoe/mirai/message/data/MessageChain;
public static synthetic fun deserializeFromMiraiCode$default (Lnet/mamoe/mirai/message/data/MessageChain$Companion;Lnet/mamoe/mirai/message/data/MessageChain;Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;ILjava/lang/Object;)Lnet/mamoe/mirai/message/data/MessageChain;
public final synthetic fun deserializeJsonToMessageChain (Ljava/lang/String;)Lnet/mamoe/mirai/message/data/MessageChain;
public final synthetic fun deserializeJsonToMessageChain (Ljava/lang/String;Lkotlinx/serialization/json/Json;)Lnet/mamoe/mirai/message/data/MessageChain;

View File

@ -4309,6 +4309,7 @@ public abstract interface class net/mamoe/mirai/message/data/MessageChain : java
public fun contains (Lnet/mamoe/mirai/message/data/MessageKey;)Z
public static fun deserializeFromJsonString (Ljava/lang/String;)Lnet/mamoe/mirai/message/data/MessageChain;
public static fun deserializeFromJsonString (Ljava/lang/String;Lkotlinx/serialization/json/Json;)Lnet/mamoe/mirai/message/data/MessageChain;
public static fun deserializeFromMiraiCode (Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;)Lnet/mamoe/mirai/message/data/MessageChain;
public static fun deserializeFromMiraiCode (Lnet/mamoe/mirai/message/data/MessageChain;Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;)Lnet/mamoe/mirai/message/data/MessageChain;
public static synthetic fun deserializeJsonToMessageChain (Ljava/lang/String;)Lnet/mamoe/mirai/message/data/MessageChain;
public static synthetic fun deserializeJsonToMessageChain (Ljava/lang/String;Lkotlinx/serialization/json/Json;)Lnet/mamoe/mirai/message/data/MessageChain;
@ -4322,7 +4323,9 @@ public final class net/mamoe/mirai/message/data/MessageChain$Companion {
public final fun deserializeFromJsonString (Ljava/lang/String;)Lnet/mamoe/mirai/message/data/MessageChain;
public final fun deserializeFromJsonString (Ljava/lang/String;Lkotlinx/serialization/json/Json;)Lnet/mamoe/mirai/message/data/MessageChain;
public static synthetic fun deserializeFromJsonString$default (Lnet/mamoe/mirai/message/data/MessageChain$Companion;Ljava/lang/String;Lkotlinx/serialization/json/Json;ILjava/lang/Object;)Lnet/mamoe/mirai/message/data/MessageChain;
public final fun deserializeFromMiraiCode (Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;)Lnet/mamoe/mirai/message/data/MessageChain;
public final fun deserializeFromMiraiCode (Lnet/mamoe/mirai/message/data/MessageChain;Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;)Lnet/mamoe/mirai/message/data/MessageChain;
public static synthetic fun deserializeFromMiraiCode$default (Lnet/mamoe/mirai/message/data/MessageChain$Companion;Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;ILjava/lang/Object;)Lnet/mamoe/mirai/message/data/MessageChain;
public static synthetic fun deserializeFromMiraiCode$default (Lnet/mamoe/mirai/message/data/MessageChain$Companion;Lnet/mamoe/mirai/message/data/MessageChain;Ljava/lang/String;Lnet/mamoe/mirai/contact/Contact;ILjava/lang/Object;)Lnet/mamoe/mirai/message/data/MessageChain;
public final synthetic fun deserializeJsonToMessageChain (Ljava/lang/String;)Lnet/mamoe/mirai/message/data/MessageChain;
public final synthetic fun deserializeJsonToMessageChain (Ljava/lang/String;Lkotlinx/serialization/json/Json;)Lnet/mamoe/mirai/message/data/MessageChain;

View File

@ -341,11 +341,30 @@ public sealed interface MessageChain :
/**
* 解析形如 "[mirai:]" mirai , [CodableMessage.serializeToMiraiCode] 返回的内容.
* @param contact 解析语境
* @see MiraiCode.deserializeMiraiCode
* @since 2.13
*/
@JvmStatic
public fun MessageChain.deserializeFromMiraiCode(miraiCode: String, contact: Contact? = null): MessageChain =
public fun deserializeFromMiraiCode(miraiCode: String, contact: Contact? = null): MessageChain =
miraiCode.deserializeMiraiCode(contact)
/**
* 解析形如 "[mirai:]" mirai , [CodableMessage.serializeToMiraiCode] 返回的内容.
* @see MiraiCode.deserializeMiraiCode
*/
@Deprecated(
"Parameter MessageChain is redundant, use the overload instead.",
ReplaceWith(
"MessageChain.deserializeFromMiraiCode(miraiCode, contact)",
"net.mamoe.mirai.message.data.MessageChain"
)
)
@Suppress("UnusedReceiverParameter")
@JvmStatic
public fun MessageChain.deserializeFromMiraiCode(miraiCode: String, contact: Contact? = null): MessageChain =
MessageChain.deserializeFromMiraiCode(miraiCode, contact)
}
}

View File

@ -191,7 +191,10 @@ public sealed class MessageSource : Message, MessageMetadata, ConstrainSingle {
public abstract val targetId: Long // groupCode / friendUin / memberUin
/**
* source 指代的原消息内容.
* 该消息源指向的原消息的内容.
*
* ## 内容不一定完整
* 如果消息源是来自一条引用回复, [QuoteReply.source], 那么原消息内容不一定完整.
*
* 此属性是惰性初始化的: 它只会在第一次调用时初始化, 因为需要反序列化服务器发来的整个包, 相当于接收了一条新消息.
*/