parent
7b67c14642
commit
e2901c216b
|
@ -254,17 +254,19 @@ internal object MsgConvert {
|
|||
}
|
||||
MsgConstant.KELEMTYPEREPLY -> {
|
||||
val reply = element.replyElement
|
||||
var msgId = reply.sourceMsgIdInRecords
|
||||
if (msgId == 0L) {
|
||||
msgId = reply.replayMsgId
|
||||
val msgId = reply.replayMsgId
|
||||
val msgHash = if (msgId != 0L) {
|
||||
MessageHelper.generateMsgIdHash(chatType, msgId)
|
||||
} else {
|
||||
MessageDB.getInstance().messageMappingDao()
|
||||
.queryByMsgSeq(chatType, peerId, reply.replayMsgSeq?.toInt() ?: 0)?.msgHashId
|
||||
?: MessageHelper.generateMsgIdHash(chatType, reply.sourceMsgIdInRecords)
|
||||
}
|
||||
|
||||
val mapping = MessageDB.getInstance().messageMappingDao().queryByMsgSeq(chatType, peerId, reply.replayMsgSeq.toInt())
|
||||
|
||||
return hashMapOf(
|
||||
"type" to "reply".json,
|
||||
"data" to JsonObject(mapOf(
|
||||
"id" to (mapping?.msgHashId ?: MessageHelper.generateMsgIdHash(chatType, msgId)).json,
|
||||
"id" to msgHash.json,
|
||||
))
|
||||
)
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ internal object MessageHelper {
|
|||
|
||||
fun generateMsgId(chatType: Int): Pair<Int, Long> {
|
||||
val msgId = createMessageUniseq(chatType, System.currentTimeMillis())
|
||||
val hashCode: Int = convertMsgIdToMsgHash(chatType, msgId)
|
||||
val hashCode: Int = generateMsgIdHash(chatType, msgId)
|
||||
return hashCode to msgId
|
||||
}
|
||||
|
||||
|
@ -128,10 +128,6 @@ internal object MessageHelper {
|
|||
return db.messageMappingDao().queryByMsgSeq(chatType, msgSeq)
|
||||
}
|
||||
|
||||
inline fun convertMsgIdToMsgHash(chatType: Int, msgId: Long): Int {
|
||||
return generateMsgIdHash(chatType, msgId)
|
||||
}
|
||||
|
||||
fun removeMsgByHashCode(hashCode: Int) {
|
||||
MessageDB.getInstance()
|
||||
.messageMappingDao()
|
||||
|
|
|
@ -29,9 +29,7 @@ internal object AioListener: IKernelMsgListener {
|
|||
|
||||
private suspend fun handleMsg(record: MsgRecord) {
|
||||
try {
|
||||
val rawMsg = record.elements.toCQCode(record.chatType, record.peerUin.toString())
|
||||
if (rawMsg.isEmpty()) return
|
||||
val msgHash = MessageHelper.convertMsgIdToMsgHash(record.chatType, record.msgId)
|
||||
val msgHash = MessageHelper.generateMsgIdHash(record.chatType, record.msgId)
|
||||
|
||||
MessageHelper.saveMsgMapping(
|
||||
hash = msgHash,
|
||||
|
@ -43,9 +41,12 @@ internal object AioListener: IKernelMsgListener {
|
|||
time = record.msgTime
|
||||
)
|
||||
|
||||
val rawMsg = record.elements.toCQCode(record.chatType, record.peerUin.toString())
|
||||
if (rawMsg.isEmpty()) return
|
||||
|
||||
when (record.chatType) {
|
||||
MsgConstant.KCHATTYPEGROUP -> {
|
||||
LogCenter.log("群消息(group = ${record.peerName}(${record.peerUin}), uin = ${record.senderUin}, id = $msgHash, msg = $rawMsg)")
|
||||
LogCenter.log("群消息(group = ${record.peerName}(${record.peerUin}), uin = ${record.senderUin}, id = $msgHash|${record.msgSeq}, msg = $rawMsg)")
|
||||
ShamrockConfig.getGroupMsgRule()?.let { rule ->
|
||||
if (rule.black?.contains(record.peerUin) == true) return
|
||||
if (rule.white?.contains(record.peerUin) == false) return
|
||||
|
@ -56,7 +57,7 @@ internal object AioListener: IKernelMsgListener {
|
|||
}
|
||||
}
|
||||
MsgConstant.KCHATTYPEC2C -> {
|
||||
LogCenter.log("私聊消息(private = ${record.senderUin}, msg = $rawMsg)")
|
||||
LogCenter.log("私聊消息(private = ${record.senderUin}, id = $msgHash|${record.msgSeq}, msg = $rawMsg)")
|
||||
ShamrockConfig.getPrivateRule()?.let { rule ->
|
||||
if (rule.black?.contains(record.peerUin) == true) return
|
||||
if (rule.white?.contains(record.peerUin) == false) return
|
||||
|
@ -76,11 +77,7 @@ internal object AioListener: IKernelMsgListener {
|
|||
override fun onAddSendMsg(record: MsgRecord) {
|
||||
GlobalScope.launch {
|
||||
try {
|
||||
val rawMsg = record.elements.toCQCode(record.chatType, record.peerUin.toString())
|
||||
if (rawMsg.isEmpty()) return@launch
|
||||
LogCenter.log("发送消息: $rawMsg")
|
||||
|
||||
val msgHash = MessageHelper.convertMsgIdToMsgHash(record.chatType, record.msgId)
|
||||
val msgHash = MessageHelper.generateMsgIdHash(record.chatType, record.msgId)
|
||||
MessageHelper.saveMsgMapping(
|
||||
hash = msgHash,
|
||||
qqMsgId = record.msgId,
|
||||
|
@ -91,6 +88,11 @@ internal object AioListener: IKernelMsgListener {
|
|||
time = record.msgTime
|
||||
)
|
||||
|
||||
val rawMsg = record.elements.toCQCode(record.chatType, record.peerUin.toString())
|
||||
if (rawMsg.isEmpty()) return@launch
|
||||
|
||||
LogCenter.log("发送消息($msgHash|${record.msgSeq}): $rawMsg")
|
||||
|
||||
if (!ShamrockConfig.enableSelfMsg())
|
||||
return@launch
|
||||
|
||||
|
|
Loading…
Reference in New Issue