mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 05:12:17 +00:00
Compare commits
2 Commits
93c49953cf
...
1d035fa378
Author | SHA1 | Date | |
---|---|---|---|
1d035fa378 | |||
7d0b60271e |
@ -12,6 +12,7 @@ import moe.fuqiuluo.qqinterface.servlet.ark.WeatherSvc
|
||||
import moe.fuqiuluo.qqinterface.servlet.msg.toJson
|
||||
import moe.fuqiuluo.qqinterface.servlet.msg.toSegments
|
||||
import moe.fuqiuluo.qqinterface.servlet.transfile.NtV2RichMediaSvc
|
||||
import moe.fuqiuluo.qqinterface.servlet.transfile.NtV2RichMediaSvc.fetchGroupResUploadTo
|
||||
import moe.fuqiuluo.shamrock.helper.*
|
||||
import moe.fuqiuluo.shamrock.helper.MessageHelper.messageArrayToRichText
|
||||
import moe.fuqiuluo.shamrock.helper.MessageHelper.obtainMessageTypeByDetailType
|
||||
@ -267,11 +268,11 @@ internal class ElemMaker {
|
||||
runCatching {
|
||||
fileInfo.uuid.toUInt()
|
||||
}.onFailure {
|
||||
NtV2RichMediaSvc.requestUploadNtPic(file, fileInfo.md5, fileInfo.sha, fileInfo.fileName, picWidth.toUInt(), picHeight.toUInt(), 5) {
|
||||
NtV2RichMediaSvc.requestUploadNtPic(file, fileInfo.md5, fileInfo.sha, fileInfo.fileName, picWidth.toUInt(), picHeight.toUInt(), 5, chatType) {
|
||||
when(chatType) {
|
||||
MsgConstant.KCHATTYPEGROUP -> {
|
||||
sceneType = 2u
|
||||
grp = GroupUserInfo(peerId.toULong())
|
||||
grp = GroupUserInfo(fetchGroupResUploadTo().toULong())
|
||||
}
|
||||
MsgConstant.KCHATTYPEC2C -> {
|
||||
sceneType = 1u
|
||||
|
@ -19,7 +19,6 @@ import kotlinx.coroutines.withTimeoutOrNull
|
||||
import moe.fuqiuluo.qqinterface.servlet.BaseSvc
|
||||
import moe.fuqiuluo.qqinterface.servlet.TicketSvc
|
||||
import moe.fuqiuluo.qqinterface.servlet.transfile.data.TryUpPicData
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
||||
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
||||
import moe.fuqiuluo.shamrock.tools.hex2ByteArray
|
||||
@ -62,7 +61,7 @@ import kotlin.time.Duration
|
||||
internal object NtV2RichMediaSvc: BaseSvc() {
|
||||
private val requestIdSeq = atomic(2L)
|
||||
|
||||
private fun fetchGroupResUploadTo(): String {
|
||||
fun fetchGroupResUploadTo(): String {
|
||||
return ShamrockConfig.getUpResGroup().ifEmpty { "100000000" }
|
||||
}
|
||||
|
||||
@ -405,13 +404,14 @@ internal object NtV2RichMediaSvc: BaseSvc() {
|
||||
width: UInt,
|
||||
height: UInt,
|
||||
retryCnt: Int,
|
||||
chatType: Int = MsgConstant.KCHATTYPEGROUP,
|
||||
sceneBuilder: suspend SceneInfo.() -> Unit
|
||||
): Result<UploadRsp> {
|
||||
return runCatching {
|
||||
requestUploadNtPic(file, md5, sha, name, width, height, sceneBuilder).getOrThrow()
|
||||
requestUploadNtPic(file, md5, sha, name, width, height, chatType, sceneBuilder).getOrThrow()
|
||||
}.onFailure {
|
||||
if (retryCnt > 0) {
|
||||
return requestUploadNtPic(file, md5, sha, name, width, height, retryCnt - 1, sceneBuilder)
|
||||
return requestUploadNtPic(file, md5, sha, name, width, height, retryCnt - 1, chatType, sceneBuilder)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -423,6 +423,7 @@ internal object NtV2RichMediaSvc: BaseSvc() {
|
||||
name: String,
|
||||
width: UInt,
|
||||
height: UInt,
|
||||
chatType: Int,
|
||||
sceneBuilder: suspend SceneInfo.() -> Unit
|
||||
): Result<UploadRsp> {
|
||||
val req = NtV2RichMediaReq(
|
||||
@ -462,13 +463,23 @@ internal object NtV2RichMediaSvc: BaseSvc() {
|
||||
tryFastUploadCompleted = true,
|
||||
srvSendMsg = false,
|
||||
clientRandomId = Random.nextULong(),
|
||||
compatQMsgSceneType = 1u,
|
||||
compatQMsgSceneType = 2u,
|
||||
clientSeq = Random.nextUInt(),
|
||||
noNeedCompatMsg = false
|
||||
noNeedCompatMsg = true
|
||||
)
|
||||
).toByteArray()
|
||||
val buffer = sendOidbAW("OidbSvcTrpcTcp.0x11c5_100", 4549, 100, req, true, timeout = 3_000)?.slice(4)
|
||||
?: return Result.failure(Exception("no response: timeout"))
|
||||
val buffer = when (chatType) {
|
||||
MsgConstant.KCHATTYPEGROUP -> {
|
||||
sendOidbAW("OidbSvcTrpcTcp.0x11c4_100", 4548, 100, req, true, timeout = 3_000)?.slice(4)
|
||||
?: return Result.failure(Exception("no response: timeout"))
|
||||
}
|
||||
MsgConstant.KCHATTYPEC2C -> {
|
||||
sendOidbAW("OidbSvcTrpcTcp.0x11c5_100", 4549, 100, req, true, timeout = 3_000)?.slice(4)
|
||||
?: return Result.failure(Exception("no response: timeout"))
|
||||
}
|
||||
|
||||
else -> return Result.failure(Exception("unknown chat type: $chatType"))
|
||||
}
|
||||
val rspBuffer = buffer.decodeProtobuf<TrpcOidb>().buffer
|
||||
val rsp = rspBuffer.decodeProtobuf<NtV2RichMediaRsp>()
|
||||
if (rsp.upload == null) {
|
||||
|
Reference in New Issue
Block a user