mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-08 17:16:34 +08:00
Deprecate bot.qqAccount
and bot.account.id
for literal account support
This commit is contained in:
parent
748581b14f
commit
ff2f0b5ae3
@ -35,8 +35,14 @@ abstract class Bot : CoroutineScope {
|
||||
/**
|
||||
* 账号信息
|
||||
*/
|
||||
@MiraiInternalAPI
|
||||
abstract val account: BotAccount
|
||||
|
||||
/**
|
||||
* QQ 号码. 实际类型为 uint
|
||||
*/
|
||||
abstract val uin: Long
|
||||
|
||||
/**
|
||||
* 日志记录器
|
||||
*/
|
||||
|
@ -3,11 +3,26 @@
|
||||
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.*
|
||||
|
||||
data class BotAccount(
|
||||
/**
|
||||
* **注意**: 在 Android 协议, 总是使用 `QQAndroidClient.uin`, 而不要使用 [BotAccount.id]. 将来 [BotAccount.id] 可能会变为 [String]
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
val id: Long,
|
||||
val passwordMd5: ByteArray // md5
|
||||
){
|
||||
constructor(id: Long, passwordPlainText: String) : this(id, md5(passwordPlainText.toByteArray()))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记直接访问 [BotAccount.id], 而不是访问 [Bot.uin]
|
||||
*/
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
|
||||
@Experimental
|
||||
annotation class RawAccountIdUse
|
@ -23,4 +23,6 @@ suspend inline fun Bot.alsoLogin(): Bot = also { login() }
|
||||
/**
|
||||
* 取得机器人的 QQ 号
|
||||
*/
|
||||
inline val Bot.qqAccount: Long get() = this.account.id
|
||||
@Deprecated(message = "Use this.uin instead", replaceWith = ReplaceWith("this.uin"), level = DeprecationLevel.WARNING)
|
||||
inline val Bot.qqAccount: Long
|
||||
get() = this.uin
|
@ -129,11 +129,11 @@ internal fun IoBuffer.parseMessageImage0x03(): Image {
|
||||
// return if (tlv.containsKey(0x0Au)) {
|
||||
return Image(
|
||||
ImageId0x03(
|
||||
String(tlv[0x02u]!!).adjustImageId(),
|
||||
String(tlv[0x02]!!).adjustImageId(),
|
||||
// tlv[0x0Au],
|
||||
uniqueId = tlv[0x04u]!!.read { readUInt() },
|
||||
height = tlv[0x16u]!!.toUInt().toInt(),
|
||||
width = tlv[0x15u]!!.toUInt().toInt()
|
||||
uniqueId = tlv[0x04]!!.read { readUInt() },
|
||||
height = tlv[0x16]!!.toUInt().toInt(),
|
||||
width = tlv[0x15]!!.toUInt().toInt()
|
||||
)//.also { debugPrintln("ImageId: $it") }
|
||||
)
|
||||
//} else {
|
||||
|
Loading…
Reference in New Issue
Block a user