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
c695f2cd
Commit
c695f2cd
authored
Apr 18, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #240
parent
7f347fee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
40 deletions
+58
-40
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
...n/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
+29
-21
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt
...ain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt
+29
-19
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
View file @
c695f2cd
...
@@ -48,11 +48,8 @@ import net.mamoe.mirai.qqandroid.network.highway.HighwayHelper
...
@@ -48,11 +48,8 @@ import net.mamoe.mirai.qqandroid.network.highway.HighwayHelper
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.LongMsg
import
net.mamoe.mirai.qqandroid.network.protocol.data.proto.LongMsg
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.*
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.*
import
net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList
import
net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList
import
net.mamoe.mirai.qqandroid.utils.MiraiPlatformUtils
import
net.mamoe.mirai.qqandroid.utils.*
import
net.mamoe.mirai.qqandroid.utils.encodeToString
import
net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray
import
net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray
import
net.mamoe.mirai.qqandroid.utils.toIpV4AddressString
import
net.mamoe.mirai.qqandroid.utils.toReadPacket
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.*
import
kotlin.collections.asSequence
import
kotlin.collections.asSequence
import
kotlin.contracts.ExperimentalContracts
import
kotlin.contracts.ExperimentalContracts
...
@@ -604,28 +601,39 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -604,28 +601,39 @@ internal abstract class QQAndroidBotBase constructor(
)
)
).
toByteArray
(
LongMsg
.
ReqBody
.
serializer
())
).
toByteArray
(
LongMsg
.
ReqBody
.
serializer
())
var
exception
:
Throwable
?
=
null
val
success
=
response
.
proto
.
uint32UpIp
.
zip
(
response
.
proto
.
uint32UpPort
).
any
{
(
ip
,
port
)
->
val
success
=
response
.
proto
.
uint32UpIp
.
zip
(
response
.
proto
.
uint32UpPort
).
any
{
(
ip
,
port
)
->
withTimeoutOrNull
((
body
.
size
*
1000L
/
1024
/
10
).
coerceAtLeast
(
5000L
))
{
kotlin
.
runCatching
{
network
.
logger
.
verbose
{
"[Highway] Uploading group long message#$sequenceId to ${ip.toIpV4AddressString()}:$port: size=${body.size}"
}
withTimeoutOrNull
((
body
.
size
*
1000L
/
1024
/
10
).
coerceAtLeast
(
5000L
))
{
HighwayHelper
.
uploadImage
(
network
.
logger
.
verbose
{
"[Highway] Uploading group long message#$sequenceId to ${ip.toIpV4AddressString()}:$port: size=${body.size}"
}
client
,
HighwayHelper
.
uploadImage
(
serverIp
=
ip
.
toIpV4AddressString
(),
client
,
serverPort
=
port
,
serverIp
=
ip
.
toIpV4AddressString
(),
ticket
=
response
.
proto
.
msgSig
,
// 104
serverPort
=
port
,
imageInput
=
body
.
toReadPacket
(),
ticket
=
response
.
proto
.
msgSig
,
// 104
inputSize
=
body
.
size
,
imageInput
=
body
.
toReadPacket
(),
fileMd5
=
MiraiPlatformUtils
.
md5
(
body
),
inputSize
=
body
.
size
,
commandId
=
27
// long msg
fileMd5
=
MiraiPlatformUtils
.
md5
(
body
),
)
commandId
=
27
// long msg
network
.
logger
.
verbose
{
"[Highway] Uploading group long message#$sequenceId: succeed"
}
)
true
network
.
logger
.
verbose
{
"[Highway] Uploading group long message#$sequenceId: succeed"
}
}
?:
kotlin
.
run
{
true
network
.
logger
.
verbose
{
"[Highway] Uploading group long message: timeout, retrying next server"
}
}
?:
kotlin
.
run
{
network
.
logger
.
verbose
{
"[Highway] Uploading group long message: timeout, retrying next server"
}
false
}
}.
getOrElse
{
exception
?.
addSuppressedMirai
(
it
)
exception
=
it
false
false
}
}
}
}
check
(
success
)
{
"cannot upload group image, failed on all servers."
}
if
(!
success
)
{
throw
IllegalStateException
(
"cannot upload group long message, failed on all servers."
,
exception
)
}
}
}
}
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt
View file @
c695f2cd
...
@@ -33,6 +33,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.TroopManagement
...
@@ -33,6 +33,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.TroopManagement
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image.ImgStore
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image.ImgStore
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvc
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvc
import
net.mamoe.mirai.qqandroid.network.protocol.packet.list.ProfileService
import
net.mamoe.mirai.qqandroid.network.protocol.packet.list.ProfileService
import
net.mamoe.mirai.qqandroid.utils.addSuppressedMirai
import
net.mamoe.mirai.qqandroid.utils.estimateLength
import
net.mamoe.mirai.qqandroid.utils.estimateLength
import
net.mamoe.mirai.qqandroid.utils.toIpV4AddressString
import
net.mamoe.mirai.qqandroid.utils.toIpV4AddressString
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.*
...
@@ -393,31 +394,40 @@ internal class GroupImpl(
...
@@ -393,31 +394,40 @@ internal class GroupImpl(
}
}
is
ImgStore
.
GroupPicUp
.
Response
.
RequireUpload
->
{
is
ImgStore
.
GroupPicUp
.
Response
.
RequireUpload
->
{
// 每 10KB 等 1 秒, 最少等待 5 秒
// 每 10KB 等 1 秒, 最少等待 5 秒
var
exception
:
Throwable
?
=
null
val
success
=
response
.
uploadIpList
.
zip
(
response
.
uploadPortList
).
any
{
(
ip
,
port
)
->
val
success
=
response
.
uploadIpList
.
zip
(
response
.
uploadPortList
).
any
{
(
ip
,
port
)
->
withTimeoutOrNull
((
image
.
inputSize
*
1000
/
1024
/
10
).
coerceAtLeast
(
5000
))
{
kotlin
.
runCatching
{
bot
.
network
.
logger
.
verbose
{
"[Highway] Uploading group image to ${ip.toIpV4AddressString()}:$port, size=${image.inputSize / 1024} KiB"
}
withTimeoutOrNull
((
image
.
inputSize
*
1000
/
1024
/
10
).
coerceAtLeast
(
5000
))
{
bot
.
network
.
logger
.
verbose
{
"[Highway] Uploading group image to ${ip.toIpV4AddressString()}:$port, size=${image.inputSize / 1024} KiB"
}
val
time
=
measureTime
{
HighwayHelper
.
uploadImage
(
val
time
=
measureTime
{
client
=
bot
.
client
,
HighwayHelper
.
uploadImage
(
serverIp
=
ip
.
toIpV4AddressString
(),
client
=
bot
.
client
,
serverPort
=
port
,
serverIp
=
ip
.
toIpV4AddressString
(),
imageInput
=
image
.
input
,
serverPort
=
port
,
inputSize
=
image
.
inputSize
.
toInt
(),
imageInput
=
image
.
input
,
fileMd5
=
image
.
md5
,
inputSize
=
image
.
inputSize
.
toInt
(),
ticket
=
response
.
uKey
,
fileMd5
=
image
.
md5
,
commandId
=
2
ticket
=
response
.
uKey
,
)
commandId
=
2
)
}
bot
.
network
.
logger
.
verbose
{
"[Highway] Uploading group image: succeed at ${(image.inputSize.toDouble() / 1024 / time.inSeconds).roundToInt()} KiB/s"
}
true
}
?:
kotlin
.
run
{
bot
.
network
.
logger
.
verbose
{
"[Highway] Uploading group image: timeout, retrying next server"
}
false
}
}
bot
.
network
.
logger
.
verbose
{
"[Highway] Uploading group image: succeed at ${(image.inputSize.toDouble() / 1024 / time.inSeconds).roundToInt()} KiB/s"
}
}.
getOrElse
{
true
exception
?.
addSuppressedMirai
(
it
)
}
?:
kotlin
.
run
{
exception
=
it
bot
.
network
.
logger
.
verbose
{
"[Highway] Uploading group image: timeout, retrying next server"
}
false
false
}
}
}
}
check
(
success
)
{
"cannot upload group image, failed on all servers."
}
if
(!
success
)
{
throw
IllegalStateException
(
"cannot upload group image, failed on all servers."
,
exception
)
}
val
resourceId
=
image
.
calculateImageResourceId
()
val
resourceId
=
image
.
calculateImageResourceId
()
// return NotOnlineImageFromFile(
// return NotOnlineImageFromFile(
...
...
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