mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 17:00:14 +08:00
Remove deprecated declarations
This commit is contained in:
parent
57463fddd8
commit
27f0c73dc3
@ -12,7 +12,6 @@
|
||||
package net.mamoe.mirai.contact
|
||||
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import java.util.concurrent.ConcurrentLinkedQueue
|
||||
|
||||
|
||||
@ -51,20 +50,4 @@ internal constructor(@JvmField @MiraiInternalApi public val delegate: Concurrent
|
||||
override fun toString(): String = delegate.joinToString(separator = ", ", prefix = "ContactList(", postfix = ")")
|
||||
override fun equals(other: Any?): Boolean = other is ContactList<*> && delegate == other.delegate
|
||||
override fun hashCode(): Int = delegate.hashCode()
|
||||
}
|
||||
|
||||
/**
|
||||
* ID 列表的字符串表示.
|
||||
* 如:
|
||||
* ```
|
||||
* [123456, 321654, 123654]
|
||||
* ```
|
||||
*/
|
||||
@Deprecated(
|
||||
"deprecated.",
|
||||
ReplaceWith("\"[\" + delegate.joinToString { it.id.toString() } + \"]\""),
|
||||
DeprecationLevel.ERROR
|
||||
)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public val ContactList<*>.idContentString: String
|
||||
get() = "[" + delegate.joinToString { it.id.toString() } + "]"
|
||||
}
|
@ -19,7 +19,6 @@ import net.mamoe.mirai.message.action.MemberNudge
|
||||
import net.mamoe.mirai.message.action.Nudge
|
||||
import net.mamoe.mirai.message.data.Message
|
||||
import net.mamoe.mirai.message.data.isContentEmpty
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import net.mamoe.mirai.utils.WeakRefProperty
|
||||
|
||||
/**
|
||||
@ -166,14 +165,4 @@ public inline val Member.isStranger: Boolean
|
||||
*
|
||||
* 若 [群名片][Member.nameCard] 不为空则返回群名片, 为空则返回 [User.nick]
|
||||
*/
|
||||
public val Member.nameCardOrNick: String get() = this.nameCard.takeIf { it.isNotEmpty() } ?: this.nick
|
||||
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated("Use is NormalMember by yourself.", ReplaceWith("this is NormalMember"), DeprecationLevel.ERROR)
|
||||
public val Member.isNormal: Boolean
|
||||
get() = this is NormalMember
|
||||
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated("Use is AnonymousMember by yourself.", ReplaceWith("this is AnonymousMember"), DeprecationLevel.ERROR)
|
||||
public val Member.isAnonymous: Boolean
|
||||
get() = this is AnonymousMember
|
||||
public val Member.nameCardOrNick: String get() = this.nameCard.takeIf { it.isNotEmpty() } ?: this.nick
|
@ -12,7 +12,6 @@ package net.mamoe.mirai.message.code
|
||||
import net.mamoe.mirai.message.code.MiraiCode.deserializeMiraiCode
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
|
||||
|
||||
/**
|
||||
@ -36,10 +35,6 @@ public interface CodableMessage : Message {
|
||||
*/
|
||||
public fun serializeToMiraiCode(): String = buildString { appendMiraiCodeTo(this) }
|
||||
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated("Use serializeToMiraiCode()", ReplaceWith("serializeToMiraiCode()"), DeprecationLevel.ERROR)
|
||||
public fun toMiraiCode(): String = this.serializeToMiraiCode()
|
||||
|
||||
// Using StringBuilder faster than direct plus objects
|
||||
@MiraiExperimentalApi
|
||||
public fun appendMiraiCodeTo(builder: StringBuilder)
|
||||
|
@ -33,7 +33,6 @@ import net.mamoe.mirai.message.data.MessageSource.Key.quote
|
||||
import net.mamoe.mirai.message.data.MessageSource.Key.recall
|
||||
import net.mamoe.mirai.message.data.MessageSource.Key.recallIn
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import net.mamoe.mirai.utils.safeCast
|
||||
import java.util.stream.Stream
|
||||
import kotlin.reflect.KProperty
|
||||
@ -543,78 +542,4 @@ public inline fun <reified T : R, R : SingleMessage?> MessageChain.orElse(
|
||||
lazyDefault: () -> R
|
||||
): OrNullDelegate<R> = OrNullDelegate<R>(this.firstIsInstanceOrNull<T>() ?: lazyDefault())
|
||||
|
||||
// endregion delegate
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Deprecated
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* 遍历每一个 [消息内容][MessageContent]
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@Deprecated(
|
||||
"Use operations on contentsSequence instead.",
|
||||
ReplaceWith(
|
||||
"this.contentsSequence().forEach(block)",
|
||||
"net.mamoe.mirai.message.data.contentsSequence"
|
||||
),
|
||||
DeprecationLevel.ERROR,
|
||||
)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public inline fun MessageChain.forEachContent(block: (MessageContent) -> Unit) {
|
||||
for (element in this) {
|
||||
if (element !is MessageMetadata) {
|
||||
check(element is MessageContent) { "internal error: Message must be either MessageMetadata or MessageContent" }
|
||||
block(element)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果每一个 [消息内容][MessageContent] 都满足 [block], 返回 `true`
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@Deprecated(
|
||||
"Use operations on contentsSequence instead.",
|
||||
ReplaceWith(
|
||||
"this.contentsSequence().all(block)",
|
||||
"net.mamoe.mirai.message.data.contentsSequence"
|
||||
),
|
||||
DeprecationLevel.ERROR,
|
||||
)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public inline fun MessageChain.allContent(block: (MessageContent) -> Boolean): Boolean {
|
||||
this.forEach {
|
||||
if (it !is MessageMetadata) {
|
||||
check(it is MessageContent) { "internal error: Message must be either MessageMetadata or MessageContent" }
|
||||
if (!block(it)) return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果每一个 [消息内容][MessageContent] 都不满足 [block], 返回 `true`
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@Deprecated(
|
||||
"Use operations on contentsSequence instead.",
|
||||
ReplaceWith(
|
||||
"this.contentsSequence().none(block)",
|
||||
"net.mamoe.mirai.message.data.contentsSequence"
|
||||
),
|
||||
DeprecationLevel.ERROR,
|
||||
)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public inline fun MessageChain.noneContent(block: (MessageContent) -> Boolean): Boolean {
|
||||
this.forEach {
|
||||
if (it !is MessageMetadata) {
|
||||
check(it is MessageContent) { "internal error: Message must be either MessageMetadata or MessageContent" }
|
||||
if (block(it)) return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
// endregion delegate
|
@ -19,7 +19,6 @@ import net.mamoe.mirai.Mirai
|
||||
import net.mamoe.mirai.contact.ContactOrBot
|
||||
import net.mamoe.mirai.message.data.MessageSource.Key.quote
|
||||
import net.mamoe.mirai.message.data.MessageSource.Key.recall
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
|
||||
/**
|
||||
@ -63,13 +62,6 @@ public class MessageSourceAmender public constructor(
|
||||
public override var ids: IntArray = origin.ids
|
||||
public override var time: Int = origin.time
|
||||
public override var internalIds: IntArray = origin.internalIds
|
||||
|
||||
/** 从另一个 [MessageSource] 中复制 [ids], [internalIds], [time]*/
|
||||
@Deprecated("use metadata", ReplaceWith("metadata(another)"))
|
||||
@PlannedRemoval("2.0.0")
|
||||
public fun metadataFrom(another: MessageSource) {
|
||||
metadata(another)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,272 +0,0 @@
|
||||
/*
|
||||
* Copyright 2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("MessageUtils")
|
||||
@file:Suppress("unused", "NOTHING_TO_INLINE", "INAPPLICABLE_JVM_NAME")
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.DeprecationLevel.ERROR
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.js.JsName
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Message
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 当 [this] 为 [PlainText] 时返回 `true`.
|
||||
*/
|
||||
@Deprecated(
|
||||
"Message.isPlain is ambiguous when used on a MessageChain containing single element PlainText. Use is PlainText by yourself.",
|
||||
ReplaceWith("this is PlainText", "net.mamoe.mirai.message.data.PlainText"),
|
||||
ERROR
|
||||
)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public inline fun Message.isPlain(): Boolean {
|
||||
contract {
|
||||
returns(true) implies (this@isPlain is PlainText)
|
||||
returns(false) implies (this@isPlain !is PlainText)
|
||||
}
|
||||
return this is PlainText
|
||||
}
|
||||
|
||||
/**
|
||||
* 当 [this] 不为 [PlainText] 时返回 `true`.
|
||||
*/
|
||||
@Deprecated(
|
||||
"Message.isNotPlain is ambiguous when used on a MessageChain containing single element PlainText. Use is PlainText by yourself.",
|
||||
ReplaceWith("this is PlainText", "net.mamoe.mirai.message.data.PlainText"),
|
||||
ERROR
|
||||
)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public inline fun Message.isNotPlain(): Boolean {
|
||||
contract {
|
||||
returns(false) implies (this@isNotPlain is PlainText)
|
||||
returns(true) implies (this@isNotPlain !is PlainText)
|
||||
}
|
||||
return this !is PlainText
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"To simplify, use !isContentEmpty",
|
||||
ReplaceWith("!this.isContentEmpty()", "net.mamoe.mirai.message.data.isContentNotEmpty"),
|
||||
ERROR
|
||||
)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public inline fun Message.isContentNotEmpty(): Boolean = !this.isContentEmpty()
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// MessageChain
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 得到包含 [this] 的 [MessageChain].
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@JvmSynthetic
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
public fun Message.asMessageChain(): MessageChain = toMessageChain()
|
||||
|
||||
/**
|
||||
* 直接将 [this] 构建为一个 [MessageChain]
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
public fun SingleMessage.asMessageChain(): MessageChain = toMessageChain()
|
||||
|
||||
/**
|
||||
* 直接将 [this] 构建为一个 [MessageChain]
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
public fun Collection<SingleMessage>.asMessageChain(): MessageChain = toMessageChain()
|
||||
|
||||
/**
|
||||
* 将 [this] [扁平化后][flatten] 构建为一个 [MessageChain]
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@JvmName("newChain1")
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
// @JsName("newChain")
|
||||
public fun Array<out Message>.asMessageChain(): MessageChain = toMessageChain()
|
||||
|
||||
@JvmSynthetic
|
||||
@JvmName("newChain2")
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
public fun Array<out SingleMessage>.asMessageChain(): MessageChain = toMessageChain()
|
||||
|
||||
/**
|
||||
* 将 [this] [扁平化后][flatten] 构建为一个 [MessageChain]
|
||||
*/
|
||||
@JvmName("newChain")
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
// @JsName("newChain")
|
||||
public fun Collection<Message>.asMessageChain(): MessageChain = toMessageChain()
|
||||
|
||||
/**
|
||||
* 直接将 [this] 构建为一个 [MessageChain]
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
public fun Iterable<SingleMessage>.asMessageChain(): MessageChain = toMessageChain()
|
||||
|
||||
@JvmSynthetic
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
public inline fun MessageChain.asMessageChain(): MessageChain = this
|
||||
|
||||
/**
|
||||
* 将 [this] [扁平化后][flatten] 构建为一个 [MessageChain]
|
||||
*/
|
||||
// @JsName("newChain")
|
||||
@JvmName("asMessageChainMessage")
|
||||
@JvmSynthetic
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
public fun Iterable<Message>.asMessageChain(): MessageChain = toMessageChain()
|
||||
|
||||
/**
|
||||
* 直接将 [this] 构建为一个 [MessageChain]
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
public fun Sequence<SingleMessage>.asMessageChain(): MessageChain = toMessageChain()
|
||||
|
||||
/**
|
||||
* 将 [this] [扁平化后][flatten] 构建为一个 [MessageChain]
|
||||
*/
|
||||
@JvmName("asMessageChainMessage")
|
||||
@JvmSynthetic
|
||||
@PlannedRemoval("2.0.0")
|
||||
@Deprecated(
|
||||
"Use toMessageChain.",
|
||||
ReplaceWith("this.toMessageChain()", "net.mamoe.mirai.message.data.toMessageChain"),
|
||||
ERROR
|
||||
)
|
||||
// @JsName("newChain")
|
||||
public fun Sequence<Message>.asMessageChain(): MessageChain = toMessageChain()
|
||||
|
||||
|
||||
/**
|
||||
* 扁平化消息序列.
|
||||
*
|
||||
* 原 [this]:
|
||||
* ```
|
||||
* A <- MessageChain(B, C) <- D <- MessageChain(E, F, G)
|
||||
* ```
|
||||
* 结果 [Sequence]:
|
||||
* ```
|
||||
* A <- B <- C <- D <- E <- F <- G
|
||||
* ```
|
||||
*/
|
||||
@Deprecated("flatten is deprecated.", ReplaceWith("this.toMessageChain().asSequence()"), ERROR)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public inline fun Iterable<Message>.flatten(): Sequence<SingleMessage> = toMessageChain().asSequence()
|
||||
|
||||
// @JsName("flatten1")
|
||||
@Deprecated("flatten is deprecated.", ReplaceWith("this.asSequence()"), ERROR)
|
||||
@PlannedRemoval("2.0.0")
|
||||
@JvmName("flatten1")// avoid platform declare clash
|
||||
@JvmSynthetic
|
||||
public inline fun Iterable<SingleMessage>.flatten(): Sequence<SingleMessage> = this.asSequence() // fast path
|
||||
|
||||
/**
|
||||
* 扁平化消息序列.
|
||||
*
|
||||
* 原 [this]:
|
||||
* ```
|
||||
* A <- MessageChain(B, C) <- D <- MessageChain(E, F, G)
|
||||
* ```
|
||||
* 结果 [Sequence]:
|
||||
* ```
|
||||
* A <- B <- C <- D <- E <- F <- G
|
||||
* ```
|
||||
*/
|
||||
@Deprecated("flatten is deprecated.", ReplaceWith("this.toMessageChain().asSequence()"), ERROR)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public inline fun Sequence<Message>.flatten(): Sequence<SingleMessage> = this.toMessageChain().asSequence()
|
||||
|
||||
@Deprecated("flatten is deprecated.", ReplaceWith("this"), ERROR)
|
||||
@PlannedRemoval("2.0.0")
|
||||
@JsName("flatten1") // avoid platform declare clash
|
||||
@JvmName("flatten1")
|
||||
@JvmSynthetic
|
||||
public inline fun Sequence<SingleMessage>.flatten(): Sequence<SingleMessage> = this // fast path
|
||||
|
||||
@Deprecated("flatten is deprecated.", ReplaceWith("this.toMessageChain().asSequence()"), ERROR)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public inline fun Array<out Message>.flatten(): Sequence<SingleMessage> = this.toMessageChain().asSequence()
|
||||
|
||||
@Deprecated("flatten is deprecated.", ReplaceWith("this.asSequence()"), ERROR)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public inline fun Array<out SingleMessage>.flatten(): Sequence<SingleMessage> = this.asSequence() // fast path
|
||||
|
||||
/**
|
||||
* 返回 [MessageChain.asSequence] 或 `sequenceOf(this as SingleMessage)`
|
||||
*/
|
||||
@Deprecated("flatten is deprecated.", ReplaceWith("this.toMessageChain().asSequence()"), ERROR)
|
||||
@PlannedRemoval("2.0.0")
|
||||
public fun Message.flatten(): Sequence<SingleMessage> = this.toMessageChain().asSequence()
|
||||
|
||||
@Deprecated("flatten is deprecated.", ReplaceWith("this.asSequence()"), ERROR)
|
||||
@PlannedRemoval("2.0.0")
|
||||
@JvmSynthetic // make Java user happier with less methods
|
||||
public inline fun MessageChain.flatten(): Sequence<SingleMessage> = this.asSequence() // fast path
|
Loading…
Reference in New Issue
Block a user