|
|
@@ -15,6 +15,7 @@ package net.mamoe.mirai.message.data
|
|
|
|
|
|
import net.mamoe.mirai.contact.Contact
|
|
|
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
|
|
+import net.mamoe.mirai.utils.PlannedRemoval
|
|
|
import net.mamoe.mirai.utils.SinceMirai
|
|
|
import kotlin.annotation.AnnotationTarget.*
|
|
|
import kotlin.jvm.JvmMultifileClass
|
|
|
@@ -40,7 +41,12 @@ interface RichMessage : MessageContent {
|
|
|
|
|
|
@MiraiExperimentalAPI
|
|
|
@SinceMirai("0.30.0")
|
|
|
- fun share(url: String, title: String? = null, content: String? = null, coverUrl: String? = null): XmlMessage =
|
|
|
+ fun share(
|
|
|
+ url: String,
|
|
|
+ title: String? = null,
|
|
|
+ content: String? = null,
|
|
|
+ coverUrl: String? = null
|
|
|
+ ): ServiceMessage =
|
|
|
buildXmlMessage(60) {
|
|
|
templateId = 12345
|
|
|
serviceId = 1
|
|
|
@@ -61,6 +67,20 @@ interface RichMessage : MessageContent {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @PlannedRemoval("1.0.0")
|
|
|
+ @JvmName("share")
|
|
|
+ @Deprecated(
|
|
|
+ "for binary compatibility", level = DeprecationLevel.HIDDEN
|
|
|
+ )
|
|
|
+ @Suppress("DEPRECATION_ERROR")
|
|
|
+ @MiraiExperimentalAPI
|
|
|
+ fun shareDeprecated(
|
|
|
+ url: String,
|
|
|
+ title: String? = null,
|
|
|
+ content: String? = null,
|
|
|
+ coverUrl: String? = null
|
|
|
+ ): XmlMessage = share(url, title, content, coverUrl) as XmlMessage
|
|
|
+
|
|
|
override val typeName: String
|
|
|
get() = "RichMessage"
|
|
|
}
|
|
|
@@ -120,8 +140,17 @@ open class ServiceMessage(@MiraiExperimentalAPI val serviceId: Int, final overri
|
|
|
*
|
|
|
* @see LightApp 一些 json 消息实际上是 [LightApp]
|
|
|
*/
|
|
|
+@PlannedRemoval("1.0.0")
|
|
|
+@Deprecated("use ServiceMessage with serviceId 1",
|
|
|
+ level = DeprecationLevel.ERROR,
|
|
|
+ replaceWith = ReplaceWith("ServiceMessage"))
|
|
|
+@Suppress("DEPRECATION_ERROR")
|
|
|
@MiraiExperimentalAPI
|
|
|
-class JsonMessage(content: String) : ServiceMessage(1, content) {
|
|
|
+class JsonMessage
|
|
|
+@Deprecated("use ServiceMessage with serviceId 1",
|
|
|
+ level = DeprecationLevel.ERROR,
|
|
|
+ replaceWith = ReplaceWith("ServiceMessage(1, content)"))
|
|
|
+constructor(content: String) : ServiceMessage(1, content) {
|
|
|
@Suppress("DEPRECATION")
|
|
|
companion object Key : Message.Key<JsonMessage> {
|
|
|
override val typeName: String get() = "JsonMessage"
|
|
|
@@ -136,7 +165,12 @@ class JsonMessage(content: String) : ServiceMessage(1, content) {
|
|
|
*
|
|
|
* @see buildXmlMessage 使用 DSL 构造一个 XML 消息
|
|
|
*/
|
|
|
+@PlannedRemoval("1.0.0")
|
|
|
+@Deprecated("use ServiceMessage with serviceId 1",
|
|
|
+ level = DeprecationLevel.ERROR,
|
|
|
+ replaceWith = ReplaceWith("ServiceMessage"))
|
|
|
@MiraiExperimentalAPI
|
|
|
+@Suppress("DEPRECATION_ERROR")
|
|
|
@SinceMirai("0.27.0")
|
|
|
class XmlMessage @MiraiExperimentalAPI("Maybe replaced with an enum")
|
|
|
constructor(serviceId: Int = 60, content: String) : ServiceMessage(serviceId, content) {
|
|
|
@@ -182,10 +216,11 @@ commonElem=CommonElem#750141174 {
|
|
|
/**
|
|
|
* 构造一条 XML 消息
|
|
|
*/
|
|
|
+@Suppress("DEPRECATION_ERROR")
|
|
|
@JvmSynthetic
|
|
|
@SinceMirai("0.27.0")
|
|
|
@MiraiExperimentalAPI
|
|
|
-inline fun buildXmlMessage(serviceId: Int, block: @XmlMessageDsl XmlMessageBuilder.() -> Unit): XmlMessage =
|
|
|
+inline fun buildXmlMessage(serviceId: Int, block: @XmlMessageDsl XmlMessageBuilder.() -> Unit): ServiceMessage =
|
|
|
XmlMessage(serviceId, XmlMessageBuilder().apply(block).text)
|
|
|
|
|
|
@Target(CLASS, FUNCTION, TYPE)
|
|
|
@@ -261,4 +296,5 @@ class XmlMessageBuilder(
|
|
|
@SinceMirai("0.27.0")
|
|
|
@MiraiExperimentalAPI
|
|
|
@Deprecated("specify serviceId explicitly", ReplaceWith("buildXmlMessage(60, block)"))
|
|
|
-inline fun buildXmlMessage(block: @XmlMessageDsl XmlMessageBuilder.() -> Unit): XmlMessage = buildXmlMessage(60, block)
|
|
|
+inline fun buildXmlMessage(block: @XmlMessageDsl XmlMessageBuilder.() -> Unit): ServiceMessage =
|
|
|
+ buildXmlMessage(60, block)
|