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.toJson
|
||||||
import moe.fuqiuluo.qqinterface.servlet.msg.toSegments
|
import moe.fuqiuluo.qqinterface.servlet.msg.toSegments
|
||||||
import moe.fuqiuluo.qqinterface.servlet.transfile.NtV2RichMediaSvc
|
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.*
|
||||||
import moe.fuqiuluo.shamrock.helper.MessageHelper.messageArrayToRichText
|
import moe.fuqiuluo.shamrock.helper.MessageHelper.messageArrayToRichText
|
||||||
import moe.fuqiuluo.shamrock.helper.MessageHelper.obtainMessageTypeByDetailType
|
import moe.fuqiuluo.shamrock.helper.MessageHelper.obtainMessageTypeByDetailType
|
||||||
@ -267,11 +268,11 @@ internal class ElemMaker {
|
|||||||
runCatching {
|
runCatching {
|
||||||
fileInfo.uuid.toUInt()
|
fileInfo.uuid.toUInt()
|
||||||
}.onFailure {
|
}.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) {
|
when(chatType) {
|
||||||
MsgConstant.KCHATTYPEGROUP -> {
|
MsgConstant.KCHATTYPEGROUP -> {
|
||||||
sceneType = 2u
|
sceneType = 2u
|
||||||
grp = GroupUserInfo(peerId.toULong())
|
grp = GroupUserInfo(fetchGroupResUploadTo().toULong())
|
||||||
}
|
}
|
||||||
MsgConstant.KCHATTYPEC2C -> {
|
MsgConstant.KCHATTYPEC2C -> {
|
||||||
sceneType = 1u
|
sceneType = 1u
|
||||||
|
@ -19,7 +19,6 @@ import kotlinx.coroutines.withTimeoutOrNull
|
|||||||
import moe.fuqiuluo.qqinterface.servlet.BaseSvc
|
import moe.fuqiuluo.qqinterface.servlet.BaseSvc
|
||||||
import moe.fuqiuluo.qqinterface.servlet.TicketSvc
|
import moe.fuqiuluo.qqinterface.servlet.TicketSvc
|
||||||
import moe.fuqiuluo.qqinterface.servlet.transfile.data.TryUpPicData
|
import moe.fuqiuluo.qqinterface.servlet.transfile.data.TryUpPicData
|
||||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
|
||||||
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
||||||
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
||||||
import moe.fuqiuluo.shamrock.tools.hex2ByteArray
|
import moe.fuqiuluo.shamrock.tools.hex2ByteArray
|
||||||
@ -62,7 +61,7 @@ import kotlin.time.Duration
|
|||||||
internal object NtV2RichMediaSvc: BaseSvc() {
|
internal object NtV2RichMediaSvc: BaseSvc() {
|
||||||
private val requestIdSeq = atomic(2L)
|
private val requestIdSeq = atomic(2L)
|
||||||
|
|
||||||
private fun fetchGroupResUploadTo(): String {
|
fun fetchGroupResUploadTo(): String {
|
||||||
return ShamrockConfig.getUpResGroup().ifEmpty { "100000000" }
|
return ShamrockConfig.getUpResGroup().ifEmpty { "100000000" }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,13 +404,14 @@ internal object NtV2RichMediaSvc: BaseSvc() {
|
|||||||
width: UInt,
|
width: UInt,
|
||||||
height: UInt,
|
height: UInt,
|
||||||
retryCnt: Int,
|
retryCnt: Int,
|
||||||
|
chatType: Int = MsgConstant.KCHATTYPEGROUP,
|
||||||
sceneBuilder: suspend SceneInfo.() -> Unit
|
sceneBuilder: suspend SceneInfo.() -> Unit
|
||||||
): Result<UploadRsp> {
|
): Result<UploadRsp> {
|
||||||
return runCatching {
|
return runCatching {
|
||||||
requestUploadNtPic(file, md5, sha, name, width, height, sceneBuilder).getOrThrow()
|
requestUploadNtPic(file, md5, sha, name, width, height, chatType, sceneBuilder).getOrThrow()
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
if (retryCnt > 0) {
|
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,
|
name: String,
|
||||||
width: UInt,
|
width: UInt,
|
||||||
height: UInt,
|
height: UInt,
|
||||||
|
chatType: Int,
|
||||||
sceneBuilder: suspend SceneInfo.() -> Unit
|
sceneBuilder: suspend SceneInfo.() -> Unit
|
||||||
): Result<UploadRsp> {
|
): Result<UploadRsp> {
|
||||||
val req = NtV2RichMediaReq(
|
val req = NtV2RichMediaReq(
|
||||||
@ -462,13 +463,23 @@ internal object NtV2RichMediaSvc: BaseSvc() {
|
|||||||
tryFastUploadCompleted = true,
|
tryFastUploadCompleted = true,
|
||||||
srvSendMsg = false,
|
srvSendMsg = false,
|
||||||
clientRandomId = Random.nextULong(),
|
clientRandomId = Random.nextULong(),
|
||||||
compatQMsgSceneType = 1u,
|
compatQMsgSceneType = 2u,
|
||||||
clientSeq = Random.nextUInt(),
|
clientSeq = Random.nextUInt(),
|
||||||
noNeedCompatMsg = false
|
noNeedCompatMsg = true
|
||||||
)
|
)
|
||||||
).toByteArray()
|
).toByteArray()
|
||||||
val buffer = sendOidbAW("OidbSvcTrpcTcp.0x11c5_100", 4549, 100, req, true, timeout = 3_000)?.slice(4)
|
val buffer = when (chatType) {
|
||||||
?: return Result.failure(Exception("no response: timeout"))
|
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 rspBuffer = buffer.decodeProtobuf<TrpcOidb>().buffer
|
||||||
val rsp = rspBuffer.decodeProtobuf<NtV2RichMediaRsp>()
|
val rsp = rspBuffer.decodeProtobuf<NtV2RichMediaRsp>()
|
||||||
if (rsp.upload == null) {
|
if (rsp.upload == null) {
|
||||||
|
Reference in New Issue
Block a user