Introduce experimental common super interface Identified for Contact and Bot

This commit is contained in:
Him188 2020-04-13 12:13:34 +08:00
parent e10e404c6c
commit 45784c01a8
3 changed files with 35 additions and 5 deletions

View File

@ -48,7 +48,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() {
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
/**
* 昵称

View File

@ -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
/**
* 向这个对象发送消息.

View File

@ -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
}