diff --git a/binary-compatibility-validator/android/api/binary-compatibility-validator-android.api b/binary-compatibility-validator/android/api/binary-compatibility-validator-android.api index c0d95ff5d..7b87b3490 100644 --- a/binary-compatibility-validator/android/api/binary-compatibility-validator-android.api +++ b/binary-compatibility-validator/android/api/binary-compatibility-validator-android.api @@ -5624,6 +5624,10 @@ public final class net/mamoe/mirai/utils/MiraiLoggerWithSwitch : net/mamoe/mirai public fun warning0 (Ljava/lang/String;Ljava/lang/Throwable;)V } +public abstract interface annotation class net/mamoe/mirai/utils/NotStableForInheritance : java/lang/annotation/Annotation { + public abstract fun message ()Ljava/lang/String; +} + public final class net/mamoe/mirai/utils/OverFileSizeMaxException : java/lang/IllegalStateException { public fun <init> ()V } diff --git a/binary-compatibility-validator/api/binary-compatibility-validator.api b/binary-compatibility-validator/api/binary-compatibility-validator.api index 13ea6ff11..617212022 100644 --- a/binary-compatibility-validator/api/binary-compatibility-validator.api +++ b/binary-compatibility-validator/api/binary-compatibility-validator.api @@ -5624,6 +5624,10 @@ public final class net/mamoe/mirai/utils/MiraiLoggerWithSwitch : net/mamoe/mirai public fun warning0 (Ljava/lang/String;Ljava/lang/Throwable;)V } +public abstract interface annotation class net/mamoe/mirai/utils/NotStableForInheritance : java/lang/annotation/Annotation { + public abstract fun message ()Ljava/lang/String; +} + public final class net/mamoe/mirai/utils/OverFileSizeMaxException : java/lang/IllegalStateException { public fun <init> ()V } diff --git a/mirai-core-api/src/commonMain/kotlin/Bot.kt b/mirai-core-api/src/commonMain/kotlin/Bot.kt index a544232e8..d6aecf7bb 100644 --- a/mirai-core-api/src/commonMain/kotlin/Bot.kt +++ b/mirai-core-api/src/commonMain/kotlin/Bot.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("NOTHING_TO_INLINE") @@ -22,6 +22,7 @@ import net.mamoe.mirai.message.action.MemberNudge import net.mamoe.mirai.network.LoginFailedException import net.mamoe.mirai.utils.BotConfiguration import net.mamoe.mirai.utils.MiraiLogger +import net.mamoe.mirai.utils.NotStableForInheritance import java.util.concurrent.ConcurrentHashMap /** @@ -41,6 +42,7 @@ public suspend inline fun <B : Bot> B.alsoLogin(): B = also { login() } * * @see BotFactory 构造 [Bot] 的工厂, [Bot] 唯一的构造方式. */ +@NotStableForInheritance public interface Bot : CoroutineScope, ContactOrBot, UserOrBot { /** * Bot 配置 diff --git a/mirai-core-api/src/commonMain/kotlin/IMirai.kt b/mirai-core-api/src/commonMain/kotlin/IMirai.kt index 9688a397f..cd29fe42c 100644 --- a/mirai-core-api/src/commonMain/kotlin/IMirai.kt +++ b/mirai-core-api/src/commonMain/kotlin/IMirai.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("INTERFACE_NOT_SUPPORTED", "PropertyName") @@ -33,6 +33,7 @@ import net.mamoe.mirai.message.data.MessageSource.Key.recall import net.mamoe.mirai.utils.FileCacheStrategy import net.mamoe.mirai.utils.MiraiExperimentalApi import net.mamoe.mirai.utils.MiraiInternalApi +import net.mamoe.mirai.utils.NotStableForInheritance /** * [IMirai] 实例. @@ -75,6 +76,7 @@ public val Mirai: IMirai * * @see Mirai 获取实例 */ +@NotStableForInheritance public interface IMirai : LowLevelApiAccessor { /** * 请优先使用 [BotFactory.INSTANCE] diff --git a/mirai-core-api/src/commonMain/kotlin/LowLevelApiAccessor.kt b/mirai-core-api/src/commonMain/kotlin/LowLevelApiAccessor.kt index 1cc3bff8c..dd325bdd7 100644 --- a/mirai-core-api/src/commonMain/kotlin/LowLevelApiAccessor.kt +++ b/mirai-core-api/src/commonMain/kotlin/LowLevelApiAccessor.kt @@ -16,10 +16,7 @@ import net.mamoe.kjbb.JvmBlockingBridge import net.mamoe.mirai.contact.* import net.mamoe.mirai.data.* import net.mamoe.mirai.message.data.Voice -import net.mamoe.mirai.utils.ExternalResource -import net.mamoe.mirai.utils.MiraiExperimentalApi -import net.mamoe.mirai.utils.MiraiInternalApi -import net.mamoe.mirai.utils.WeakRef +import net.mamoe.mirai.utils.* import kotlin.annotation.AnnotationTarget.* /** @@ -41,6 +38,7 @@ public annotation class LowLevelApi * **警告**: 所有的低级 API 都可能在任意时刻不经过任何警告和迭代就被修改. 因此非常不建议在任何情况下使用这些 API. */ @LowLevelApi +@NotStableForInheritance public interface LowLevelApiAccessor { /** * 主动刷新 keys, 如 SKey, PSKey 等. diff --git a/mirai-core-api/src/commonMain/kotlin/contact/AnonymousMember.kt b/mirai-core-api/src/commonMain/kotlin/contact/AnonymousMember.kt index 4a3530631..1ea417f17 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/AnonymousMember.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/AnonymousMember.kt @@ -7,19 +7,22 @@ * https://github.com/mamoe/mirai/blob/dev/LICENSE */ +@file:Suppress("DeprecatedCallableAddReplaceWith") + package net.mamoe.mirai.contact import net.mamoe.mirai.message.action.MemberNudge import net.mamoe.mirai.message.data.Image import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.utils.ExternalResource +import net.mamoe.mirai.utils.NotStableForInheritance /** * 匿名 * * 代表匿名群成员 */ -@Suppress("DeprecatedCallableAddReplaceWith") +@NotStableForInheritance public interface AnonymousMember : Member { /** 该匿名群成员 ID */ public val anonymousId: String diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt b/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt index 20b06664f..7e0e87e55 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt @@ -1,23 +1,27 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("EXPERIMENTAL_API_USAGE", "NOTHING_TO_INLINE", "EXPERIMENTAL_OVERRIDE") @file:OptIn(JavaFriendlyAPI::class) +@file:JvmBlockingBridge package net.mamoe.mirai.contact import kotlinx.coroutines.CoroutineScope import net.mamoe.kjbb.JvmBlockingBridge -import net.mamoe.mirai.* +import net.mamoe.mirai.Bot +import net.mamoe.mirai.IMirai +import net.mamoe.mirai.Mirai import net.mamoe.mirai.event.events.* import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.message.data.* +import net.mamoe.mirai.recallMessage import net.mamoe.mirai.utils.* import net.mamoe.mirai.utils.ExternalResource.Companion.sendAsImageTo import net.mamoe.mirai.utils.ExternalResource.Companion.uploadAsImage @@ -27,7 +31,7 @@ import java.io.InputStream /** * 联系对象, 即可以与 [Bot] 互动的对象. 包含 [用户][User], 和 [群][Group]. */ -@JvmBlockingBridge +@NotStableForInheritance public interface Contact : ContactOrBot, CoroutineScope { /** * 这个联系对象所属 [Bot]. diff --git a/mirai-core-api/src/commonMain/kotlin/contact/ContactOrBot.kt b/mirai-core-api/src/commonMain/kotlin/contact/ContactOrBot.kt index e568bb624..4f3e1d2ab 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/ContactOrBot.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/ContactOrBot.kt @@ -1,16 +1,17 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ package net.mamoe.mirai.contact import kotlinx.coroutines.CoroutineScope import net.mamoe.mirai.Bot +import net.mamoe.mirai.utils.NotStableForInheritance /** * 拥有 [id] 的对象. @@ -21,6 +22,7 @@ import net.mamoe.mirai.Bot * @see Contact * @see Bot */ +@NotStableForInheritance public interface ContactOrBot : CoroutineScope { /** * QQ 号或群号. diff --git a/mirai-core-api/src/commonMain/kotlin/contact/FileSupported.kt b/mirai-core-api/src/commonMain/kotlin/contact/FileSupported.kt index bfe386726..467c3953d 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/FileSupported.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/FileSupported.kt @@ -1,15 +1,16 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ package net.mamoe.mirai.contact +import net.mamoe.mirai.utils.NotStableForInheritance import net.mamoe.mirai.utils.RemoteFile /** @@ -19,6 +20,7 @@ import net.mamoe.mirai.utils.RemoteFile * * @since 2.5 */ +@NotStableForInheritance public interface FileSupported : Contact { /** * 文件根目录. 可通过 [RemoteFile.listFiles] 获取目录下文件列表. diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Friend.kt b/mirai-core-api/src/commonMain/kotlin/contact/Friend.kt index 6c30a132b..e387f6bcf 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Friend.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Friend.kt @@ -8,6 +8,7 @@ */ @file:Suppress("EXPERIMENTAL_API_USAGE", "unused", "UnusedImport") +@file:JvmBlockingBridge package net.mamoe.mirai.contact @@ -21,6 +22,7 @@ import net.mamoe.mirai.message.action.Nudge import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.isContentEmpty import net.mamoe.mirai.message.data.toPlainText +import net.mamoe.mirai.utils.NotStableForInheritance /** * 代表一位好友. @@ -31,7 +33,7 @@ import net.mamoe.mirai.message.data.toPlainText * * @see FriendMessageEvent */ -@JvmBlockingBridge +@NotStableForInheritance public interface Friend : User, CoroutineScope, VoiceSupported { /** * QQ 号码 diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Group.kt b/mirai-core-api/src/commonMain/kotlin/contact/Group.kt index 58f9f58e7..ef699125e 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Group.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Group.kt @@ -1,13 +1,14 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("EXPERIMENTAL_API_USAGE", "unused", "UnusedImport", "NOTHING_TO_INLINE") +@file:JvmBlockingBridge package net.mamoe.mirai.contact @@ -23,15 +24,13 @@ import net.mamoe.mirai.data.covertToGroupAnnouncement import net.mamoe.mirai.event.events.* import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.message.data.* -import net.mamoe.mirai.utils.ExternalResource -import net.mamoe.mirai.utils.ExternalResource.Companion.uploadAsVoice import net.mamoe.mirai.utils.MiraiExperimentalApi -import net.mamoe.mirai.utils.OverFileSizeMaxException +import net.mamoe.mirai.utils.NotStableForInheritance /** * 群. */ -@JvmBlockingBridge +@NotStableForInheritance public interface Group : Contact, CoroutineScope, FileSupported, VoiceSupported { /** * 群名称. diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Member.kt b/mirai-core-api/src/commonMain/kotlin/contact/Member.kt index 7e6b5bdf2..ba957cdf1 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Member.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Member.kt @@ -1,13 +1,14 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("unused", "UnusedImport") +@file:JvmBlockingBridge package net.mamoe.mirai.contact @@ -19,6 +20,7 @@ import net.mamoe.mirai.message.action.MemberNudge import net.mamoe.mirai.message.action.Nudge import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.isContentEmpty +import net.mamoe.mirai.utils.NotStableForInheritance import net.mamoe.mirai.utils.WeakRefProperty /** @@ -34,7 +36,7 @@ import net.mamoe.mirai.utils.WeakRefProperty * - [Member.asFriend] 转换为 [Friend] * - [Member.asStranger] 转换为 [Stranger] */ -@JvmBlockingBridge +@NotStableForInheritance public interface Member : User { /** * 所在的群. diff --git a/mirai-core-api/src/commonMain/kotlin/contact/NormalMember.kt b/mirai-core-api/src/commonMain/kotlin/contact/NormalMember.kt index f166ec59a..92e2e9dd2 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/NormalMember.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/NormalMember.kt @@ -1,12 +1,14 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ +@file:JvmBlockingBridge + package net.mamoe.mirai.contact import net.mamoe.kjbb.JvmBlockingBridge @@ -18,6 +20,7 @@ import net.mamoe.mirai.message.action.Nudge import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.isContentEmpty import net.mamoe.mirai.message.data.toPlainText +import net.mamoe.mirai.utils.NotStableForInheritance import kotlin.time.Duration import kotlin.time.DurationUnit import kotlin.time.ExperimentalTime @@ -28,7 +31,7 @@ import kotlin.time.ExperimentalTime * 群成员可能也是好友, 但他们在对象类型上不同. * 群成员可以通过 [asFriend] 得到相关好友对象. */ -@JvmBlockingBridge +@NotStableForInheritance public interface NormalMember : Member { /** * 群名片. 可能为空. diff --git a/mirai-core-api/src/commonMain/kotlin/contact/OtherClient.kt b/mirai-core-api/src/commonMain/kotlin/contact/OtherClient.kt index ff6123018..20fde162c 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/OtherClient.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/OtherClient.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("unused") @@ -20,11 +20,13 @@ import net.mamoe.mirai.utils.BotConfiguration.MiraiProtocol.ANDROID_PAD import net.mamoe.mirai.utils.BotConfiguration.MiraiProtocol.ANDROID_PHONE import net.mamoe.mirai.utils.ExternalResource import net.mamoe.mirai.utils.MiraiInternalApi +import net.mamoe.mirai.utils.NotStableForInheritance import net.mamoe.mirai.utils.toLongUnsigned /** * 其他设备. 如当 [Bot] 以 [ANDROID_PHONE] 登录时, 还可以有其他设备以 [ANDROID_PAD], iOS, PC 或其他设备登录. */ +@NotStableForInheritance public interface OtherClient : Contact { public val info: OtherClientInfo diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Stranger.kt b/mirai-core-api/src/commonMain/kotlin/contact/Stranger.kt index ed18af9a8..8494947a3 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Stranger.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Stranger.kt @@ -1,13 +1,14 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("EXPERIMENTAL_API_USAGE", "unused", "UnusedImport") +@file:JvmBlockingBridge package net.mamoe.mirai.contact @@ -21,6 +22,7 @@ import net.mamoe.mirai.message.action.StrangerNudge import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.isContentEmpty import net.mamoe.mirai.message.data.toPlainText +import net.mamoe.mirai.utils.NotStableForInheritance /** * 代表一位陌生人. @@ -39,7 +41,7 @@ import net.mamoe.mirai.message.data.toPlainText * * @see StrangerMessageEvent */ -@JvmBlockingBridge +@NotStableForInheritance public interface Stranger : User, CoroutineScope { /** * QQ 号码 diff --git a/mirai-core-api/src/commonMain/kotlin/contact/TempUser.kt b/mirai-core-api/src/commonMain/kotlin/contact/TempUser.kt index b278434de..cccb036fe 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/TempUser.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/TempUser.kt @@ -10,6 +10,7 @@ package net.mamoe.mirai.contact import net.mamoe.mirai.utils.MiraiInternalApi +import net.mamoe.mirai.utils.NotStableForInheritance /** * 临时会话用户, 非群成员. @@ -17,4 +18,5 @@ import net.mamoe.mirai.utils.MiraiInternalApi * [#429](https://github.com/mamoe/mirai/issues/429) */ @MiraiInternalApi("其他渠道的临时会话暂未支持. ") +@NotStableForInheritance public interface TempUser : User \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/contact/User.kt b/mirai-core-api/src/commonMain/kotlin/contact/User.kt index a9ddde4ac..8de9b4a6a 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/User.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/User.kt @@ -1,13 +1,14 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("EXPERIMENTAL_API_USAGE", "unused") +@file:JvmBlockingBridge package net.mamoe.mirai.contact @@ -25,6 +26,7 @@ import net.mamoe.mirai.message.action.UserNudge import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.isContentEmpty import net.mamoe.mirai.message.data.toPlainText +import net.mamoe.mirai.utils.NotStableForInheritance /** * 代表一个 **用户**. @@ -36,7 +38,7 @@ import net.mamoe.mirai.message.data.toPlainText * * 对于同一个 [Bot] 任何一个人的 [User] 实例都是单一的. */ -@JvmBlockingBridge +@NotStableForInheritance public interface User : Contact, UserOrBot, CoroutineScope { /** * QQ 号码 diff --git a/mirai-core-api/src/commonMain/kotlin/contact/UserOrBot.kt b/mirai-core-api/src/commonMain/kotlin/contact/UserOrBot.kt index a4fe53641..576856800 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/UserOrBot.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/UserOrBot.kt @@ -1,16 +1,17 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ package net.mamoe.mirai.contact import net.mamoe.mirai.Bot import net.mamoe.mirai.message.action.Nudge +import net.mamoe.mirai.utils.NotStableForInheritance /** * @see User @@ -18,6 +19,7 @@ import net.mamoe.mirai.message.action.Nudge * * @see ContactOrBot */ +@NotStableForInheritance public interface UserOrBot : ContactOrBot { /** * 昵称 diff --git a/mirai-core-api/src/commonMain/kotlin/contact/VoiceSupported.kt b/mirai-core-api/src/commonMain/kotlin/contact/VoiceSupported.kt index 54cf615ff..5db799a70 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/VoiceSupported.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/VoiceSupported.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ package net.mamoe.mirai.contact @@ -13,6 +13,7 @@ import net.mamoe.kjbb.JvmBlockingBridge import net.mamoe.mirai.message.data.Voice import net.mamoe.mirai.utils.ExternalResource import net.mamoe.mirai.utils.ExternalResource.Companion.uploadAsVoice +import net.mamoe.mirai.utils.NotStableForInheritance import net.mamoe.mirai.utils.OverFileSizeMaxException /** @@ -20,6 +21,7 @@ import net.mamoe.mirai.utils.OverFileSizeMaxException * * @since 2.7 */ +@NotStableForInheritance public interface VoiceSupported : Contact { /** * 上传一个语音消息以备发送. diff --git a/mirai-core-api/src/commonMain/kotlin/event/Listener.kt b/mirai-core-api/src/commonMain/kotlin/event/Listener.kt index e01cb2a0a..87b836f7d 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/Listener.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/Listener.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("unused", "DEPRECATION", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @@ -16,6 +16,7 @@ package net.mamoe.mirai.event import kotlinx.coroutines.CompletableJob import kotlinx.coroutines.sync.Mutex import net.mamoe.mirai.event.EventPriority.* +import net.mamoe.mirai.utils.NotStableForInheritance /** * 订阅者的状态 @@ -43,6 +44,7 @@ public enum class ListeningStatus { * * 取消监听: [complete] */ +@NotStableForInheritance public interface Listener<in E : Event> : CompletableJob { // Impl notes: diff --git a/mirai-core-api/src/commonMain/kotlin/message/MessageReceipt.kt b/mirai-core-api/src/commonMain/kotlin/message/MessageReceipt.kt index d7ac48b33..311738ef3 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/MessageReceipt.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/MessageReceipt.kt @@ -1,13 +1,14 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("NOTHING_TO_INLINE", "FunctionName", "unused") +@file:JvmBlockingBridge package net.mamoe.mirai.message @@ -21,6 +22,7 @@ import net.mamoe.mirai.message.data.* import net.mamoe.mirai.message.data.MessageSource.Key.quote import net.mamoe.mirai.message.data.MessageSource.Key.recallIn import net.mamoe.mirai.utils.MiraiInternalApi +import net.mamoe.mirai.utils.NotStableForInheritance /** * 发送消息后得到的回执. 可用于撤回, 引用回复等. @@ -39,7 +41,7 @@ import net.mamoe.mirai.utils.MiraiInternalApi * @see MessageReceipt.sourceIds 源 ids * @see MessageReceipt.sourceTime 源时间 */ -@JvmBlockingBridge +@NotStableForInheritance public open class MessageReceipt<out C : Contact> @MiraiInternalApi @Deprecated("Do not call it directly", level = DeprecationLevel.ERROR) diff --git a/mirai-core-api/src/commonMain/kotlin/message/MessageSerializers.kt b/mirai-core-api/src/commonMain/kotlin/message/MessageSerializers.kt index 9b715e6a4..29423fcf9 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/MessageSerializers.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/MessageSerializers.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ package net.mamoe.mirai.message @@ -22,6 +22,7 @@ import net.mamoe.mirai.message.data.MessageChain import net.mamoe.mirai.message.data.MessageChain.Companion.serializeToJsonString import net.mamoe.mirai.message.data.SingleMessage import net.mamoe.mirai.utils.MiraiExperimentalApi +import net.mamoe.mirai.utils.NotStableForInheritance import kotlin.reflect.KClass /** @@ -38,6 +39,7 @@ import kotlin.reflect.KClass * * @see MessageSerializers.INSTANCE */ +@NotStableForInheritance public interface MessageSerializers { /** * 包含 [SingleMessage] 多态序列化和 [Message] [ContextualSerializer] 信息的 [SerializersModule]. diff --git a/mirai-core-api/src/commonMain/kotlin/message/code/CodableMessage.kt b/mirai-core-api/src/commonMain/kotlin/message/code/CodableMessage.kt index f355f598d..eb0625dea 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/code/CodableMessage.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/code/CodableMessage.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ package net.mamoe.mirai.message.code @@ -12,6 +12,7 @@ package net.mamoe.mirai.message.code import net.mamoe.mirai.message.code.MiraiCode.deserializeMiraiCode import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.utils.MiraiExperimentalApi +import net.mamoe.mirai.utils.NotStableForInheritance /** @@ -19,8 +20,12 @@ import net.mamoe.mirai.utils.MiraiExperimentalApi * * 从字符串解析 mirai 码:[MiraiCode.deserializeMiraiCode] * + * ### 不适合第三方实现 + * 即使自定义消息类型实现了接口 [CodableMessage], 在 [MiraiCode.deserializeMiraiCode] 时也无法解析消息类型. 因此实现没有意义. + * * @see MiraiCode */ +@NotStableForInheritance public interface CodableMessage : Message { /** * 转换为 mirai 码. diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/FileMessage.kt b/mirai-core-api/src/commonMain/kotlin/message/data/FileMessage.kt index cbc4ed78f..500305b65 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/FileMessage.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/FileMessage.kt @@ -39,6 +39,7 @@ import net.mamoe.mirai.utils.* */ @Serializable(FileMessage.Serializer::class) @SerialName(FileMessage.SERIAL_NAME) +@NotStableForInheritance public interface FileMessage : MessageContent, ConstrainSingle, CodableMessage { /** * 服务器需要的某种 ID. diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/HummerMessage.kt b/mirai-core-api/src/commonMain/kotlin/message/data/HummerMessage.kt index 3ec5f5b9f..bd76a4c1e 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/HummerMessage.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/HummerMessage.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("unused", "NOTHING_TO_INLINE") @@ -14,6 +14,7 @@ package net.mamoe.mirai.message.data import net.mamoe.mirai.utils.MiraiExperimentalApi +import net.mamoe.mirai.utils.NotStableForInheritance import net.mamoe.mirai.utils.castOrNull /** @@ -27,6 +28,7 @@ import net.mamoe.mirai.utils.castOrNull * @see VipFace VIP 表情 */ @MiraiExperimentalApi +@NotStableForInheritance public interface HummerMessage : MessageContent, ConstrainSingle { public companion object Key : AbstractPolymorphicMessageKey<MessageContent, HummerMessage>(MessageContent, { it.castOrNull() }) diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/Image.kt b/mirai-core-api/src/commonMain/kotlin/message/data/Image.kt index 47c050142..4977aecc5 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/Image.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/Image.kt @@ -70,6 +70,7 @@ import kotlin.LazyThreadSafetyMode.NONE * @see Image.flash 转换普通图片为闪照 */ @Serializable(Image.Serializer::class) +@NotStableForInheritance public interface Image : Message, MessageContent, CodableMessage { /** diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/MarketFace.kt b/mirai-core-api/src/commonMain/kotlin/message/data/MarketFace.kt index 4eb9a3fb4..e1bfa808e 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/MarketFace.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/MarketFace.kt @@ -1,15 +1,16 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ package net.mamoe.mirai.message.data import net.mamoe.mirai.utils.MiraiExperimentalApi +import net.mamoe.mirai.utils.NotStableForInheritance import net.mamoe.mirai.utils.safeCast /** @@ -19,6 +20,7 @@ import net.mamoe.mirai.utils.safeCast * * @see Dice */ +@NotStableForInheritance public interface MarketFace : HummerMessage { /** * 如 `[开心]` diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/MessageChain.kt b/mirai-core-api/src/commonMain/kotlin/message/data/MessageChain.kt index b32e7a4c4..af4cc731d 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/MessageChain.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/MessageChain.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:JvmMultifileClass @@ -33,6 +33,7 @@ import net.mamoe.mirai.message.data.MessageSource.Key.quote import net.mamoe.mirai.message.data.MessageSource.Key.recall import net.mamoe.mirai.message.data.MessageSource.Key.recallIn import net.mamoe.mirai.utils.MiraiExperimentalApi +import net.mamoe.mirai.utils.NotStableForInheritance import net.mamoe.mirai.utils.safeCast import java.util.stream.Stream import kotlin.reflect.KProperty @@ -184,6 +185,7 @@ import kotlin.streams.asSequence * */ @Serializable(MessageChain.Serializer::class) +@NotStableForInheritance public sealed interface MessageChain : Message, List<SingleMessage>, RandomAccess, CodableMessage { diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/MessageSource.kt b/mirai-core-api/src/commonMain/kotlin/message/data/MessageSource.kt index 3ecefe977..d5516de9f 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/MessageSource.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/MessageSource.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:JvmMultifileClass @@ -30,6 +30,7 @@ import net.mamoe.mirai.message.data.MessageSource.Key.quote import net.mamoe.mirai.message.data.MessageSource.Key.recall import net.mamoe.mirai.utils.LazyProperty import net.mamoe.mirai.utils.MiraiInternalApi +import net.mamoe.mirai.utils.NotStableForInheritance import net.mamoe.mirai.utils.safeCast /** @@ -474,6 +475,7 @@ public sealed class OnlineMessageSource : MessageSource() { // TODO: 2021/1/10 E public final override val fromId: Long get() = sender.id public final override val targetId: Long get() = target.id + @NotStableForInheritance public abstract class ToFriend @MiraiInternalApi constructor() : Outgoing() { public companion object Key : AbstractPolymorphicMessageKey<Outgoing, ToFriend>(Outgoing, { it.safeCast() }) @@ -482,6 +484,7 @@ public sealed class OnlineMessageSource : MessageSource() { // TODO: 2021/1/10 E // final override fun toString(): String = "OnlineMessageSource.ToFriend(target=${target.ids})" } + @NotStableForInheritance public abstract class ToStranger @MiraiInternalApi constructor() : Outgoing() { public companion object Key : AbstractPolymorphicMessageKey<Outgoing, ToStranger>(Outgoing, { it.safeCast() }) @@ -491,6 +494,7 @@ public sealed class OnlineMessageSource : MessageSource() { // TODO: 2021/1/10 E // final override fun toString(): String = "OnlineMessageSource.ToFriend(target=${target.ids})" } + @NotStableForInheritance public abstract class ToTemp @MiraiInternalApi constructor() : Outgoing() { public companion object Key : AbstractPolymorphicMessageKey<Outgoing, ToTemp>(Outgoing, { it.safeCast() }) @@ -499,6 +503,7 @@ public sealed class OnlineMessageSource : MessageSource() { // TODO: 2021/1/10 E public final override val subject: Member get() = target } + @NotStableForInheritance public abstract class ToGroup @MiraiInternalApi constructor() : Outgoing() { public companion object Key : AbstractPolymorphicMessageKey<Outgoing, ToGroup>(Outgoing, { it.safeCast() }) @@ -516,6 +521,7 @@ public sealed class OnlineMessageSource : MessageSource() { // TODO: 2021/1/10 E public final override val fromId: Long get() = sender.id public final override val targetId: Long get() = target.id + @NotStableForInheritance public abstract class FromFriend @MiraiInternalApi constructor() : Incoming() { public companion object Key : AbstractPolymorphicMessageKey<Incoming, FromFriend>(Incoming, { it.safeCast() }) @@ -526,6 +532,7 @@ public sealed class OnlineMessageSource : MessageSource() { // TODO: 2021/1/10 E // final override fun toString(): String = "OnlineMessageSource.FromFriend(from=${sender.ids})" } + @NotStableForInheritance public abstract class FromTemp @MiraiInternalApi constructor() : Incoming() { public companion object Key : AbstractPolymorphicMessageKey<Incoming, FromTemp>(Incoming, { it.safeCast() }) @@ -536,6 +543,7 @@ public sealed class OnlineMessageSource : MessageSource() { // TODO: 2021/1/10 E public final override val target: Bot get() = sender.bot } + @NotStableForInheritance public abstract class FromStranger @MiraiInternalApi constructor() : Incoming() { public companion object Key : AbstractPolymorphicMessageKey<Incoming, FromStranger>(Incoming, { it.safeCast() }) @@ -545,6 +553,7 @@ public sealed class OnlineMessageSource : MessageSource() { // TODO: 2021/1/10 E public final override val target: Bot get() = sender.bot } + @NotStableForInheritance public abstract class FromGroup @MiraiInternalApi constructor() : Incoming() { public companion object Key : AbstractPolymorphicMessageKey<Incoming, FromGroup>(Incoming, { it.safeCast() }) @@ -567,6 +576,7 @@ public sealed class OnlineMessageSource : MessageSource() { // TODO: 2021/1/10 E * * 要获得 [OfflineMessageSource], 使用 [MessageSourceBuilder]. 或通过 [OnlineMessageSource.toOffline] 转换得到 (一般没有必要). */ +@NotStableForInheritance public abstract class OfflineMessageSource : MessageSource() { // TODO: 2021/1/10 Extract to separate file in Kotlin 1.5 public companion object Key : AbstractPolymorphicMessageKey<MessageSource, OfflineMessageSource>(MessageSource, { it.safeCast() }) diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/RichMessage.kt b/mirai-core-api/src/commonMain/kotlin/message/data/RichMessage.kt index 8496f2d4e..3c5b119a8 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/RichMessage.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/RichMessage.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:JvmName("MessageUtils") @@ -18,6 +18,7 @@ import kotlinx.serialization.Serializable import net.mamoe.mirai.message.code.CodableMessage import net.mamoe.mirai.message.code.internal.appendStringAsMiraiCode import net.mamoe.mirai.utils.MiraiExperimentalApi +import net.mamoe.mirai.utils.NotStableForInheritance import net.mamoe.mirai.utils.safeCast import kotlin.annotation.AnnotationTarget.* @@ -33,6 +34,7 @@ import kotlin.annotation.AnnotationTarget.* */ // not using sealed class for customized implementations // using polymorphic serializer from Message.Serializer +@NotStableForInheritance public interface RichMessage : MessageContent, ConstrainSingle { override val key: MessageKey<RichMessage> get() = Key @@ -164,6 +166,7 @@ public class SimpleServiceMessage( * @see LightApp 小程序类型消息 * @see SimpleServiceMessage */ +@NotStableForInheritance public interface ServiceMessage : RichMessage, CodableMessage { public companion object Key : AbstractPolymorphicMessageKey<RichMessage, ServiceMessage>(RichMessage, { it.safeCast() }) diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/UnsupportedMessage.kt b/mirai-core-api/src/commonMain/kotlin/message/data/UnsupportedMessage.kt index 11f63c0b0..f5ee48b6a 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/UnsupportedMessage.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/UnsupportedMessage.kt @@ -19,10 +19,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import net.mamoe.mirai.IMirai import net.mamoe.mirai.Mirai -import net.mamoe.mirai.utils.chunkedHexToBytes -import net.mamoe.mirai.utils.copy -import net.mamoe.mirai.utils.map -import net.mamoe.mirai.utils.toUHexString +import net.mamoe.mirai.utils.* /** * mirai 尚未支持的消息类型. @@ -32,6 +29,7 @@ import net.mamoe.mirai.utils.toUHexString */ @SerialName(UnsupportedMessage.SERIAL_NAME) @Serializable(UnsupportedMessage.Serializer::class) +@NotStableForInheritance public interface UnsupportedMessage : MessageContent { override fun contentToString(): String = "[不支持的消息#${struct.contentHashCode()}]" // to produce 'stable' and reliable text diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/Voice.kt b/mirai-core-api/src/commonMain/kotlin/message/data/Voice.kt index 563e5bcf8..063fdc561 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/Voice.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/Voice.kt @@ -26,6 +26,7 @@ import net.mamoe.mirai.utils.ExternalResource.Companion.uploadAsVoice */ @Serializable @MiraiExperimentalApi +@NotStableForInheritance public abstract class PttMessage : MessageContent { public companion object Key : diff --git a/mirai-core-api/src/commonMain/kotlin/utils/Annotations.kt b/mirai-core-api/src/commonMain/kotlin/utils/Annotations.kt index 5187ad6ca..f9e1751f1 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/Annotations.kt +++ b/mirai-core-api/src/commonMain/kotlin/utils/Annotations.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ package net.mamoe.mirai.utils @@ -53,6 +53,20 @@ public annotation class MiraiExperimentalApi( public val message: String = "" ) +/** + * 标记一个定义在使用上是稳定的 (如果没有特殊说明), 但只应该由 mirai 内部实现. + * + * 用户自行实现将可能造成对未来版本的不兼容, 因为新的抽象函数或属性会在未经警告的前提下添加. 自行实现还可能因 mirai 内部实现有部分硬编码成分而不兼容. + * + * @since 2.7 + */ +@Retention(AnnotationRetention.BINARY) +@Target(CLASS, PROPERTY, FUNCTION) +@MustBeDocumented +public annotation class NotStableForInheritance( + public val message: String = "This declaration is not stable for inheritance." +) + /** * 标记一个正计划在 [version] 版本时删除 (对外隐藏) 的 API. */ diff --git a/mirai-core-api/src/commonMain/kotlin/utils/RemoteFile.kt b/mirai-core-api/src/commonMain/kotlin/utils/RemoteFile.kt index 7c628d216..2c876d760 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/RemoteFile.kt +++ b/mirai-core-api/src/commonMain/kotlin/utils/RemoteFile.kt @@ -1,10 +1,10 @@ /* * Copyright 2019-2021 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. + * 此源代码的使用受 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 + * https://github.com/mamoe/mirai/blob/dev/LICENSE */ @file:Suppress("unused") @@ -97,6 +97,7 @@ import java.io.File * @see FileSupported * @since 2.5 */ +@NotStableForInheritance public interface RemoteFile { /** * 文件名或目录名.