mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-14 07:10:09 +08:00
Add experimental annotations
This commit is contained in:
parent
51a95da5db
commit
b0718c5b2e
@ -10,21 +10,33 @@
|
||||
package net.mamoe.mirai.contact
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
|
||||
/**
|
||||
* 拥有 [id] 的对象.
|
||||
* 此为 [Contact] 与 [Bot] 的唯一公共接口.
|
||||
* **注意:** 此接口为实验性接口, 将来可能会发生不兼容的更名.
|
||||
*
|
||||
* @see Contact
|
||||
* @see Bot
|
||||
*/
|
||||
@MiraiExperimentalAPI("classname may change")
|
||||
@SinceMirai("0.38.0")
|
||||
@ExperimentalIdentification("classname may change")
|
||||
@SinceMirai("0.37.2")
|
||||
interface Identified {
|
||||
/**
|
||||
* QQ 号或群号.
|
||||
*/
|
||||
val id: Long
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 标记使用实验性 [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 = ""
|
||||
)
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -458,7 +458,7 @@ open class MessageSubscribersBuilder<M : ContactMessage, out Ret, R : RR, RR>(
|
||||
|
||||
/** 如果消息内容 `==` [equals] */
|
||||
@MessageDsl
|
||||
@SinceMirai("0.38.0")
|
||||
@SinceMirai("0.37.1")
|
||||
operator fun String.invoke(block: MessageListener<M, R>): Ret {
|
||||
return case(this, onEvent = block)
|
||||
}
|
||||
|
@ -117,12 +117,14 @@ sealed class OnlineMessageSource : MessageSource() {
|
||||
* 消息发送人. 可能为 [机器人][Bot] 或 [好友][QQ] 或 [群员][Member].
|
||||
* 即类型必定为 [Bot], [QQ] 或 [Member]
|
||||
*/
|
||||
@ExperimentalIdentification
|
||||
abstract val sender: Identified
|
||||
|
||||
/**
|
||||
* 消息发送目标. 可能为 [机器人][Bot] 或 [好友][QQ] 或 [群][Group].
|
||||
* 即类型必定为 [Bot], [QQ] 或 [Group]
|
||||
*/
|
||||
@ExperimentalIdentification
|
||||
abstract val target: Identified
|
||||
|
||||
/**
|
||||
@ -134,6 +136,7 @@ sealed class OnlineMessageSource : MessageSource() {
|
||||
/**
|
||||
* 由 [机器人主动发送消息][Contact.sendMessage] 产生的 [MessageSource]
|
||||
*/
|
||||
@OptIn(ExperimentalIdentification::class)
|
||||
sealed class Outgoing : OnlineMessageSource() {
|
||||
companion object Key : Message.Key<Outgoing> {
|
||||
override val typeName: String get() = "OnlineMessageSource.Outgoing"
|
||||
@ -179,6 +182,7 @@ sealed class OnlineMessageSource : MessageSource() {
|
||||
/**
|
||||
* 接收到的一条消息的 [MessageSource]
|
||||
*/
|
||||
@OptIn(ExperimentalIdentification::class)
|
||||
sealed class Incoming : OnlineMessageSource() {
|
||||
companion object Key : Message.Key<Incoming> {
|
||||
override val typeName: String get() = "OnlineMessageSource.Incoming"
|
||||
@ -240,6 +244,7 @@ sealed class OnlineMessageSource : MessageSource() {
|
||||
@Deprecated("for binary compatibility until 1.0.0", level = DeprecationLevel.HIDDEN)
|
||||
@get:JvmName("target")
|
||||
@get:JvmSynthetic
|
||||
@OptIn(ExperimentalIdentification::class)
|
||||
open val target2: Any
|
||||
get() = target
|
||||
|
||||
@ -247,6 +252,7 @@ sealed class OnlineMessageSource : MessageSource() {
|
||||
@Deprecated("for binary compatibility until 1.0.0", level = DeprecationLevel.HIDDEN)
|
||||
@get:JvmName("sender")
|
||||
@get:JvmSynthetic
|
||||
@OptIn(ExperimentalIdentification::class)
|
||||
open val sender2: Any
|
||||
get() = sender
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user