Commit ff2f0b5a authored by Him188's avatar Him188

Deprecate `bot.qqAccount` and `bot.account.id` for literal account support

parent 748581b1
...@@ -35,8 +35,14 @@ abstract class Bot : CoroutineScope { ...@@ -35,8 +35,14 @@ abstract class Bot : CoroutineScope {
/** /**
* 账号信息 * 账号信息
*/ */
@MiraiInternalAPI
abstract val account: BotAccount abstract val account: BotAccount
/**
* QQ 号码. 实际类型为 uint
*/
abstract val uin: Long
/** /**
* 日志记录器 * 日志记录器
*/ */
......
...@@ -3,11 +3,26 @@ ...@@ -3,11 +3,26 @@
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.*
data class BotAccount( data class BotAccount(
/**
* **注意**: 在 Android 协议, 总是使用 `QQAndroidClient.uin`, 而不要使用 [BotAccount.id]. 将来 [BotAccount.id] 可能会变为 [String]
*/
@MiraiExperimentalAPI
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]
*/
@Retention(AnnotationRetention.SOURCE)
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
@Experimental
annotation class RawAccountIdUse
\ No newline at end of file
...@@ -23,4 +23,6 @@ suspend inline fun Bot.alsoLogin(): Bot = also { login() } ...@@ -23,4 +23,6 @@ suspend inline fun Bot.alsoLogin(): Bot = also { login() }
/** /**
* 取得机器人的 QQ 号 * 取得机器人的 QQ 号
*/ */
inline val Bot.qqAccount: Long get() = this.account.id @Deprecated(message = "Use this.uin instead", replaceWith = ReplaceWith("this.uin"), level = DeprecationLevel.WARNING)
\ No newline at end of file inline val Bot.qqAccount: Long
get() = this.uin
\ No newline at end of file
...@@ -129,11 +129,11 @@ internal fun IoBuffer.parseMessageImage0x03(): Image { ...@@ -129,11 +129,11 @@ internal fun IoBuffer.parseMessageImage0x03(): Image {
// return if (tlv.containsKey(0x0Au)) { // return if (tlv.containsKey(0x0Au)) {
return Image( return Image(
ImageId0x03( ImageId0x03(
String(tlv[0x02u]!!).adjustImageId(), String(tlv[0x02]!!).adjustImageId(),
// tlv[0x0Au], // tlv[0x0Au],
uniqueId = tlv[0x04u]!!.read { readUInt() }, uniqueId = tlv[0x04]!!.read { readUInt() },
height = tlv[0x16u]!!.toUInt().toInt(), height = tlv[0x16]!!.toUInt().toInt(),
width = tlv[0x15u]!!.toUInt().toInt() width = tlv[0x15]!!.toUInt().toInt()
)//.also { debugPrintln("ImageId: $it") } )//.also { debugPrintln("ImageId: $it") }
) )
//} else { //} else {
......
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