diff --git a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/MsgSvc.kt b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/MsgSvc.kt index 23fbc15..0722446 100644 --- a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/MsgSvc.kt +++ b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/MsgSvc.kt @@ -176,9 +176,6 @@ internal object MsgSvc: BaseSvc() { fromId: String = peedId, retryCnt: Int = 3 ): Result> { - //LogCenter.log(message.toString(), Level.ERROR) - //callback.msgHash = result.second 什么垃圾代码,万一cb比你快,你不就寄了? - // 主动临时消息 when (chatType) { MsgConstant.KCHATTYPETEMPC2CFROMGROUP -> { @@ -188,13 +185,7 @@ internal object MsgSvc: BaseSvc() { } } } - val result = MessageHelper.sendMessageWithoutMsgId( - chatType, - peedId, - message, - fromId, - MessageCallback(peedId, 0) - ) + val result = MessageHelper.sendMessageWithoutMsgId(chatType, peedId, message, fromId, MessageCallback(peedId, 0)) return if (result.isFailure && result.exceptionOrNull()?.javaClass == SendMsgException::class.java && retryCnt > 0) { diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/helper/MessageHelper.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/helper/MessageHelper.kt index 456e565..18de550 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/helper/MessageHelper.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/helper/MessageHelper.kt @@ -9,6 +9,7 @@ import com.tencent.qqnt.msg.api.IMsgService import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.withTimeoutOrNull import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.JsonElement @@ -38,7 +39,11 @@ internal object MessageHelper { ): Pair { val uniseq = generateMsgId(chatType) val msg = messageArrayToMessageElements(chatType, uniseq.second, peerId, decodeCQCode(message)).also { - if (it.second.isEmpty() && !it.first) error("消息合成失败,请查看日志或者检查输入。") + if (it.second.isEmpty() && !it.first) { + error("消息合成失败,请查看日志或者检查输入。") + } else if (it.second.isEmpty()) { + return System.currentTimeMillis() to 0 + } }.second.filter { it.elementType != -1 } as ArrayList @@ -59,6 +64,12 @@ internal object MessageHelper { }.second.filter { it.elementType != -1 } as ArrayList + + // ActionMsg No Care + if (msg.isEmpty()) { + return Result.success(System.currentTimeMillis() to 0) + } + val totalSize = msg.filter { it.elementType == MsgConstant.KELEMTYPEPIC || it.elementType == MsgConstant.KELEMTYPEPTT || @@ -67,11 +78,11 @@ internal object MessageHelper { (it.picElement?.fileSize ?: 0) + (it.pttElement?.fileSize ?: 0) + (it.videoElement?.fileSize ?: 0) }.reduceOrNull { a, b -> a + b } ?: 0 + val estimateTime = (totalSize / (300 * 1024)) * 1000 + 2000 - val estimateTime = (totalSize / (300 * 1024)) * 1000 + 5000 lateinit var sendResultPair: Pair val sendRet = withTimeoutOrNull>(estimateTime) { - suspendCoroutine { + suspendCancellableCoroutine { GlobalScope.launch { sendResultPair = sendMessageWithoutMsgId( chatType,