Commit b0089d58 authored by Him188's avatar Him188

Deprecate ambiguous extensions on `QuoteReply`, like `QuoteReply.id`

parent b64b1da6
...@@ -38,12 +38,10 @@ import kotlin.reflect.KProperty ...@@ -38,12 +38,10 @@ import kotlin.reflect.KProperty
* - [asMessageChain] 将 [Iterable], 等类型消息 * - [asMessageChain] 将 [Iterable], 等类型消息
* - [messageChainOf] 类似 [listOf], 将多个 [Message] 构造为 [MessageChain] * - [messageChainOf] 类似 [listOf], 将多个 [Message] 构造为 [MessageChain]
* *
* ### 消息链如何工作
* - [SingleMessageChainImpl] 将 [单个消息][SingleMessage] 委托为一个 [MessageChain]
*
* @see get 获取消息链中一个类型的元素, 不存在时返回 `null` * @see get 获取消息链中一个类型的元素, 不存在时返回 `null`
* @see getOrFail 获取消息链中一个类型的元素, 不存在时抛出异常 [NoSuchElementException] * @see getOrFail 获取消息链中一个类型的元素, 不存在时抛出异常 [NoSuchElementException]
* @see quote 引用这条消息. * @see quote 引用这条消息
* @see recall 撤回这条消息 (
* *
* @see buildMessageChain 构造一个 [MessageChain] * @see buildMessageChain 构造一个 [MessageChain]
* @see asMessageChain 将单个 [Message] 转换为 [MessageChain] * @see asMessageChain 将单个 [Message] 转换为 [MessageChain]
......
...@@ -16,6 +16,7 @@ package net.mamoe.mirai.message.data ...@@ -16,6 +16,7 @@ package net.mamoe.mirai.message.data
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.utils.MiraiExperimentalAPI import net.mamoe.mirai.utils.MiraiExperimentalAPI
import net.mamoe.mirai.utils.PlannedRemoval
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext import kotlin.coroutines.EmptyCoroutineContext
import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmMultifileClass
...@@ -60,63 +61,75 @@ class QuoteReply(val source: MessageSource) : Message, MessageMetadata, Constrai ...@@ -60,63 +61,75 @@ class QuoteReply(val source: MessageSource) : Message, MessageMetadata, Constrai
} }
/** /**
* @see MessageSource.id * @see MessageSource.bot
*/ */
@get:JvmSynthetic @get:JvmSynthetic
inline val QuoteReply.id: Int inline val QuoteReply.bot: Bot
get() = source.id get() = source.bot
/** /**
* @see MessageSource.internalId * 撤回引用的源消息
*/ */
@JvmSynthetic
suspend inline fun QuoteReply.recallSource() = this.source.recall()
/**
* 在一段时间后撤回引用的源消息
*/
@JvmOverloads
inline fun QuoteReply.recallSourceIn(
millis: Long,
coroutineContext: CoroutineContext = EmptyCoroutineContext
): Job = this.source.recallIn(millis, coroutineContext)
//// 因语义不明而弃用的 API, 兼容到 1.3.0
@PlannedRemoval("1.3.0")
@get:JvmSynthetic
@Deprecated("use source.id for clearer semantics", ReplaceWith("source.id"))
inline val QuoteReply.id: Int
get() = source.id
@PlannedRemoval("1.3.0")
@get:JvmSynthetic @get:JvmSynthetic
@Deprecated("use source.internalId for clearer semantics", ReplaceWith("source.internalId"))
inline val QuoteReply.internalId: Int inline val QuoteReply.internalId: Int
get() = source.internalId get() = source.internalId
/** @PlannedRemoval("1.3.0")
* @see MessageSource.fromId
*/
@get:JvmSynthetic @get:JvmSynthetic
@Deprecated("use source.fromId for clearer semantics", ReplaceWith("source.fromId"))
inline val QuoteReply.fromId: Long inline val QuoteReply.fromId: Long
get() = source.fromId get() = source.fromId
/** @PlannedRemoval("1.3.0")
* @see MessageSource.targetId
*/
@get:JvmSynthetic @get:JvmSynthetic
@Deprecated("use source.targetId for clearer semantics", ReplaceWith("source.targetId"))
inline val QuoteReply.targetId: Long inline val QuoteReply.targetId: Long
get() = source.targetId get() = source.targetId
/** @PlannedRemoval("1.3.0")
* @see MessageSource.originalMessage
*/
@get:JvmSynthetic @get:JvmSynthetic
@Deprecated("use source.originalMessage for clearer semantics", ReplaceWith("source.originalMessage"))
inline val QuoteReply.originalMessage: MessageChain inline val QuoteReply.originalMessage: MessageChain
get() = source.originalMessage get() = source.originalMessage
/** @PlannedRemoval("1.3.0")
* @see MessageSource.time
*/
@get:JvmSynthetic @get:JvmSynthetic
@Deprecated("use source.time for clearer semantics", ReplaceWith("source.time"))
inline val QuoteReply.time: Int inline val QuoteReply.time: Int
get() = source.time get() = source.time
/** @PlannedRemoval("1.3.0")
* @see MessageSource.bot @Deprecated("use recallSourceIn for clearer semantics", ReplaceWith("recallSourceIn(millis, coroutineContext)"))
*/
@get:JvmSynthetic
inline val QuoteReply.bot: Bot
get() = source.bot
@JvmSynthetic
suspend inline fun QuoteReply.recall() = this.source.recall()
/**
* 在一段时间后撤回这条消息.
*/
@JvmOverloads @JvmOverloads
inline fun QuoteReply.recallIn( inline fun QuoteReply.recallIn(
millis: Long, millis: Long,
coroutineContext: CoroutineContext = EmptyCoroutineContext coroutineContext: CoroutineContext = EmptyCoroutineContext
): Job = this.source.recallIn(millis, coroutineContext) ): Job = recallSourceIn(millis, coroutineContext)
\ No newline at end of file
@PlannedRemoval("1.3.0")
@Deprecated("use recallSource for clearer semantics", ReplaceWith("this.recallSource()"))
@JvmSynthetic
suspend inline fun QuoteReply.recall() = recallSource()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment