Commit f3ec99e5 authored by Him188's avatar Him188

Annotate BotAccount.id with @RawAccountIdUse

parent 259d492f
...@@ -15,7 +15,8 @@ import net.mamoe.mirai.utils.LockFreeLinkedList ...@@ -15,7 +15,8 @@ import net.mamoe.mirai.utils.LockFreeLinkedList
import net.mamoe.mirai.utils.MiraiInternalAPI import net.mamoe.mirai.utils.MiraiInternalAPI
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
internal expect class QQAndroidBot( @UseExperimental(MiraiInternalAPI::class)
internal expect class QQAndroidBot constructor(
context: Context, context: Context,
account: BotAccount, account: BotAccount,
configuration: BotConfiguration configuration: BotConfiguration
......
...@@ -5,6 +5,7 @@ import kotlinx.atomicfu.atomic ...@@ -5,6 +5,7 @@ import kotlinx.atomicfu.atomic
import kotlinx.io.core.ByteReadPacket import kotlinx.io.core.ByteReadPacket
import kotlinx.io.core.toByteArray import kotlinx.io.core.toByteArray
import net.mamoe.mirai.BotAccount import net.mamoe.mirai.BotAccount
import net.mamoe.mirai.RawAccountIdUse
import net.mamoe.mirai.data.OnlineStatus import net.mamoe.mirai.data.OnlineStatus
import net.mamoe.mirai.qqandroid.QQAndroidBot import net.mamoe.mirai.qqandroid.QQAndroidBot
import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketLogger import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketLogger
...@@ -129,6 +130,7 @@ internal open class QQAndroidClient( ...@@ -129,6 +130,7 @@ internal open class QQAndroidClient(
*/ */
val uin: Long get() = _uin val uin: Long get() = _uin
@UseExperimental(RawAccountIdUse::class)
@Suppress("PropertyName") @Suppress("PropertyName")
internal var _uin: Long = bot.account.id internal var _uin: Long = bot.account.id
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
package net.mamoe.mirai package net.mamoe.mirai
import kotlinx.io.core.toByteArray import kotlinx.io.core.toByteArray
import net.mamoe.mirai.utils.MiraiExperimentalAPI
import net.mamoe.mirai.utils.MiraiInternalAPI
import net.mamoe.mirai.utils.md5 import net.mamoe.mirai.utils.md5
import kotlin.annotation.AnnotationTarget.* import kotlin.annotation.AnnotationTarget.*
...@@ -12,17 +10,17 @@ data class BotAccount( ...@@ -12,17 +10,17 @@ data class BotAccount(
/** /**
* **注意**: 在 Android 协议, 总是使用 `QQAndroidClient.uin` 或 [Bot.uin], 而不要使用 [BotAccount.id]. 将来 [BotAccount.id] 可能会变为 [String] * **注意**: 在 Android 协议, 总是使用 `QQAndroidClient.uin` 或 [Bot.uin], 而不要使用 [BotAccount.id]. 将来 [BotAccount.id] 可能会变为 [String]
*/ */
@MiraiExperimentalAPI @RawAccountIdUse
val id: Long, val id: Long,
val passwordMd5: ByteArray // md5 val passwordMd5: ByteArray // md5
){ ) {
constructor(id: Long, passwordPlainText: String) : this(id, md5(passwordPlainText.toByteArray())) constructor(id: Long, passwordPlainText: String) : this(id, md5(passwordPlainText.toByteArray()))
} }
/** /**
* 标记直接访问 [BotAccount.id], 而不是访问 [Bot.uin]. 这可能会不兼容未来的 API 修改. * 标记直接访问 [BotAccount.id], 而不是访问 [Bot.uin]. 这可能会不兼容未来的 API 修改.
*/ */
@Retention(AnnotationRetention.SOURCE) @Retention(AnnotationRetention.SOURCE)
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR) @Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
@Experimental @Experimental(level = Experimental.Level.WARNING)
annotation class RawAccountIdUse annotation class RawAccountIdUse
\ No newline at end of file
...@@ -26,8 +26,8 @@ abstract class BotImpl<N : BotNetworkHandler> constructor( ...@@ -26,8 +26,8 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
@Suppress("CanBePrimaryConstructorProperty") // for logger @Suppress("CanBePrimaryConstructorProperty") // for logger
final override val account: BotAccount = account final override val account: BotAccount = account
override val uin: Long @UseExperimental(RawAccountIdUse::class)
get() = account.id override val uin: Long get() = account.id
final override val logger: MiraiLogger by lazy { configuration.logger ?: DefaultLogger("Bot($uin)").also { configuration.logger = it } } final override val logger: MiraiLogger by lazy { configuration.logger ?: DefaultLogger("Bot($uin)").also { configuration.logger = it } }
init { init {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment