mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-31 03:22:36 +08:00
[Review] Add missing @MiraiExperimentalApi
to appendMiraiCode
This commit is contained in:
parent
43b422b540
commit
d4852ceb6f
@ -21,6 +21,7 @@ import net.mamoe.mirai.contact.Member
|
||||
import net.mamoe.mirai.contact.UserOrBot
|
||||
import net.mamoe.mirai.contact.nameCardOrNick
|
||||
import net.mamoe.mirai.message.code.CodableMessage
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
|
||||
|
||||
/**
|
||||
@ -49,6 +50,7 @@ public data class At(
|
||||
return "@${member.nameCardOrNick}"
|
||||
}
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
builder.append("[mirai:at:").append(target).append(']')
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ package net.mamoe.mirai.message.data
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.message.code.CodableMessage
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
|
||||
private const val displayA = "@全体成员"
|
||||
|
||||
@ -47,6 +48,7 @@ public object AtAll :
|
||||
return toString()
|
||||
}
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
builder.append(toString())
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ package net.mamoe.mirai.message.data
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.message.code.CodableMessage
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
|
||||
/**
|
||||
* QQ 自带表情
|
||||
@ -31,6 +32,7 @@ public data class Face(public val id: Int) : // used in delegation
|
||||
public val name: String get() = contentToString().let { it.substring(1, it.length - 1) }
|
||||
public override fun contentToString(): String = names.getOrElse(id) { "[表情]" }
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
builder.append("[mirai:face:").append(id).append(']')
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.message.code.CodableMessage
|
||||
import net.mamoe.mirai.message.code.internal.appendAsMiraiCode
|
||||
import net.mamoe.mirai.message.data.VipFace.Kind
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
import net.mamoe.mirai.utils.castOrNull
|
||||
import net.mamoe.mirai.utils.safeCast
|
||||
@ -170,6 +171,7 @@ public data class PokeMessage @MiraiInternalApi constructor(
|
||||
|
||||
private val stringValue = "[mirai:poke:$name,$pokeType,$id]"
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
builder.append("[mirai:poke:").appendAsMiraiCode(name)
|
||||
.append(',').append(pokeType).append(',').append(id)
|
||||
@ -292,6 +294,7 @@ public data class VipFace @MiraiInternalApi constructor(
|
||||
private infix fun Int.to(name: String): Kind = Kind(this, name)
|
||||
}
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
builder.append(stringValue)
|
||||
}
|
||||
@ -346,6 +349,7 @@ public data class FlashImage(
|
||||
|
||||
private val stringValue: String by lazy(LazyThreadSafetyMode.NONE) { "[mirai:flash:${image.imageId}]" }
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
builder.append(stringValue)
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import net.mamoe.mirai.message.MessageSerializers
|
||||
import net.mamoe.mirai.message.code.CodableMessage
|
||||
import net.mamoe.mirai.message.data.MessageSource.Key.quote
|
||||
import net.mamoe.mirai.message.data.MessageSource.Key.recall
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.safeCast
|
||||
import java.util.stream.Stream
|
||||
import kotlin.reflect.KProperty
|
||||
@ -96,6 +97,11 @@ public interface MessageChain : Message, List<SingleMessage>, RandomAccess, Coda
|
||||
public operator fun <M : SingleMessage> contains(key: MessageKey<M>): Boolean =
|
||||
asSequence().any { key.safeCast.invoke(it) != null }
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
forEach { it.safeCast<CodableMessage>()?.appendMiraiCode(builder) }
|
||||
}
|
||||
|
||||
@kotlinx.serialization.Serializer(MessageChain::class)
|
||||
public object Serializer : KSerializer<MessageChain> {
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@ -105,10 +111,6 @@ public interface MessageChain : Message, List<SingleMessage>, RandomAccess, Coda
|
||||
override fun serialize(encoder: Encoder, value: MessageChain): Unit = delegate.serialize(encoder, value)
|
||||
}
|
||||
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
forEach { it.safeCast<CodableMessage>()?.appendMiraiCode(builder) }
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public companion object {
|
||||
private fun getDefaultJson() = Json {
|
||||
@ -167,6 +169,8 @@ public object EmptyMessageChain : MessageChain, Iterator<SingleMessage>, List<Si
|
||||
public override fun hasNext(): Boolean = false
|
||||
public override fun next(): SingleMessage = throw NoSuchElementException("EmptyMessageChain is empty.")
|
||||
override fun toMiraiCode(): String = ""
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.message.code.CodableMessage
|
||||
import net.mamoe.mirai.message.code.internal.appendAsMiraiCode
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
|
||||
/**
|
||||
* 纯文本. 可含 emoji 表情如 😊.
|
||||
@ -34,6 +35,7 @@ public data class PlainText(
|
||||
public override fun toString(): String = content
|
||||
public override fun contentToString(): String = content
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
builder.appendAsMiraiCode(content)
|
||||
}
|
||||
|
@ -104,6 +104,7 @@ public data class LightApp(override val content: String) : RichMessage, CodableM
|
||||
|
||||
public override fun toString(): String = "[mirai:app:$content]"
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
builder.append("[mirai:app:").appendAsMiraiCode(content).append(']')
|
||||
}
|
||||
@ -164,6 +165,7 @@ public interface ServiceMessage : RichMessage, CodableMessage {
|
||||
*/
|
||||
public val serviceId: Int
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
builder.append("[mirai:service:").append(serviceId).append(',').appendAsMiraiCode(content).append(']')
|
||||
}
|
||||
|
@ -24,11 +24,8 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.message.data.Image.Key.IMAGE_ID_REGEX
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.ExternalResource.Companion.DEFAULT_FORMAT_NAME
|
||||
import net.mamoe.mirai.utils.generateImageId
|
||||
import net.mamoe.mirai.utils.generateImageIdFromResourceId
|
||||
import net.mamoe.mirai.utils.hexToBytes
|
||||
import net.mamoe.mirai.utils.toUHexString
|
||||
|
||||
@Serializable(with = OnlineGroupImageImpl.Serializer::class)
|
||||
internal class OnlineGroupImageImpl(
|
||||
@ -201,6 +198,7 @@ internal abstract class AbstractImage : Image { // make sealed in 1.3.0 ?
|
||||
final override fun toString(): String = _stringValue!!
|
||||
final override fun contentToString(): String = "[图片]"
|
||||
|
||||
@MiraiExperimentalApi
|
||||
override fun appendMiraiCode(builder: StringBuilder) {
|
||||
builder.append("[mirai:image:").append(imageId).append("]")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user