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
bc57001e
Commit
bc57001e
authored
Oct 20, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Image uploading
parent
28b47f96
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
11 deletions
+11
-11
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt
....mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt
+5
-5
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/UploadFriendImage.kt
...oe.mirai/network/protocol/tim/packet/UploadFriendImage.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/UploadGroupImage.kt
...moe.mirai/network/protocol/tim/packet/UploadGroupImage.kt
+3
-3
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt
.../jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt
+2
-2
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt
View file @
bc57001e
...
...
@@ -182,6 +182,11 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) :
}
packet
.
use
{
val
name
=
packet
::
class
.
simpleName
if
(
name
!=
null
&&
!
name
.
endsWith
(
"Encrypted"
)
&&
!
name
.
endsWith
(
"Raw"
))
{
bot
.
logCyan
(
"Packet received: $packet"
)
}
//coz removeIf is not inline
handlersLock
.
withLock
{
temporaryPacketHandlers
.
removeIfInlined
{
...
...
@@ -189,11 +194,6 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) :
}
}
val
name
=
packet
::
class
.
simpleName
if
(
name
!=
null
&&
!
name
.
endsWith
(
"Encrypted"
)
&&
!
name
.
endsWith
(
"Raw"
))
{
bot
.
logCyan
(
"Packet received: $packet"
)
}
if
(
packet
is
ServerEventPacket
)
{
//no need to sync acknowledgement packets
NetworkScope
.
launch
{
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/UploadFriendImage.kt
View file @
bc57001e
...
...
@@ -16,7 +16,7 @@ import net.mamoe.mirai.utils.*
*/
suspend
fun
QQ
.
uploadImage
(
image
:
PlatformImage
):
ImageId
=
with
(
bot
.
network
.
session
)
{
//SubmitImageFilenamePacket(account, account, "sdiovaoidsa.png", sessionKey).sendAndExpect<ServerSubmitImageFilenameResponsePacket>().join()
DebugLogger
.
logPurple
(
"正在上传好友图片, md5=${image.md5.toUHexString()}"
)
return
FriendImageIdRequestPacket
(
account
,
sessionKey
,
account
,
image
).
sendAndExpect
<
FriendImageIdRequestPacket
.
Response
,
ImageId
>
{
if
(
it
.
uKey
!=
null
)
{
require
(
httpPostFriendImage
(
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/UploadGroupImage.kt
View file @
bc57001e
...
...
@@ -195,11 +195,11 @@ class GroupImageIdRequestPacket(
//if (readUByte() != UByte.MIN_VALUE) {
//服务器还没有
discardExact
(
remaining
-
128
)
uKey
=
readBytes
(
128
)
discardExact
(
remaining
-
128
-
14
)
uKey
=
readBytes
(
128
)
//} else {
// println("服务器已经有了这个图片")
//
println("后文 = ${readRemainingBytes().toUHexString()}")
//println("后文 = ${readRemainingBytes().toUHexString()}")
//}
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt
View file @
bc57001e
...
...
@@ -73,7 +73,7 @@ actual suspend fun httpPostFriendImage(
"&range="
+
"0"
+
"&uin="
+
botNumber
.
toLong
()).
openConnection
()
as
HttpURLConnection
conn
.
setRequestProperty
(
"User-Agent"
,
"QQClient"
)
conn
.
setRequestProperty
(
"Content-Length"
,
""
+
fileSize
)
conn
.
setRequestProperty
(
"Content-Length"
,
imageData
.
toString
()
)
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
)
conn
.
requestMethod
=
"POST"
conn
.
doOutput
=
true
...
...
@@ -98,7 +98,7 @@ actual suspend fun httpPostGroupImage(uKeyHex: String, fileSize: Long, imageData
"&term=pc"
+
"&ver=5603"
+
"&ukey="
+
uKeyHex
.
replace
(
" "
,
""
)).
openConnection
()
as
HttpURLConnection
conn
.
setRequestProperty
(
"Content-Length"
,
fileSize
.
toString
())
conn
.
setRequestProperty
(
"Content-Length"
,
imageData
.
remaining
.
toString
())
conn
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
)
conn
.
requestMethod
=
"POST"
conn
.
doOutput
=
true
...
...
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