Commit b0718c5b authored by Him188's avatar Him188

Add experimental annotations

parent 51a95da5
...@@ -10,21 +10,33 @@ ...@@ -10,21 +10,33 @@
package net.mamoe.mirai.contact package net.mamoe.mirai.contact
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.utils.MiraiExperimentalAPI
import net.mamoe.mirai.utils.SinceMirai import net.mamoe.mirai.utils.SinceMirai
/** /**
* 拥有 [id] 的对象. * 拥有 [id] 的对象.
* 此为 [Contact] 与 [Bot] 的唯一公共接口. * 此为 [Contact] 与 [Bot] 的唯一公共接口.
* **注意:** 此接口为实验性接口, 将来可能会发生不兼容的更名.
* *
* @see Contact * @see Contact
* @see Bot * @see Bot
*/ */
@MiraiExperimentalAPI("classname may change") @ExperimentalIdentification("classname may change")
@SinceMirai("0.38.0") @SinceMirai("0.37.2")
interface Identified { interface Identified {
/** /**
* QQ 号或群号. * QQ 号或群号.
*/ */
val id: Long val id: Long
} }
\ No newline at end of file
/**
* 标记使用实验性 [Identified] 接口.
*/
@Retention(AnnotationRetention.SOURCE)
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPEALIAS, AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.CONSTRUCTOR)
annotation class ExperimentalIdentification(
val message: String = ""
)
\ No newline at end of file
...@@ -75,7 +75,7 @@ sealed class BotOfflineEvent : BotEvent { ...@@ -75,7 +75,7 @@ sealed class BotOfflineEvent : BotEvent {
/** /**
* 服务器主动要求更换另一个服务器 * 服务器主动要求更换另一个服务器
*/ */
@SinceMirai("0.38.0") @SinceMirai("0.37.1")
data class RequireReconnect(override val bot: Bot) : BotOfflineEvent(), Packet, BotPassiveEvent data class RequireReconnect(override val bot: Bot) : BotOfflineEvent(), Packet, BotPassiveEvent
} }
......
...@@ -458,7 +458,7 @@ open class MessageSubscribersBuilder<M : ContactMessage, out Ret, R : RR, RR>( ...@@ -458,7 +458,7 @@ open class MessageSubscribersBuilder<M : ContactMessage, out Ret, R : RR, RR>(
/** 如果消息内容 `==` [equals] */ /** 如果消息内容 `==` [equals] */
@MessageDsl @MessageDsl
@SinceMirai("0.38.0") @SinceMirai("0.37.1")
operator fun String.invoke(block: MessageListener<M, R>): Ret { operator fun String.invoke(block: MessageListener<M, R>): Ret {
return case(this, onEvent = block) return case(this, onEvent = block)
} }
......
...@@ -117,12 +117,14 @@ sealed class OnlineMessageSource : MessageSource() { ...@@ -117,12 +117,14 @@ sealed class OnlineMessageSource : MessageSource() {
* 消息发送人. 可能为 [机器人][Bot] 或 [好友][QQ] 或 [群员][Member]. * 消息发送人. 可能为 [机器人][Bot] 或 [好友][QQ] 或 [群员][Member].
* 即类型必定为 [Bot], [QQ] 或 [Member] * 即类型必定为 [Bot], [QQ] 或 [Member]
*/ */
@ExperimentalIdentification
abstract val sender: Identified abstract val sender: Identified
/** /**
* 消息发送目标. 可能为 [机器人][Bot] 或 [好友][QQ] 或 [群][Group]. * 消息发送目标. 可能为 [机器人][Bot] 或 [好友][QQ] 或 [群][Group].
* 即类型必定为 [Bot], [QQ] 或 [Group] * 即类型必定为 [Bot], [QQ] 或 [Group]
*/ */
@ExperimentalIdentification
abstract val target: Identified abstract val target: Identified
/** /**
...@@ -134,6 +136,7 @@ sealed class OnlineMessageSource : MessageSource() { ...@@ -134,6 +136,7 @@ sealed class OnlineMessageSource : MessageSource() {
/** /**
* 由 [机器人主动发送消息][Contact.sendMessage] 产生的 [MessageSource] * 由 [机器人主动发送消息][Contact.sendMessage] 产生的 [MessageSource]
*/ */
@OptIn(ExperimentalIdentification::class)
sealed class Outgoing : OnlineMessageSource() { sealed class Outgoing : OnlineMessageSource() {
companion object Key : Message.Key<Outgoing> { companion object Key : Message.Key<Outgoing> {
override val typeName: String get() = "OnlineMessageSource.Outgoing" override val typeName: String get() = "OnlineMessageSource.Outgoing"
...@@ -179,6 +182,7 @@ sealed class OnlineMessageSource : MessageSource() { ...@@ -179,6 +182,7 @@ sealed class OnlineMessageSource : MessageSource() {
/** /**
* 接收到的一条消息的 [MessageSource] * 接收到的一条消息的 [MessageSource]
*/ */
@OptIn(ExperimentalIdentification::class)
sealed class Incoming : OnlineMessageSource() { sealed class Incoming : OnlineMessageSource() {
companion object Key : Message.Key<Incoming> { companion object Key : Message.Key<Incoming> {
override val typeName: String get() = "OnlineMessageSource.Incoming" override val typeName: String get() = "OnlineMessageSource.Incoming"
...@@ -240,6 +244,7 @@ sealed class OnlineMessageSource : MessageSource() { ...@@ -240,6 +244,7 @@ sealed class OnlineMessageSource : MessageSource() {
@Deprecated("for binary compatibility until 1.0.0", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility until 1.0.0", level = DeprecationLevel.HIDDEN)
@get:JvmName("target") @get:JvmName("target")
@get:JvmSynthetic @get:JvmSynthetic
@OptIn(ExperimentalIdentification::class)
open val target2: Any open val target2: Any
get() = target get() = target
...@@ -247,6 +252,7 @@ sealed class OnlineMessageSource : MessageSource() { ...@@ -247,6 +252,7 @@ sealed class OnlineMessageSource : MessageSource() {
@Deprecated("for binary compatibility until 1.0.0", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility until 1.0.0", level = DeprecationLevel.HIDDEN)
@get:JvmName("sender") @get:JvmName("sender")
@get:JvmSynthetic @get:JvmSynthetic
@OptIn(ExperimentalIdentification::class)
open val sender2: Any open val sender2: Any
get() = sender get() = sender
} }
......
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