mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: Rewrite timeout message sending #215
This commit is contained in:
parent
72c3c7bdf7
commit
dd1b909bb0
@ -171,6 +171,7 @@ internal object MsgSvc: BaseSvc() {
|
||||
peedId: String,
|
||||
message: JsonArray,
|
||||
fromId: String = peedId,
|
||||
retryCnt: Int
|
||||
): Result<SendMsgResult> {
|
||||
// 主动临时消息
|
||||
when (chatType) {
|
||||
|
@ -122,7 +122,7 @@ internal object QuickOperation: IActionHandler() {
|
||||
}.let {
|
||||
if (it.isNotEmpty()) {
|
||||
it.map { listOf(it) }.forEach {
|
||||
MsgSvc.sendToAio(record.chatType, record.peerUin.toString(), it.jsonArray)
|
||||
MsgSvc.sendToAio(record.chatType, record.peerUin.toString(), it.jsonArray, retryCnt = 3)
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -143,6 +143,6 @@ internal object QuickOperation: IActionHandler() {
|
||||
).json) // 添加@发送者
|
||||
}
|
||||
messageList.addAll(message)
|
||||
MsgSvc.sendToAio(record.chatType, record.peerUin.toString(), JsonArray(messageList))
|
||||
MsgSvc.sendToAio(record.chatType, record.peerUin.toString(), JsonArray(messageList), retryCnt = 3)
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ import moe.fuqiuluo.shamrock.helper.ParamsException
|
||||
import moe.fuqiuluo.qqinterface.servlet.MsgSvc
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import moe.fuqiuluo.shamrock.helper.ContactHelper
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.MessageResult
|
||||
import moe.fuqiuluo.shamrock.tools.json
|
||||
import moe.fuqiuluo.shamrock.helper.Level
|
||||
@ -93,7 +92,7 @@ internal object SendMessage: IActionHandler() {
|
||||
"text" to message
|
||||
)
|
||||
)
|
||||
).json, fromId = fromId)
|
||||
).json, fromId = fromId, retryCnt)
|
||||
} else {
|
||||
val msg = MessageHelper.decodeCQCode(message)
|
||||
if (msg.isEmpty()) {
|
||||
@ -106,14 +105,14 @@ internal object SendMessage: IActionHandler() {
|
||||
if (result.isFailure) {
|
||||
return logic(result.exceptionOrNull()?.message ?: "", echo)
|
||||
}
|
||||
val pair = result.getOrNull() ?: Pair(0L, 0)
|
||||
if (pair.first <= 0) {
|
||||
val sendMsgResult = result.getOrThrow()
|
||||
if (sendMsgResult.msgHashId <= 0) {
|
||||
return logic("send message failed", echo = echo)
|
||||
}
|
||||
recallDuration?.let { autoRecall(pair.second, it) }
|
||||
recallDuration?.let { autoRecall(sendMsgResult.msgHashId, it) }
|
||||
return ok(MessageResult(
|
||||
msgId = pair.second,
|
||||
time = (pair.first * 0.001).toLong()
|
||||
msgId = sendMsgResult.msgHashId,
|
||||
time = (sendMsgResult.msgTime * 0.001).toLong()
|
||||
), echo = echo)
|
||||
}
|
||||
|
||||
@ -128,14 +127,14 @@ internal object SendMessage: IActionHandler() {
|
||||
if (result.isFailure) {
|
||||
return logic(result.exceptionOrNull()?.message ?: "", echo)
|
||||
}
|
||||
val pair = result.getOrNull() ?: Pair(0L, 0)
|
||||
if (pair.first <= 0) {
|
||||
val sendMsgResult = result.getOrThrow()
|
||||
if (sendMsgResult.msgHashId <= 0) {
|
||||
return logic("send message failed", echo = echo)
|
||||
}
|
||||
recallDuration?.let { autoRecall(pair.second, it) }
|
||||
recallDuration?.let { autoRecall(sendMsgResult.msgHashId, it) }
|
||||
return ok(MessageResult(
|
||||
msgId = pair.second,
|
||||
time = (pair.first * 0.001).toLong()
|
||||
msgId = sendMsgResult.msgHashId,
|
||||
time = (sendMsgResult.msgTime * 0.001).toLong()
|
||||
), echo)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user