mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
add history msg to database
This commit is contained in:
parent
78fd60dade
commit
2d8dde6951
@ -353,6 +353,21 @@ internal object MessageHelper {
|
|||||||
database.messageMappingDao().insert(mapping)
|
database.messageMappingDao().insert(mapping)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun saveMsgMappingNotExist(
|
||||||
|
hash: Int,
|
||||||
|
qqMsgId: Long,
|
||||||
|
time: Long,
|
||||||
|
chatType: Int,
|
||||||
|
peerId: String,
|
||||||
|
subPeerId: String,
|
||||||
|
msgSeq: Int,
|
||||||
|
subChatType: Int = chatType
|
||||||
|
) {
|
||||||
|
val database = MessageDB.getInstance()
|
||||||
|
val mapping = MessageMapping(hash, qqMsgId, chatType, subChatType, peerId, time, msgSeq, subPeerId)
|
||||||
|
database.messageMappingDao().insertNotExist(mapping)
|
||||||
|
}
|
||||||
|
|
||||||
external fun createMessageUniseq(chatType: Int, time: Long): Long
|
external fun createMessageUniseq(chatType: Int, time: Long): Long
|
||||||
|
|
||||||
fun decodeCQCode(code: String): JsonArray {
|
fun decodeCQCode(code: String): JsonArray {
|
||||||
|
@ -30,6 +30,9 @@ interface MessageMappingDao {
|
|||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
fun insert(mapping: MessageMapping)
|
fun insert(mapping: MessageMapping)
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.ABORT)
|
||||||
|
fun insertNotExist(mapping: MessageMapping)
|
||||||
|
|
||||||
@Query("UPDATE message_mapping_v2 SET msgSeq = :msgSeq WHERE msgHashId = :hash")
|
@Query("UPDATE message_mapping_v2 SET msgSeq = :msgSeq WHERE msgHashId = :hash")
|
||||||
fun updateMsgSeqByMsgHash(hash: Int, msgSeq: Int)
|
fun updateMsgSeqByMsgHash(hash: Int, msgSeq: Int)
|
||||||
|
|
||||||
|
@ -59,6 +59,16 @@ internal object GetHistoryMsg: IActionHandler() {
|
|||||||
val msgList = ArrayList<MessageDetail>().apply {
|
val msgList = ArrayList<MessageDetail>().apply {
|
||||||
addAll(result.data!!.map { msg ->
|
addAll(result.data!!.map { msg ->
|
||||||
val msgHash = MessageHelper.generateMsgIdHash(msg.chatType, msg.msgId)
|
val msgHash = MessageHelper.generateMsgIdHash(msg.chatType, msg.msgId)
|
||||||
|
MessageHelper.saveMsgMappingNotExist(
|
||||||
|
hash = msgHash,
|
||||||
|
qqMsgId = msg.msgId,
|
||||||
|
chatType = msg.chatType,
|
||||||
|
subChatType = msg.chatType,
|
||||||
|
peerId = peerId,
|
||||||
|
msgSeq = msg.msgSeq.toInt(),
|
||||||
|
time = msg.msgTime,
|
||||||
|
subPeerId = msg.channelId ?: peerId
|
||||||
|
)
|
||||||
MessageDetail(
|
MessageDetail(
|
||||||
time = msg.msgTime.toInt(),
|
time = msg.msgTime.toInt(),
|
||||||
msgType = MessageHelper.obtainDetailTypeByMsgType(msg.chatType),
|
msgType = MessageHelper.obtainDetailTypeByMsgType(msg.chatType),
|
||||||
|
@ -89,10 +89,12 @@ internal object AioListener : IKernelMsgListener {
|
|||||||
|
|
||||||
if (!GlobalEventTransmitter.MessageTransmitter.transGroupMessage(
|
if (!GlobalEventTransmitter.MessageTransmitter.transGroupMessage(
|
||||||
record, record.elements, rawMsg, msgHash, postType
|
record, record.elements, rawMsg, msgHash, postType
|
||||||
)) {
|
)
|
||||||
|
) {
|
||||||
LogCenter.log("群消息推送失败 -> 推送目标可能不存在", Level.WARN)
|
LogCenter.log("群消息推送失败 -> 推送目标可能不存在", Level.WARN)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgConstant.KCHATTYPEC2C -> {
|
MsgConstant.KCHATTYPEC2C -> {
|
||||||
LogCenter.log("私聊消息(private = ${record.senderUin}, id = [$msgHash | ${record.msgId} | ${record.msgSeq}], msg = $rawMsg)")
|
LogCenter.log("私聊消息(private = ${record.senderUin}, id = [$msgHash | ${record.msgId} | ${record.msgSeq}], msg = $rawMsg)")
|
||||||
ShamrockConfig.getPrivateRule()?.let { rule ->
|
ShamrockConfig.getPrivateRule()?.let { rule ->
|
||||||
@ -102,7 +104,8 @@ internal object AioListener : IKernelMsgListener {
|
|||||||
|
|
||||||
if (!GlobalEventTransmitter.MessageTransmitter.transPrivateMessage(
|
if (!GlobalEventTransmitter.MessageTransmitter.transPrivateMessage(
|
||||||
record, record.elements, rawMsg, msgHash, postType
|
record, record.elements, rawMsg, msgHash, postType
|
||||||
)) {
|
)
|
||||||
|
) {
|
||||||
LogCenter.log("私聊消息推送失败 -> MessageTransmitter", Level.WARN)
|
LogCenter.log("私聊消息推送失败 -> MessageTransmitter", Level.WARN)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,8 +120,14 @@ internal object AioListener : IKernelMsgListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!GlobalEventTransmitter.MessageTransmitter.transPrivateMessage(
|
if (!GlobalEventTransmitter.MessageTransmitter.transPrivateMessage(
|
||||||
record, record.elements, rawMsg, msgHash, tempSource = MessageTempSource.Group, postType = postType
|
record,
|
||||||
)) {
|
record.elements,
|
||||||
|
rawMsg,
|
||||||
|
msgHash,
|
||||||
|
tempSource = MessageTempSource.Group,
|
||||||
|
postType = postType
|
||||||
|
)
|
||||||
|
) {
|
||||||
LogCenter.log("私聊临时消息推送失败 -> MessageTransmitter", Level.WARN)
|
LogCenter.log("私聊临时消息推送失败 -> MessageTransmitter", Level.WARN)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -447,6 +456,7 @@ internal object AioListener : IKernelMsgListener {
|
|||||||
override fun onGuildMsgAbFlagChanged(guildMsgAbFlag: GuildMsgAbFlag?) {
|
override fun onGuildMsgAbFlagChanged(guildMsgAbFlag: GuildMsgAbFlag?) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGuildNotificationAbstractUpdate(guildNotificationAbstractInfo: GuildNotificationAbstractInfo?) {
|
override fun onGuildNotificationAbstractUpdate(guildNotificationAbstractInfo: GuildNotificationAbstractInfo?) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user