Rename Identified to ContactOrBot, remove experimental annotations

This commit is contained in:
Him188 2020-04-22 14:03:29 +08:00
parent 15527b56d8
commit 3c9b057ad0
4 changed files with 8 additions and 21 deletions

View File

@ -50,7 +50,7 @@ suspend inline fun <B : Bot> B.alsoLogin(): B = also { login() }
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@OptIn(MiraiInternalAPI::class, LowLevelAPI::class)
abstract class Bot : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI(), Identified {
abstract class Bot : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI(), ContactOrBot {
companion object {
/**
* 复制一份此时的 [Bot] 实例列表.

View File

@ -8,6 +8,7 @@
*/
@file:Suppress("EXPERIMENTAL_API_USAGE", "NOTHING_TO_INLINE", "EXPERIMENTAL_OVERRIDE")
@file:OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class)
package net.mamoe.mirai.contact
@ -34,9 +35,8 @@ import kotlin.jvm.JvmSynthetic
* 联系人. 虽然叫做联系人, 但他的子类有 [QQ], [群成员][Member] [][Group].
*
* @author Him188moe
*/ // 不要删除多平台结构 !!! kotlin bug
@OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class)
abstract class Contact : CoroutineScope, ContactJavaFriendlyAPI(), Identified {
*/
abstract class Contact : CoroutineScope, ContactJavaFriendlyAPI(), ContactOrBot {
/**
* 这个联系人所属 [Bot].
*/

View File

@ -20,23 +20,10 @@ import net.mamoe.mirai.utils.SinceMirai
* @see Contact
* @see Bot
*/
@ExperimentalIdentification("classname may change")
@SinceMirai("0.37.2")
interface Identified {
interface ContactOrBot {
/**
* 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 = ""
)
}

View File

@ -117,14 +117,14 @@ sealed class OnlineMessageSource : MessageSource() {
* 即类型必定为 [Bot], [QQ] [Member]
*/
@ExperimentalIdentification
abstract val sender: Identified
abstract val sender: ContactOrBot
/**
* 消息发送目标. 可能为 [机器人][Bot] [好友][QQ] [][Group].
* 即类型必定为 [Bot], [QQ] [Group]
*/
@ExperimentalIdentification
abstract val target: Identified
abstract val target: ContactOrBot
/**
* 消息主体. 群消息时为 [Group]. 好友消息时为 [QQ], 临时消息为 [Member]