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
009f11ea
Commit
009f11ea
authored
Feb 07, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
5e0048bf
a66c71dd
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
180 additions
and
69 deletions
+180
-69
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+12
-11
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/Codec.kt
...kotlin/net/mamoe/mirai/qqandroid/network/highway/Codec.kt
+0
-57
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/HighwayHelper.kt
...et/mamoe/mirai/qqandroid/network/highway/HighwayHelper.kt
+59
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/OnlinePushPack.kt
...rai/qqandroid/network/protocol/data/jce/OnlinePushPack.kt
+87
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt
...ndroid/network/protocol/packet/chat/receive/OnlinePush.kt
+22
-0
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
009f11ea
...
...
@@ -10,6 +10,7 @@ import net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.MessageChain
import
net.mamoe.mirai.message.data.NotOnlineImageFromFile
import
net.mamoe.mirai.qqandroid.network.highway.HighwayHelper
import
net.mamoe.mirai.qqandroid.network.highway.postImage
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.Cmd0x352
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.TroopManagement
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image.ImgStore
...
...
@@ -50,7 +51,6 @@ internal class QQImpl(bot: QQAndroidBot, override val coroutineContext: Coroutin
)
{
"send message failed"
}
}
}
override
suspend
fun
uploadImage
(
image
:
ExternalImage
):
Image
=
try
{
bot
.
network
.
run
{
val
response
=
LongConn
.
OffPicUp
(
...
...
@@ -78,16 +78,17 @@ internal class QQImpl(bot: QQAndroidBot, override val coroutineContext: Coroutin
resourceId
=
response
.
resourceId
)
is
LongConn
.
OffPicUp
.
Response
.
RequireUpload
->
{
HighwayHelper
.
uploadImage
(
client
=
bot
.
client
,
serverIp
=
response
.
serverIp
[
0
].
toIpV4AddressString
(),
serverPort
=
response
.
serverPort
[
0
],
imageInput
=
image
.
input
,
inputSize
=
image
.
inputSize
.
toInt
(),
md5
=
image
.
md5
,
uKey
=
response
.
uKey
,
commandId
=
1
)
Http
.
postImage
(
"0x6ff0070"
,
bot
.
uin
,
null
,
imageInput
=
image
.
input
,
inputSize
=
image
.
inputSize
,
uKeyHex
=
response
.
uKey
.
toUHexString
(
""
))
// HighwayHelper.uploadImage(
// client = bot.client,
// serverIp = response.serverIp[0].toIpV4AddressString(),
// serverPort = response.serverPort[0],
// imageInput = image.input,
// inputSize = image.inputSize.toInt(),
// md5 = image.md5,
// uKey = response.uKey,
// commandId = 1
// )
return
NotOnlineImageFromFile
(
filepath
=
response
.
resourceId
,
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/Codec.kt
View file @
009f11ea
package
net.mamoe.mirai.qqandroid.network.highway
import
io.ktor.client.HttpClient
import
io.ktor.client.request.post
import
io.ktor.http.ContentType
import
io.ktor.http.HttpStatusCode
import
io.ktor.http.URLProtocol
import
io.ktor.http.content.OutgoingContent
import
io.ktor.http.userAgent
import
kotlinx.coroutines.io.ByteWriteChannel
import
kotlinx.io.core.*
import
kotlinx.io.pool.useInstance
import
net.mamoe.mirai.qqandroid.io.serialization.toByteArray
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.CSDataHighwayHead
import
net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
import
net.mamoe.mirai.utils.io.ByteArrayPool
@Suppress
(
"SpellCheckingInspection"
)
internal
suspend
inline
fun
HttpClient
.
postImage
(
htcmd
:
String
,
uin
:
Long
,
groupcode
:
Long
?,
imageInput
:
Input
,
inputSize
:
Long
,
uKeyHex
:
String
):
Boolean
=
try
{
post
<
HttpStatusCode
>
{
url
{
protocol
=
URLProtocol
.
HTTP
host
=
"htdata2.qq.com"
path
(
"cgi-bin/httpconn"
)
parameters
[
"htcmd"
]
=
htcmd
parameters
[
"uin"
]
=
uin
.
toString
()
if
(
groupcode
!=
null
)
parameters
[
"groupcode"
]
=
groupcode
.
toString
()
parameters
[
"term"
]
=
"pc"
parameters
[
"ver"
]
=
"5603"
parameters
[
"filesize"
]
=
inputSize
.
toString
()
parameters
[
"range"
]
=
0
.
toString
()
parameters
[
"ukey"
]
=
uKeyHex
userAgent
(
"QQClient"
)
}
body
=
object
:
OutgoingContent
.
WriteChannelContent
()
{
override
val
contentType
:
ContentType
=
ContentType
.
Image
.
Any
override
val
contentLength
:
Long
=
inputSize
override
suspend
fun
writeTo
(
channel
:
ByteWriteChannel
)
{
ByteArrayPool
.
useInstance
{
buffer
:
ByteArray
->
var
size
:
Int
while
(
imageInput
.
readAvailable
(
buffer
).
also
{
size
=
it
}
!=
0
)
{
channel
.
writeFully
(
buffer
,
0
,
size
)
}
}
}
}
}
==
HttpStatusCode
.
OK
}
finally
{
imageInput
.
close
()
}
object
Highway
{
fun
RequestDataTrans
(
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/HighwayHelper.kt
View file @
009f11ea
package
net.mamoe.mirai.qqandroid.network.highway
import
io.ktor.client.HttpClient
import
io.ktor.client.request.post
import
io.ktor.http.ContentType
import
io.ktor.http.HttpStatusCode
import
io.ktor.http.URLProtocol
import
io.ktor.http.content.OutgoingContent
import
io.ktor.http.userAgent
import
kotlinx.coroutines.io.ByteWriteChannel
import
kotlinx.io.core.Input
import
kotlinx.io.core.readAvailable
import
kotlinx.io.core.use
import
kotlinx.io.pool.useInstance
import
net.mamoe.mirai.qqandroid.io.serialization.readProtoBuf
import
net.mamoe.mirai.qqandroid.network.QQAndroidClient
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.CSDataHighwayHead
import
net.mamoe.mirai.qqandroid.network.protocol.packet.withUse
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
net.mamoe.mirai.utils.io.ByteArrayPool
import
net.mamoe.mirai.utils.io.PlatformSocket
import
net.mamoe.mirai.utils.io.discardExact
@Suppress
(
"SpellCheckingInspection"
)
internal
suspend
inline
fun
HttpClient
.
postImage
(
htcmd
:
String
,
uin
:
Long
,
groupcode
:
Long
?,
imageInput
:
Input
,
inputSize
:
Long
,
uKeyHex
:
String
):
Boolean
=
try
{
post
<
HttpStatusCode
>
{
url
{
protocol
=
URLProtocol
.
HTTP
host
=
"htdata2.qq.com"
path
(
"cgi-bin/httpconn"
)
parameters
[
"htcmd"
]
=
htcmd
parameters
[
"uin"
]
=
uin
.
toString
()
if
(
groupcode
!=
null
)
parameters
[
"groupcode"
]
=
groupcode
.
toString
()
parameters
[
"term"
]
=
"pc"
parameters
[
"ver"
]
=
"5603"
parameters
[
"filesize"
]
=
inputSize
.
toString
()
parameters
[
"range"
]
=
0
.
toString
()
parameters
[
"ukey"
]
=
uKeyHex
userAgent
(
"QQClient"
)
}
body
=
object
:
OutgoingContent
.
WriteChannelContent
()
{
override
val
contentType
:
ContentType
=
ContentType
.
Image
.
Any
override
val
contentLength
:
Long
=
inputSize
override
suspend
fun
writeTo
(
channel
:
ByteWriteChannel
)
{
ByteArrayPool
.
useInstance
{
buffer
:
ByteArray
->
var
size
:
Int
while
(
imageInput
.
readAvailable
(
buffer
).
also
{
size
=
it
}
!=
0
)
{
channel
.
writeFully
(
buffer
,
0
,
size
)
}
}
}
}
}
==
HttpStatusCode
.
OK
}
finally
{
imageInput
.
close
()
}
@UseExperimental
(
MiraiInternalAPI
::
class
)
internal
object
HighwayHelper
{
suspend
fun
uploadImage
(
client
:
QQAndroidClient
,
serverIp
:
String
,
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/OnlinePushPack.kt
0 → 100644
View file @
009f11ea
package
net.mamoe.mirai.qqandroid.network.protocol.data.jce
import
kotlinx.serialization.SerialId
import
kotlinx.serialization.Serializable
import
net.mamoe.mirai.qqandroid.io.JceStruct
class
OnlinePushPack
{
@Serializable
internal
class
DelMsgInfo
(
@SerialId
(
0
)
val
fromUin
:
Long
,
@SerialId
(
1
)
val
uMsgTime
:
Long
,
@SerialId
(
2
)
val
shMsgSeq
:
Short
,
@SerialId
(
3
)
val
vMsgCookies
:
ByteArray
?
=
null
,
@SerialId
(
4
)
val
wCmd
:
Short
?
=
null
,
@SerialId
(
5
)
val
uMsgType
:
Long
?
=
null
,
@SerialId
(
6
)
val
uAppId
:
Long
?
=
null
,
@SerialId
(
7
)
val
sendTime
:
Long
?
=
null
,
@SerialId
(
8
)
val
ssoSeq
:
Int
?
=
null
,
@SerialId
(
9
)
val
ssoIp
:
Int
?
=
null
,
@SerialId
(
10
)
val
clientIp
:
Int
?
=
null
)
:
JceStruct
@Serializable
internal
class
DeviceInfo
(
@SerialId
(
0
)
val
netType
:
Byte
?
=
null
,
@SerialId
(
1
)
val
devType
:
String
?
=
""
,
@SerialId
(
2
)
val
oSVer
:
String
?
=
""
,
@SerialId
(
3
)
val
vendorName
:
String
?
=
""
,
@SerialId
(
4
)
val
vendorOSName
:
String
?
=
""
,
@SerialId
(
5
)
val
iOSIdfa
:
String
?
=
""
)
:
JceStruct
@Serializable
internal
class
Name
(
@SerialId
(
0
)
val
fromUin
:
Long
,
@SerialId
(
1
)
val
uMsgTime
:
Long
,
@SerialId
(
2
)
val
shMsgType
:
Short
,
@SerialId
(
3
)
val
shMsgSeq
:
Short
,
@SerialId
(
4
)
val
msg
:
String
=
""
,
@SerialId
(
5
)
val
uRealMsgTime
:
Int
?
=
null
,
@SerialId
(
6
)
val
vMsg
:
ByteArray
?
=
null
,
@SerialId
(
7
)
val
uAppShareID
:
Long
?
=
null
,
@SerialId
(
8
)
val
vMsgCookies
:
ByteArray
?
=
null
,
@SerialId
(
9
)
val
vAppShareCookie
:
ByteArray
?
=
null
,
@SerialId
(
10
)
val
msgUid
:
Long
?
=
null
,
@SerialId
(
11
)
val
lastChangeTime
:
Long
?
=
1L
,
@SerialId
(
12
)
val
vCPicInfo
:
List
<
CPicInfo
>?
=
null
,
@SerialId
(
13
)
val
stShareData
:
ShareData
?
=
null
,
@SerialId
(
14
)
val
fromInstId
:
Long
?
=
null
,
@SerialId
(
15
)
val
vRemarkOfSender
:
ByteArray
?
=
null
,
@SerialId
(
16
)
val
fromMobile
:
String
?
=
""
,
@SerialId
(
17
)
val
fromName
:
String
?
=
""
,
@SerialId
(
18
)
val
vNickName
:
List
<
String
>?
=
null
,
@SerialId
(
19
)
val
stC2CTmpMsgHead
:
TempMsgHead
?
=
null
)
:
JceStruct
@Serializable
internal
class
SvcReqPushMsg
(
@SerialId
(
0
)
val
uin
:
Long
,
@SerialId
(
1
)
val
uMsgTime
:
Long
,
@SerialId
(
2
)
val
vMsgInfos
:
List
<
MsgInfo
>,
@SerialId
(
3
)
val
svrip
:
Int
?
=
0
,
@SerialId
(
4
)
val
vSyncCookie
:
ByteArray
?
=
null
,
@SerialId
(
5
)
val
vUinPairMsg
:
List
<
UinPairMsg
>?
=
null
,
@SerialId
(
6
)
val
mPreviews
:
Map
<
String
,
ByteArray
>?
=
null
,
@SerialId
(
7
)
val
wUserActive
:
Int
?
=
null
,
@SerialId
(
12
)
val
wGeneralFlag
:
Int
?
=
null
)
:
JceStruct
@Serializable
internal
class
SvcRespPushMsg
(
@SerialId
(
0
)
val
uin
:
Long
,
@SerialId
(
1
)
val
vDelInfos
:
List
<
DelMsgInfo
>,
@SerialId
(
2
)
val
svrip
:
Int
,
@SerialId
(
3
)
val
pushToken
:
ByteArray
?
=
null
,
@SerialId
(
4
)
val
serviceType
:
Int
?
=
null
,
@SerialId
(
5
)
val
deviceInfo
:
DeviceInfo
?
=
null
)
:
JceStruct
@Serializable
internal
class
UinPairMsg
(
@SerialId
(
1
)
val
uLastReadTime
:
Long
?
=
null
,
@SerialId
(
2
)
val
peerUin
:
Long
?
=
null
,
@SerialId
(
3
)
val
uMsgCompleted
:
Long
?
=
null
,
@SerialId
(
4
)
val
vMsgInfos
:
List
<
MsgInfo
>?
=
null
)
:
JceStruct
}
\ No newline at end of file
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt
View file @
009f11ea
...
...
@@ -4,16 +4,21 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive
import
kotlinx.io.core.ByteReadPacket
import
net.mamoe.mirai.contact.MemberPermission
import
net.mamoe.mirai.data.NoPakcet
import
net.mamoe.mirai.data.Packet
import
net.mamoe.mirai.event.broadcast
import
net.mamoe.mirai.message.GroupMessage
import
net.mamoe.mirai.qqandroid.QQAndroidBot
import
net.mamoe.mirai.qqandroid.io.serialization.decodeUniPacket
import
net.mamoe.mirai.qqandroid.io.serialization.readProtoBuf
import
net.mamoe.mirai.qqandroid.network.protocol.data.jce.MsgInfo
import
net.mamoe.mirai.qqandroid.network.protocol.data.jce.OnlinePushPack
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.ImMsgBody
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.MsgOnlinePush
import
net.mamoe.mirai.qqandroid.network.protocol.packet.IncomingPacketFactory
import
net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import
net.mamoe.mirai.qqandroid.utils.toMessageChain
import
net.mamoe.mirai.utils.cryptor.contentToString
internal
inline
class
GroupMessageOrNull
(
val
delegate
:
GroupMessage
?)
:
Packet
{
override
fun
toString
():
String
{
...
...
@@ -70,4 +75,21 @@ internal class OnlinePush {
return
null
}
}
internal
object
ReqPush
:
IncomingPacketFactory
<
Packet
>(
"OnlinePush.ReqPush"
)
{
@UseExperimental
(
ExperimentalStdlibApi
::
class
)
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
,
sequenceId
:
Int
):
Packet
{
val
reqPushMsg
=
decodeUniPacket
(
OnlinePushPack
.
SvcReqPushMsg
.
serializer
(),
"req"
)
reqPushMsg
.
vMsgInfos
.
forEach
{
msgInfo
:
MsgInfo
->
}
println
(
reqPushMsg
.
contentToString
())
return
NoPakcet
}
override
suspend
fun
QQAndroidBot
.
handle
(
packet
:
Packet
,
sequenceId
:
Int
):
OutgoingPacket
?
{
return
null
}
}
}
\ No newline at end of file
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