mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-05 07:30:09 +08:00
QQA Debugging update
This commit is contained in:
parent
9ff1ff604c
commit
b1451f664c
@ -203,18 +203,19 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
|
|||||||
println("subCommand=$subCommand")
|
println("subCommand=$subCommand")
|
||||||
val type = readByte()
|
val type = readByte()
|
||||||
println("type=$type")
|
println("type=$type")
|
||||||
|
|
||||||
|
debugDiscardExact(2)
|
||||||
|
val tlvMap: Map<Int, ByteArray> = this.readTLVMap()
|
||||||
return when (type.toInt()) {
|
return when (type.toInt()) {
|
||||||
0 -> onLoginSuccess(bot)
|
0 -> onLoginSuccess(tlvMap, bot)
|
||||||
1, 15 -> onErrorMessage()
|
1, 15 -> onErrorMessage(tlvMap)
|
||||||
2 -> onSolveLoginCaptcha(bot)
|
2 -> onSolveLoginCaptcha(tlvMap, bot)
|
||||||
else -> error("unknown login result type: $type")
|
else -> error("unknown login result type: $type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ByteReadPacket.onErrorMessage(): LoginPacketResponse.Error {
|
private fun ByteReadPacket.onErrorMessage(tlvMap: Map<Int, ByteArray>): LoginPacketResponse.Error {
|
||||||
discardExact(2)
|
return tlvMap[0x146]?.toReadPacket()?.run {
|
||||||
val tlvMap = readTLVMap()
|
|
||||||
tlvMap[0x146]?.toReadPacket()?.run {
|
|
||||||
readShort() // ver
|
readShort() // ver
|
||||||
readShort() // code
|
readShort() // code
|
||||||
|
|
||||||
@ -222,40 +223,37 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
|
|||||||
val message = readUShortLVString()
|
val message = readUShortLVString()
|
||||||
val errorInfo = readUShortLVString()
|
val errorInfo = readUShortLVString()
|
||||||
|
|
||||||
return LoginPacketResponse.Error(title, message, errorInfo)
|
LoginPacketResponse.Error(title, message, errorInfo)
|
||||||
} ?: error("Cannot find error message")
|
} ?: error("Cannot find error message")
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseExperimental(MiraiDebugAPI::class)
|
@UseExperimental(MiraiDebugAPI::class)
|
||||||
suspend fun ByteReadPacket.onSolveLoginCaptcha(bot: QQAndroidBot): LoginPacketResponse.Captcha = this.debugPrint("login验证码解析").run {
|
suspend fun ByteReadPacket.onSolveLoginCaptcha(tlvMap: Map<Int, ByteArray>, bot: QQAndroidBot): LoginPacketResponse.Captcha =
|
||||||
val client = bot.client
|
this.debugPrint("login验证码解析").run {
|
||||||
debugDiscardExact(2)
|
val client = bot.client
|
||||||
val tlvMap: Map<Int, ByteArray> = this.readTLVMap()
|
// val ret = tlvMap[0x104]?.let { println(it.toUHexString()) }
|
||||||
// val ret = tlvMap[0x104]?.let { println(it.toUHexString()) }
|
println()
|
||||||
println()
|
val question = tlvMap[0x165] ?: error("CAPTCHA QUESTION UNKNOWN")
|
||||||
val question = tlvMap[0x165] ?: error("CAPTCHA QUESTION UNKNOWN")
|
when (question[18].toUHexString()) {
|
||||||
when (question[18].toUHexString()) {
|
"36" -> {
|
||||||
"36" -> {
|
//图片验证
|
||||||
//图片验证
|
debugPrint("是一个图片验证码")
|
||||||
debugPrint("是一个图片验证码")
|
val imageData = tlvMap[0x165]
|
||||||
val imageData = tlvMap[0x165]
|
bot.configuration.captchaSolver.invoke(
|
||||||
bot.configuration.captchaSolver.invoke(
|
bot,
|
||||||
bot,
|
(tlvMap[0x165] ?: error("Captcha Image Data Not Found")).toIoBuffer()
|
||||||
(tlvMap[0x165] ?: error("Captcha Image Data Not Found")).toIoBuffer()
|
)
|
||||||
)
|
}
|
||||||
}
|
else -> {
|
||||||
else -> {
|
error("UNKNOWN CAPTCHA QUESTION: $question")
|
||||||
error("UNKNOWN CAPTCHA QUESTION: $question")
|
}
|
||||||
}
|
}
|
||||||
|
return TODO()
|
||||||
}
|
}
|
||||||
return TODO()
|
|
||||||
}
|
|
||||||
|
|
||||||
@UseExperimental(MiraiDebugAPI::class)
|
@UseExperimental(MiraiDebugAPI::class)
|
||||||
private fun ByteReadPacket.onLoginSuccess(bot: QQAndroidBot): LoginPacketResponse.Success {
|
private fun ByteReadPacket.onLoginSuccess(tlvMap: Map<Int, ByteArray>, bot: QQAndroidBot): LoginPacketResponse.Success {
|
||||||
val client = bot.client
|
val client = bot.client
|
||||||
debugDiscardExact(2)
|
|
||||||
val tlvMap: Map<Int, ByteArray> = this.readTLVMap()
|
|
||||||
println("TLV KEYS: " + tlvMap.keys.joinToString { it.contentToString() })
|
println("TLV KEYS: " + tlvMap.keys.joinToString { it.contentToString() })
|
||||||
|
|
||||||
tlvMap[0x150]?.let { client.analysisTlv150(it) }
|
tlvMap[0x150]?.let { client.analysisTlv150(it) }
|
||||||
|
Loading…
Reference in New Issue
Block a user