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,
|
peedId: String,
|
||||||
message: JsonArray,
|
message: JsonArray,
|
||||||
fromId: String = peedId,
|
fromId: String = peedId,
|
||||||
|
retryCnt: Int
|
||||||
): Result<SendMsgResult> {
|
): Result<SendMsgResult> {
|
||||||
// 主动临时消息
|
// 主动临时消息
|
||||||
when (chatType) {
|
when (chatType) {
|
||||||
|
@ -122,7 +122,7 @@ internal object QuickOperation: IActionHandler() {
|
|||||||
}.let {
|
}.let {
|
||||||
if (it.isNotEmpty()) {
|
if (it.isNotEmpty()) {
|
||||||
it.map { listOf(it) }.forEach {
|
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
|
return
|
||||||
}
|
}
|
||||||
@ -143,6 +143,6 @@ internal object QuickOperation: IActionHandler() {
|
|||||||
).json) // 添加@发送者
|
).json) // 添加@发送者
|
||||||
}
|
}
|
||||||
messageList.addAll(message)
|
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 moe.fuqiuluo.qqinterface.servlet.MsgSvc
|
||||||
import kotlinx.serialization.json.JsonArray
|
import kotlinx.serialization.json.JsonArray
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
import moe.fuqiuluo.shamrock.helper.ContactHelper
|
|
||||||
import moe.fuqiuluo.shamrock.remote.service.data.MessageResult
|
import moe.fuqiuluo.shamrock.remote.service.data.MessageResult
|
||||||
import moe.fuqiuluo.shamrock.tools.json
|
import moe.fuqiuluo.shamrock.tools.json
|
||||||
import moe.fuqiuluo.shamrock.helper.Level
|
import moe.fuqiuluo.shamrock.helper.Level
|
||||||
@ -93,7 +92,7 @@ internal object SendMessage: IActionHandler() {
|
|||||||
"text" to message
|
"text" to message
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).json, fromId = fromId)
|
).json, fromId = fromId, retryCnt)
|
||||||
} else {
|
} else {
|
||||||
val msg = MessageHelper.decodeCQCode(message)
|
val msg = MessageHelper.decodeCQCode(message)
|
||||||
if (msg.isEmpty()) {
|
if (msg.isEmpty()) {
|
||||||
@ -106,14 +105,14 @@ internal object SendMessage: IActionHandler() {
|
|||||||
if (result.isFailure) {
|
if (result.isFailure) {
|
||||||
return logic(result.exceptionOrNull()?.message ?: "", echo)
|
return logic(result.exceptionOrNull()?.message ?: "", echo)
|
||||||
}
|
}
|
||||||
val pair = result.getOrNull() ?: Pair(0L, 0)
|
val sendMsgResult = result.getOrThrow()
|
||||||
if (pair.first <= 0) {
|
if (sendMsgResult.msgHashId <= 0) {
|
||||||
return logic("send message failed", echo = echo)
|
return logic("send message failed", echo = echo)
|
||||||
}
|
}
|
||||||
recallDuration?.let { autoRecall(pair.second, it) }
|
recallDuration?.let { autoRecall(sendMsgResult.msgHashId, it) }
|
||||||
return ok(MessageResult(
|
return ok(MessageResult(
|
||||||
msgId = pair.second,
|
msgId = sendMsgResult.msgHashId,
|
||||||
time = (pair.first * 0.001).toLong()
|
time = (sendMsgResult.msgTime * 0.001).toLong()
|
||||||
), echo = echo)
|
), echo = echo)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,14 +127,14 @@ internal object SendMessage: IActionHandler() {
|
|||||||
if (result.isFailure) {
|
if (result.isFailure) {
|
||||||
return logic(result.exceptionOrNull()?.message ?: "", echo)
|
return logic(result.exceptionOrNull()?.message ?: "", echo)
|
||||||
}
|
}
|
||||||
val pair = result.getOrNull() ?: Pair(0L, 0)
|
val sendMsgResult = result.getOrThrow()
|
||||||
if (pair.first <= 0) {
|
if (sendMsgResult.msgHashId <= 0) {
|
||||||
return logic("send message failed", echo = echo)
|
return logic("send message failed", echo = echo)
|
||||||
}
|
}
|
||||||
recallDuration?.let { autoRecall(pair.second, it) }
|
recallDuration?.let { autoRecall(sendMsgResult.msgHashId, it) }
|
||||||
return ok(MessageResult(
|
return ok(MessageResult(
|
||||||
msgId = pair.second,
|
msgId = sendMsgResult.msgHashId,
|
||||||
time = (pair.first * 0.001).toLong()
|
time = (sendMsgResult.msgTime * 0.001).toLong()
|
||||||
), echo)
|
), echo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user