From 7810127f7f1a4c1948448b735a23f276e3bc8fb2 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 24 Jan 2020 17:57:13 +0800 Subject: [PATCH] QQA Debugging update --- build.gradle | 1 + .../protocol/packet/login/LoginPacket.kt | 43 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build.gradle b/build.gradle index e226a72ca..08d1243f2 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ buildscript { jcenter() mavenCentral() google() + maven { url 'https://dl.bintray.com/kotlin/kotlin-dev/'} } dependencies { diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt index da18f24df..10ffaaec1 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt @@ -214,7 +214,7 @@ internal object LoginPacket : PacketFactory("wt } } - private fun ByteReadPacket.onErrorMessage(tlvMap: Map): LoginPacketResponse.Error { + private fun onErrorMessage(tlvMap: Map): LoginPacketResponse.Error { return tlvMap[0x146]?.toReadPacket()?.run { readShort() // ver readShort() // code @@ -228,31 +228,30 @@ internal object LoginPacket : PacketFactory("wt } @UseExperimental(MiraiDebugAPI::class) - suspend fun ByteReadPacket.onSolveLoginCaptcha(tlvMap: Map, bot: QQAndroidBot): LoginPacketResponse.Captcha = - this.debugPrint("login验证码解析").run { - val client = bot.client - // val ret = tlvMap[0x104]?.let { println(it.toUHexString()) } - println() - val question = tlvMap[0x165] ?: error("CAPTCHA QUESTION UNKNOWN") - when (question[18].toUHexString()) { - "36" -> { - //图片验证 - debugPrint("是一个图片验证码") - val imageData = tlvMap[0x165] - bot.configuration.captchaSolver.invoke( - bot, - (tlvMap[0x165] ?: error("Captcha Image Data Not Found")).toIoBuffer() - ) - } - else -> { - error("UNKNOWN CAPTCHA QUESTION: $question") - } + suspend fun onSolveLoginCaptcha(tlvMap: Map, bot: QQAndroidBot): LoginPacketResponse.Captcha { + val client = bot.client + // val ret = tlvMap[0x104]?.let { println(it.toUHexString()) } + println() + val question = tlvMap[0x165] ?: error("CAPTCHA QUESTION UNKNOWN") + when (question[18].toUHexString()) { + "36" -> { + //图片验证 + DebugLogger.debug("是一个图片验证码") + val imageData = tlvMap[0x165] + bot.configuration.captchaSolver.invoke( + bot, + (tlvMap[0x165] ?: error("Captcha Image Data Not Found")).toIoBuffer() + ) + } + else -> { + error("UNKNOWN CAPTCHA QUESTION: $question") } - return TODO() } + return TODO() + } @UseExperimental(MiraiDebugAPI::class) - private fun ByteReadPacket.onLoginSuccess(tlvMap: Map, bot: QQAndroidBot): LoginPacketResponse.Success { + private fun onLoginSuccess(tlvMap: Map, bot: QQAndroidBot): LoginPacketResponse.Success { val client = bot.client println("TLV KEYS: " + tlvMap.keys.joinToString { it.contentToString() })