From e222465dedeab18b76c90b36964a36a9973f5c82 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sat, 7 Mar 2020 00:24:37 +0800 Subject: [PATCH] Make `account` internal --- .../net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt | 2 +- mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt | 6 ------ mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt | 6 ------ .../src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt | 3 +++ .../src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt | 4 +++- .../src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt | 9 +++++++++ mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt | 6 ------ 7 files changed, 16 insertions(+), 20 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt index 7d2801ffa..76df1763d 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt @@ -160,7 +160,7 @@ internal open class QQAndroidClient( @UseExperimental(RawAccountIdUse::class) @Suppress("PropertyName") - internal var _uin: Long = bot.account.id + internal var _uin: Long = bot.uin var t530: ByteArray? = null var t528: ByteArray? = null diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt index 48c629081..de70962a5 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt @@ -54,12 +54,6 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA */ actual abstract val context: Context - /** - * 账号信息 - */ - @MiraiInternalAPI - actual abstract val account: BotAccount - /** * QQ 号码. 实际类型为 uint */ 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 e8a25b56e..54bb1308e 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt @@ -70,12 +70,6 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor { */ abstract val context: Context - /** - * 账号信息 - */ - @MiraiInternalAPI - abstract val account: BotAccount - /** * QQ 号码. 实际类型为 uint */ diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt index fe0ff4b4d..b4c84333a 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt @@ -12,6 +12,7 @@ package net.mamoe.mirai import io.ktor.utils.io.core.toByteArray +import net.mamoe.mirai.utils.MiraiExperimentalAPI import net.mamoe.mirai.utils.MiraiInternalAPI import net.mamoe.mirai.utils.md5 import kotlin.annotation.AnnotationTarget.* @@ -23,6 +24,8 @@ data class BotAccount( */ @RawAccountIdUse val id: Long, + @MiraiExperimentalAPI + @MiraiInternalAPI val passwordMd5: ByteArray // md5 ) { constructor(id: Long, passwordPlainText: String) : this(id, md5(passwordPlainText.toByteArray())) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt index da87be75c..3ead4f73b 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt @@ -40,9 +40,11 @@ abstract class BotImpl constructor( ?: CoroutineExceptionHandler { _, e -> logger.error("An exception was thrown under a coroutine of Bot", e) }) override val context: Context by context.unsafeWeakRef() - @Suppress("CanBePrimaryConstructorProperty") // for logger + @UseExperimental(LowLevelAPI::class) + @Suppress("CanBePrimaryConstructorProperty", "OverridingDeprecatedMember") // for logger final override val account: BotAccount = account + @Suppress("DEPRECATION_ERROR") @UseExperimental(RawAccountIdUse::class) override val uin: Long get() = account.id diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt index 0940819a6..08387696a 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt @@ -17,6 +17,7 @@ import net.mamoe.mirai.data.GroupInfo import net.mamoe.mirai.data.MemberInfo import net.mamoe.mirai.message.data.MessageSource import net.mamoe.mirai.utils.MiraiExperimentalAPI +import net.mamoe.mirai.utils.MiraiInternalAPI import net.mamoe.mirai.utils.WeakRef /** @@ -37,6 +38,14 @@ annotation class LowLevelAPI @Suppress("FunctionName", "unused") @LowLevelAPI interface LowLevelBotAPIAccessor { + /** + * 账号信息 + */ + @Deprecated("将来会做修改", level = DeprecationLevel.ERROR) + @MiraiExperimentalAPI + @LowLevelAPI + @MiraiInternalAPI + abstract val account: BotAccount /** * 构造一个 [_lowLevelNewQQ] 对象. 它持有对 [Bot] 的弱引用([WeakRef]). diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt index 509ed8381..93c0ebd52 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt @@ -64,12 +64,6 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA */ actual abstract val context: Context - /** - * 账号信息 - */ - @MiraiInternalAPI - actual abstract val account: BotAccount - /** * QQ 号码. 实际类型为 uint */