mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-24 20:43:33 +08:00
Annotate BotAccount.id with @RawAccountIdUse
This commit is contained in:
parent
259d492f21
commit
f3ec99e560
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid
mirai-core/src/commonMain/kotlin/net.mamoe.mirai
@ -15,7 +15,8 @@ import net.mamoe.mirai.utils.LockFreeLinkedList
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
internal expect class QQAndroidBot(
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
internal expect class QQAndroidBot constructor(
|
||||
context: Context,
|
||||
account: BotAccount,
|
||||
configuration: BotConfiguration
|
||||
|
@ -5,6 +5,7 @@ import kotlinx.atomicfu.atomic
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.toByteArray
|
||||
import net.mamoe.mirai.BotAccount
|
||||
import net.mamoe.mirai.RawAccountIdUse
|
||||
import net.mamoe.mirai.data.OnlineStatus
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketLogger
|
||||
@ -129,6 +130,7 @@ internal open class QQAndroidClient(
|
||||
*/
|
||||
val uin: Long get() = _uin
|
||||
|
||||
@UseExperimental(RawAccountIdUse::class)
|
||||
@Suppress("PropertyName")
|
||||
internal var _uin: Long = bot.account.id
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
package net.mamoe.mirai
|
||||
|
||||
import kotlinx.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.*
|
||||
|
||||
@ -12,17 +10,17 @@ data class BotAccount(
|
||||
/**
|
||||
* **注意**: 在 Android 协议, 总是使用 `QQAndroidClient.uin` 或 [Bot.uin], 而不要使用 [BotAccount.id]. 将来 [BotAccount.id] 可能会变为 [String]
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@RawAccountIdUse
|
||||
val id: Long,
|
||||
val passwordMd5: ByteArray // md5
|
||||
){
|
||||
) {
|
||||
constructor(id: Long, passwordPlainText: String) : this(id, md5(passwordPlainText.toByteArray()))
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记直接访问 [BotAccount.id], 而不是访问 [Bot.uin]. 这将可能会不兼容未来的 API 修改.
|
||||
* 标记直接访问 [BotAccount.id], 而不是访问 [Bot.uin]. 这可能会不兼容未来的 API 修改.
|
||||
*/
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
|
||||
@Experimental
|
||||
@Experimental(level = Experimental.Level.WARNING)
|
||||
annotation class RawAccountIdUse
|
@ -26,8 +26,8 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
|
||||
|
||||
@Suppress("CanBePrimaryConstructorProperty") // for logger
|
||||
final override val account: BotAccount = account
|
||||
override val uin: Long
|
||||
get() = account.id
|
||||
@UseExperimental(RawAccountIdUse::class)
|
||||
override val uin: Long get() = account.id
|
||||
final override val logger: MiraiLogger by lazy { configuration.logger ?: DefaultLogger("Bot($uin)").also { configuration.logger = it } }
|
||||
|
||||
init {
|
||||
|
Loading…
Reference in New Issue
Block a user