Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
9ff1ff60
Commit
9ff1ff60
authored
Jan 24, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QQA Debugging update
parent
ddab66f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
18 deletions
+32
-18
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
...ai/qqandroid/network/protocol/packet/login/LoginPacket.kt
+32
-18
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
View file @
9ff1ff60
...
...
@@ -172,6 +172,12 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
sealed
class
LoginPacketResponse
:
Packet
{
object
Success
:
LoginPacketResponse
()
data class
Error
(
val
title
:
String
,
val
message
:
String
,
val
errorInfo
:
String
)
:
LoginPacketResponse
()
sealed
class
Captcha
:
LoginPacketResponse
()
{
class
Slider
(
val
data
:
IoBuffer
...
...
@@ -197,32 +203,38 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
println
(
"subCommand=$subCommand"
)
val
type
=
readByte
()
println
(
"type=$type"
)
when
(
type
.
toInt
())
{
0
->
{
onLoginSuccess
(
bot
)
}
1
->
{
throw
Exception
(
"Wrong Password"
)
}
2
->
{
onSolveLoginCaptcha
(
bot
)
}
}
if
(
type
.
toInt
()
!=
0
)
{
DebugLogger
.
debug
(
"unknown login result type: $type"
)
return
when
(
type
.
toInt
())
{
0
->
onLoginSuccess
(
bot
)
1
,
15
->
onErrorMessage
()
2
->
onSolveLoginCaptcha
(
bot
)
else
->
error
(
"unknown login result type: $type"
)
}
return
LoginPacketResponse
.
Success
}
private
fun
ByteReadPacket
.
onErrorMessage
():
LoginPacketResponse
.
Error
{
discardExact
(
2
)
val
tlvMap
=
readTLVMap
()
tlvMap
[
0
x146
]
?.
toReadPacket
()
?.
run
{
readShort
()
// ver
readShort
()
// code
val
title
=
readUShortLVString
()
val
message
=
readUShortLVString
()
val
errorInfo
=
readUShortLVString
()
return
LoginPacketResponse
.
Error
(
title
,
message
,
errorInfo
)
}
?:
error
(
"Cannot find error message"
)
}
@UseExperimental
(
MiraiDebugAPI
::
class
)
suspend
fun
ByteReadPacket
.
onSolveLoginCaptcha
(
bot
:
QQAndroidBot
)
=
this
.
debugPrint
(
"login验证码解析"
).
run
{
suspend
fun
ByteReadPacket
.
onSolveLoginCaptcha
(
bot
:
QQAndroidBot
)
:
LoginPacketResponse
.
Captcha
=
this
.
debugPrint
(
"login验证码解析"
).
run
{
val
client
=
bot
.
client
debugDiscardExact
(
2
)
val
tlvMap
:
Map
<
Int
,
ByteArray
>
=
this
.
readTLVMap
()
// val ret = tlvMap[0x104]?.let { println(it.toUHexString()) }
// val ret = tlvMap[0x104]?.let { println(it.toUHexString()) }
println
()
val
question
=
tlvMap
[
0
x165
]
?:
error
(
"CAPTCHA QUESTION UNKNOWN"
)
when
(
question
[
18
].
toUHexString
())
{
when
(
question
[
18
].
toUHexString
())
{
"36"
->
{
//图片验证
debugPrint
(
"是一个图片验证码"
)
...
...
@@ -236,10 +248,11 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
error
(
"UNKNOWN CAPTCHA QUESTION: $question"
)
}
}
return
TODO
()
}
@UseExperimental
(
MiraiDebugAPI
::
class
)
fun
ByteReadPacket
.
onLoginSuccess
(
bot
:
QQAndroidBot
)
=
this
.
debugPrint
(
"login成功解析"
).
run
{
private
fun
ByteReadPacket
.
onLoginSuccess
(
bot
:
QQAndroidBot
):
LoginPacketResponse
.
Success
{
val
client
=
bot
.
client
debugDiscardExact
(
2
)
val
tlvMap
:
Map
<
Int
,
ByteArray
>
=
this
.
readTLVMap
()
...
...
@@ -446,6 +459,7 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
}
}
return
LoginPacketResponse
.
Success
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment