diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt index d7e04694d..516cc2243 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt @@ -48,7 +48,7 @@ suspend inline fun B.alsoLogin(): B = also { login() } */ @Suppress("INAPPLICABLE_JVM_NAME") @OptIn(MiraiInternalAPI::class, LowLevelAPI::class) -abstract class Bot : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI() { +abstract class Bot : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI(), Identified { companion object { /** * 复制一份此时的 [Bot] 实例列表. @@ -85,7 +85,7 @@ abstract class Bot : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI( * QQ 号码. 实际类型为 uint */ @SinceMirai("0.32.0") - abstract val id: Long + abstract override val id: Long /** * 昵称 diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt index 89db1d58a..526c69e8f 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt @@ -7,7 +7,7 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -@file:Suppress("EXPERIMENTAL_API_USAGE", "NOTHING_TO_INLINE") +@file:Suppress("EXPERIMENTAL_API_USAGE", "NOTHING_TO_INLINE", "EXPERIMENTAL_OVERRIDE") package net.mamoe.mirai.contact @@ -36,7 +36,7 @@ import kotlin.jvm.JvmSynthetic * @author Him188moe */ // 不要删除多平台结构 !!! kotlin bug @OptIn(MiraiInternalAPI::class, JavaFriendlyAPI::class) -abstract class Contact : CoroutineScope, ContactJavaFriendlyAPI() { +abstract class Contact : CoroutineScope, ContactJavaFriendlyAPI(), Identified { /** * 这个联系人所属 [Bot]. */ @@ -52,7 +52,7 @@ abstract class Contact : CoroutineScope, ContactJavaFriendlyAPI() { * @see QQ.id * @see Group.id */ - abstract val id: Long + abstract override val id: Long /** * 向这个对象发送消息. diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Identified.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Identified.kt new file mode 100644 index 000000000..8e1545a3d --- /dev/null +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Identified.kt @@ -0,0 +1,30 @@ +/* + * 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 + */ + +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") +interface Identified { + /** + * QQ 号或群号. + */ + val id: Long +} \ No newline at end of file