mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-24 14:30:09 +08:00
Ensure binary compatibility until 1.1.0
This commit is contained in:
parent
0de76149c8
commit
50934f9b7d
@ -98,7 +98,7 @@ internal fun MessageChain.toRichTextElems(forGroup: Boolean, withGeneralFlags: B
|
||||
}
|
||||
|
||||
when (it) {
|
||||
is PlainText -> elements.add(ImMsgBody.Elem(text = ImMsgBody.Text(str = it.stringValue)))
|
||||
is PlainText -> elements.add(ImMsgBody.Elem(text = ImMsgBody.Text(str = it.content)))
|
||||
is CustomMessage -> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
elements.add(
|
||||
@ -250,7 +250,7 @@ private fun MessageChain.cleanupRubbishMessageElements(): MessageChain {
|
||||
}
|
||||
if (last is VipFace && element is PlainText) {
|
||||
val l = last as VipFace
|
||||
if (element.length == 4 + (l.count / 10) + l.kind.name.length) {
|
||||
if (element.content.length == 4 + (l.count / 10) + l.kind.name.length) {
|
||||
last = element
|
||||
return@forEach
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ internal fun SingleMessage.estimateLength(upTo: Int): Int {
|
||||
return when (this) {
|
||||
is QuoteReply -> 444 + this.source.originalMessage.estimateLength(upTo) // Magic number
|
||||
is Image -> 260 // Magic number
|
||||
is PlainText -> stringValue.chineseLength(upTo)
|
||||
is PlainText -> content.chineseLength(upTo)
|
||||
is At -> display.chineseLength(upTo)
|
||||
is AtAll -> display.chineseLength(upTo)
|
||||
else -> this.toString().chineseLength(upTo)
|
||||
|
@ -32,9 +32,7 @@ import kotlin.jvm.JvmSynthetic
|
||||
data class At
|
||||
@Suppress("DataClassPrivateConstructor")
|
||||
private constructor(val target: Long, val display: String) :
|
||||
MessageContent,
|
||||
CharSequence by display,
|
||||
Comparable<String> by display {
|
||||
MessageContent {
|
||||
|
||||
/**
|
||||
* 构造一个 [At] 实例. 这是唯一的公开的构造方式.
|
||||
@ -63,7 +61,7 @@ private constructor(val target: Long, val display: String) :
|
||||
|
||||
// 自动为消息补充 " "
|
||||
override fun followedBy(tail: Message): MessageChain {
|
||||
if (tail is PlainText && tail.stringValue.startsWith(' ')) {
|
||||
if (tail is PlainText && tail.content.startsWith(' ')) {
|
||||
return super.followedBy(tail)
|
||||
}
|
||||
return super.followedBy(PlainText(" ")) + tail
|
||||
|
@ -27,9 +27,7 @@ private const val displayA = "@全体成员"
|
||||
*/
|
||||
object AtAll :
|
||||
Message.Key<AtAll>,
|
||||
MessageContent,
|
||||
CharSequence by displayA,
|
||||
Comparable<String> by displayA {
|
||||
MessageContent {
|
||||
|
||||
@SinceMirai("0.31.2")
|
||||
const val display = displayA
|
||||
@ -49,7 +47,7 @@ object AtAll :
|
||||
|
||||
// 自动为消息补充 " "
|
||||
override fun followedBy(tail: Message): MessageChain {
|
||||
if (tail is PlainText && tail.stringValue.startsWith(' ')) {
|
||||
if (tail is PlainText && tail.content.startsWith(' ')) {
|
||||
return super.followedBy(tail)
|
||||
}
|
||||
return super.followedBy(PlainText(" ")) + tail
|
||||
|
@ -21,8 +21,7 @@ import kotlin.jvm.JvmName
|
||||
data class Face
|
||||
@Suppress("DataClassPrivateConstructor")
|
||||
private constructor(val id: Int, private val stringValue: String) : // used in delegation
|
||||
MessageContent,
|
||||
CharSequence by stringValue, Comparable<String> by stringValue {
|
||||
MessageContent {
|
||||
constructor(id: Int) : this(id, "[mirai:face:$id]")
|
||||
|
||||
override fun toString(): String = stringValue
|
||||
|
@ -279,7 +279,7 @@ interface Message { // must be interface. Don't consider any changes.
|
||||
@SinceMirai("0.39.3")
|
||||
fun Message.isContentEmpty(): Boolean = when (this) {
|
||||
is MessageMetadata -> true
|
||||
is PlainText -> this.stringValue.isEmpty()
|
||||
is PlainText -> this.content.isEmpty()
|
||||
is MessageChain -> this.all { it.isContentEmpty() }
|
||||
else -> false
|
||||
}
|
||||
@ -339,6 +339,25 @@ interface SingleMessage : Message {
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
/* final */ override infix fun eq(other: String): Boolean = this.contentToString() == other
|
||||
|
||||
|
||||
@PlannedRemoval("1.1.0")
|
||||
@JvmSynthetic
|
||||
@SinceMirai("1.0.0")
|
||||
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
fun length(): Int = this.toString().length
|
||||
|
||||
@PlannedRemoval("1.1.0")
|
||||
@JvmSynthetic
|
||||
@SinceMirai("1.0.0")
|
||||
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
fun charAt(index: Int): Char = this.toString()[index]
|
||||
|
||||
@PlannedRemoval("1.1.0")
|
||||
@JvmSynthetic
|
||||
@SinceMirai("1.0.0")
|
||||
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
fun subSequence(start: Int, end: Int): CharSequence = this.toString().subSequence(start, end)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,20 +32,6 @@ internal class TestConstrainSingleMessage : ConstrainSingle<TestConstrainSingleM
|
||||
|
||||
override val key: Message.Key<TestConstrainSingleMessage>
|
||||
get() = Key
|
||||
override val length: Int
|
||||
get() = TODO("Not yet implemented")
|
||||
|
||||
override fun get(index: Int): Char {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun subSequence(startIndex: Int, endIndex: Int): CharSequence {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun compareTo(other: String): Int {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
|
Loading…
Reference in New Issue
Block a user