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
b1451f66
Commit
b1451f66
authored
Jan 24, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QQA Debugging update
parent
9ff1ff60
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
32 deletions
+30
-32
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
...ai/qqandroid/network/protocol/packet/login/LoginPacket.kt
+30
-32
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
View file @
b1451f66
...
...
@@ -203,18 +203,19 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
println
(
"subCommand=$subCommand"
)
val
type
=
readByte
()
println
(
"type=$type"
)
debugDiscardExact
(
2
)
val
tlvMap
:
Map
<
Int
,
ByteArray
>
=
this
.
readTLVMap
()
return
when
(
type
.
toInt
())
{
0
->
onLoginSuccess
(
bot
)
1
,
15
->
onErrorMessage
()
2
->
onSolveLoginCaptcha
(
bot
)
0
->
onLoginSuccess
(
tlvMap
,
bot
)
1
,
15
->
onErrorMessage
(
tlvMap
)
2
->
onSolveLoginCaptcha
(
tlvMap
,
bot
)
else
->
error
(
"unknown login result type: $type"
)
}
}
private
fun
ByteReadPacket
.
onErrorMessage
():
LoginPacketResponse
.
Error
{
discardExact
(
2
)
val
tlvMap
=
readTLVMap
()
tlvMap
[
0
x146
]
?.
toReadPacket
()
?.
run
{
private
fun
ByteReadPacket
.
onErrorMessage
(
tlvMap
:
Map
<
Int
,
ByteArray
>):
LoginPacketResponse
.
Error
{
return
tlvMap
[
0
x146
]
?.
toReadPacket
()
?.
run
{
readShort
()
// ver
readShort
()
// code
...
...
@@ -222,40 +223,37 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
val
message
=
readUShortLVString
()
val
errorInfo
=
readUShortLVString
()
return
LoginPacketResponse
.
Error
(
title
,
message
,
errorInfo
)
LoginPacketResponse
.
Error
(
title
,
message
,
errorInfo
)
}
?:
error
(
"Cannot find error message"
)
}
@UseExperimental
(
MiraiDebugAPI
::
class
)
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()) }
println
(
)
val
question
=
tlvMap
[
0
x165
]
?:
error
(
"CAPTCHA QUESTION UNKNOWN"
)
when
(
question
[
18
].
toUHexString
())
{
"36"
->
{
//图片验证
debugPrint
(
"是一个图片验证码"
)
val
imageData
=
tlvMap
[
0
x165
]
bot
.
configuration
.
captchaSolver
.
invoke
(
bot
,
(
tlvMap
[
0
x165
]
?:
error
(
"Captcha Image Data Not Found"
)).
toIoBuffer
(
)
)
}
else
->
{
error
(
"UNKNOWN CAPTCHA QUESTION: $question"
)
suspend
fun
ByteReadPacket
.
onSolveLoginCaptcha
(
tlvMap
:
Map
<
Int
,
ByteArray
>,
bot
:
QQAndroidBot
):
LoginPacketResponse
.
Captcha
=
this
.
debugPrint
(
"login验证码解析"
).
run
{
val
client
=
bot
.
client
// val ret = tlvMap[0x104]?.let { println(it.toUHexString()) }
println
()
val
question
=
tlvMap
[
0
x165
]
?:
error
(
"CAPTCHA QUESTION UNKNOWN"
)
when
(
question
[
18
].
toUHexString
())
{
"36"
->
{
//图片验证
debugPrint
(
"是一个图片验证码"
)
val
imageData
=
tlvMap
[
0
x165
]
bot
.
configuration
.
captchaSolver
.
invoke
(
bot
,
(
tlvMap
[
0
x165
]
?:
error
(
"Captcha Image Data Not Found"
)).
toIoBuffer
()
)
}
else
->
{
error
(
"UNKNOWN CAPTCHA QUESTION: $question"
)
}
}
return
TODO
()
}
return
TODO
()
}
@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
debugDiscardExact
(
2
)
val
tlvMap
:
Map
<
Int
,
ByteArray
>
=
this
.
readTLVMap
()
println
(
"TLV KEYS: "
+
tlvMap
.
keys
.
joinToString
{
it
.
contentToString
()
})
tlvMap
[
0
x150
]
?.
let
{
client
.
analysisTlv150
(
it
)
}
...
...
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