mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 05:12:17 +00:00
Compare commits
6 Commits
b03e02675b
...
2d8dde6951
Author | SHA1 | Date | |
---|---|---|---|
2d8dde6951 | |||
78fd60dade | |||
80dbf6af28 | |||
1e53753b5a | |||
e727877268 | |||
63b69df3ea |
@ -353,6 +353,21 @@ internal object MessageHelper {
|
||||
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
|
||||
|
||||
fun decodeCQCode(code: String): JsonArray {
|
||||
|
@ -30,6 +30,9 @@ interface MessageMappingDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(mapping: MessageMapping)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.ABORT)
|
||||
fun insertNotExist(mapping: MessageMapping)
|
||||
|
||||
@Query("UPDATE message_mapping_v2 SET msgSeq = :msgSeq WHERE msgHashId = :hash")
|
||||
fun updateMsgSeqByMsgHash(hash: Int, msgSeq: Int)
|
||||
|
||||
|
@ -59,6 +59,16 @@ internal object GetHistoryMsg: IActionHandler() {
|
||||
val msgList = ArrayList<MessageDetail>().apply {
|
||||
addAll(result.data!!.map { msg ->
|
||||
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(
|
||||
time = msg.msgTime.toInt(),
|
||||
msgType = MessageHelper.obtainDetailTypeByMsgType(msg.chatType),
|
||||
|
@ -2,6 +2,7 @@ package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import moe.fuqiuluo.qqinterface.servlet.GroupSvc
|
||||
import moe.fuqiuluo.qqinterface.servlet.TicketSvc
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.tools.EmptyJsonString
|
||||
@ -17,7 +18,7 @@ internal object ModifyTroopMemberName: IActionHandler() {
|
||||
}
|
||||
|
||||
operator fun invoke(groupId: String, userId: String, card: String, echo: JsonElement = EmptyJsonString): String {
|
||||
if (!GroupSvc.isAdmin(groupId)) {
|
||||
if (!GroupSvc.isAdmin(groupId) && userId != TicketSvc.getUin()) {
|
||||
return logic("you are not admin", echo)
|
||||
}
|
||||
return if(GroupSvc.modifyGroupMemberCard(groupId.toLong(), userId.toLong(), card))
|
||||
|
@ -172,6 +172,8 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
||||
postType = postType,
|
||||
messageType = MsgType.Guild,
|
||||
subType = MsgSubType.Channel,
|
||||
guildId = record.guildId,
|
||||
channelId = record.channelId,
|
||||
messageId = msgHash,
|
||||
targetId = record.peerUin,
|
||||
peerId = botUin,
|
||||
|
@ -53,6 +53,8 @@ internal data class MessageEvent (
|
||||
@SerialName("sub_type") val subType: MsgSubType,
|
||||
@SerialName("message_id") val messageId: Int,
|
||||
@SerialName("group_id") val groupId: Long = 0,
|
||||
@SerialName("guild_id") val guildId: String? = null,
|
||||
@SerialName("channel_id") val channelId: String? = null,
|
||||
@SerialName("target_id") val targetId: Long = 0,
|
||||
@SerialName("peer_id") val peerId: Long,
|
||||
@SerialName("user_id") val userId: Long,
|
||||
|
@ -89,10 +89,12 @@ internal object AioListener : IKernelMsgListener {
|
||||
|
||||
if (!GlobalEventTransmitter.MessageTransmitter.transGroupMessage(
|
||||
record, record.elements, rawMsg, msgHash, postType
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
LogCenter.log("群消息推送失败 -> 推送目标可能不存在", Level.WARN)
|
||||
}
|
||||
}
|
||||
|
||||
MsgConstant.KCHATTYPEC2C -> {
|
||||
LogCenter.log("私聊消息(private = ${record.senderUin}, id = [$msgHash | ${record.msgId} | ${record.msgSeq}], msg = $rawMsg)")
|
||||
ShamrockConfig.getPrivateRule()?.let { rule ->
|
||||
@ -102,7 +104,8 @@ internal object AioListener : IKernelMsgListener {
|
||||
|
||||
if (!GlobalEventTransmitter.MessageTransmitter.transPrivateMessage(
|
||||
record, record.elements, rawMsg, msgHash, postType
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
LogCenter.log("私聊消息推送失败 -> MessageTransmitter", Level.WARN)
|
||||
}
|
||||
}
|
||||
@ -117,8 +120,14 @@ internal object AioListener : IKernelMsgListener {
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -447,6 +456,7 @@ internal object AioListener : IKernelMsgListener {
|
||||
override fun onGuildMsgAbFlagChanged(guildMsgAbFlag: GuildMsgAbFlag?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onGuildNotificationAbstractUpdate(guildNotificationAbstractInfo: GuildNotificationAbstractInfo?) {
|
||||
|
||||
}
|
||||
|
@ -534,12 +534,11 @@ internal object PrimitiveListener {
|
||||
val groupCode = event.groupCode
|
||||
val applierUid = event.applierUid
|
||||
val reason = event.applyMsg ?: ""
|
||||
val applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
||||
var applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
||||
if (applier == getLongUin()) {
|
||||
return
|
||||
}
|
||||
val msgSeq = contentHead.msgSeq
|
||||
LogCenter.log("入群申请($groupCode) $applier: \"$reason\", seq: $msgSeq")
|
||||
val flag = try {
|
||||
var reqs = requestGroupSystemMsgNew(10, 1)
|
||||
val riskReqs = requestGroupSystemMsgNew(5, 2)
|
||||
@ -548,10 +547,14 @@ internal object PrimitiveListener {
|
||||
it.msg_time.get() == time && it.msg?.group_code?.get() == groupCode
|
||||
}
|
||||
val seq = req?.msg_seq?.get() ?: time
|
||||
if (applier == 0L) {
|
||||
applier = req?.req_uin?.get() ?: 0L
|
||||
}
|
||||
"$seq;$groupCode;$applier"
|
||||
} catch (err: Throwable) {
|
||||
"$time;$groupCode;$applier"
|
||||
}
|
||||
LogCenter.log("入群申请($groupCode) $applier: \"$reason\", seq: $msgSeq")
|
||||
if (!GlobalEventTransmitter.RequestTransmitter
|
||||
.transGroupApply(time, applier, applierUid, reason, groupCode, flag, RequestSubType.Add)
|
||||
) {
|
||||
@ -562,7 +565,7 @@ internal object PrimitiveListener {
|
||||
val event = ProtoBuf.decodeFromByteArray<GroupInvitedApplyEvent>(richMsg.rawBuffer!!)
|
||||
val groupCode = event.applyInfo?.groupCode ?: return
|
||||
val applierUid = event.applyInfo?.applierUid ?: return
|
||||
val applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
||||
var applier = ContactHelper.getUinByUidAsync(applierUid).toLong()
|
||||
if (applier == getLongUin()) {
|
||||
return
|
||||
}
|
||||
@ -570,7 +573,6 @@ internal object PrimitiveListener {
|
||||
// todo
|
||||
return
|
||||
}
|
||||
LogCenter.log("邀请入群申请($groupCode): $applier")
|
||||
val flag = try {
|
||||
var reqs = requestGroupSystemMsgNew(10, 1)
|
||||
val riskReqs = requestGroupSystemMsgNew(5, 2)
|
||||
@ -579,10 +581,14 @@ internal object PrimitiveListener {
|
||||
it.msg_time.get() == time
|
||||
}
|
||||
val seq = req?.msg_seq?.get() ?: time
|
||||
if (applier == 0L) {
|
||||
applier = req?.req_uin?.get() ?: 0L
|
||||
}
|
||||
"$seq;$groupCode;$applier"
|
||||
} catch (err: Throwable) {
|
||||
"$time;$groupCode;$applier"
|
||||
}
|
||||
LogCenter.log("邀请入群申请($groupCode): $applier")
|
||||
if (!GlobalEventTransmitter.RequestTransmitter
|
||||
.transGroupApply(time, applier, applierUid, "", groupCode, flag, RequestSubType.Add)
|
||||
) {
|
||||
|
Reference in New Issue
Block a user