This commit is contained in:
idranme
2024-10-18 21:09:51 +08:00
parent 2453509734
commit 2910b8f4e6
4 changed files with 33 additions and 32 deletions

View File

@@ -173,9 +173,10 @@ class Core extends Service {
})
registerReceiveHook<{ msgList: RawMessage[] }>([ReceiveCmdS.NEW_MSG, ReceiveCmdS.NEW_ACTIVE_MSG], payload => {
const startTime = this.startTime / 1000
for (const message of payload.msgList) {
// 过滤启动之前的消息
if (parseInt(message.msgTime) < this.startTime / 1000) {
if (parseInt(message.msgTime) < startTime) {
continue
}
if (message.senderUin && message.senderUin !== '0') {
@@ -202,7 +203,9 @@ class Core extends Service {
this.ctx.parallel('nt/message-deleted', msg)
} else if (sentMsgIds.get(msg.msgId)) {
sentMsgIds.delete(msg.msgId)
this.ctx.parallel('nt/message-sent', msg)
if (msg.sendStatus === 2) {
this.ctx.parallel('nt/message-sent', msg)
}
}
}
})
@@ -211,7 +214,7 @@ class Core extends Service {
sentMsgIds.set(payload.msgRecord.msgId, true)
})
const groupNotifyFlags: string[] = []
const groupNotifyIgnore: string[] = []
registerReceiveHook<{
doubt: boolean
oldestUnreadSeq: string
@@ -225,13 +228,11 @@ class Core extends Service {
return
}
for (const notify of notifies) {
const flag = notify.group.groupCode + '|' + notify.seq + '|' + notify.type
const notifyTime = parseInt(notify.seq) / 1000
if (groupNotifyFlags.includes(flag) || notifyTime < this.startTime) {
const notifyTime = Math.trunc(+notify.seq / 1000)
if (groupNotifyIgnore.includes(notify.seq) || notifyTime < this.startTime) {
continue
}
groupNotifyFlags.shift()
groupNotifyFlags.push(flag)
groupNotifyIgnore.push(notify.seq)
this.ctx.parallel('nt/group-notify', notify)
}
}

View File

@@ -438,6 +438,10 @@ export interface RawMessage {
likesCnt: string
isClicked: boolean
}[]
msgAttrs: Map<number, {
attrType: number
attrId: string
}>
}
export interface Peer {

View File

@@ -23,11 +23,11 @@ export default class SetFriendAddRequest extends BaseAction<Payload, null> {
if (payload.remark) {
await this.ctx.ntFriendApi.setBuddyRemark(uid, payload.remark)
}
await this.ctx.ntMsgApi.activateChat({
/*await this.ctx.ntMsgApi.activateChat({
peerUid: uid,
chatType: ChatType.C2C,
guildId: ''
})
})*/
return null
}
}

View File

@@ -71,7 +71,7 @@ export namespace OB11Entities {
sub_type: 'friend',
message: messagePostFormat === 'string' ? '' : [],
message_format: messagePostFormat === 'string' ? 'string' : 'array',
post_type: selfUin == msg.senderUin ? EventType.MESSAGE_SENT : EventType.MESSAGE,
post_type: selfUin === msg.senderUin ? EventType.MESSAGE_SENT : EventType.MESSAGE,
}
if (debug) {
resMsg.raw = msg
@@ -376,11 +376,23 @@ export namespace OB11Entities {
if (msg.chatType !== ChatType.C2C) {
return
}
if (msg.msgType !== 5) {
return
}
for (const element of msg.elements) {
if (element.grayTipElement) {
const { grayTipElement } = element
if (grayTipElement.jsonGrayTipElement?.busiId === '1061') {
const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr)
const param = grayTipElement.jsonGrayTipElement.xmlToJsonParam
if (param) {
return new OB11FriendPokeEvent(
Number(param.templParam.get('uin_str1')),
Number(param.templParam.get('uin_str2')),
json.items
)
}
const pokedetail: Dict[] = json.items
//筛选item带有uid的元素
const poke_uid = pokedetail.filter(item => item.uid)
@@ -405,31 +417,15 @@ export namespace OB11Entities {
if (msg.chatType !== ChatType.Group) {
return
}
/**if (msg.senderUin) {
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUid, msg.senderUin)
if (member && member.cardName !== msg.sendMemberName) {
const event = new OB11GroupCardEvent(
parseInt(msg.peerUid),
parseInt(msg.senderUin),
msg.sendMemberName!,
member.cardName,
)
member.cardName = msg.sendMemberName!
return event
}
}*/
if (msg.msgType !== 5 && msg.msgType !== 3) {
return
}
for (const element of msg.elements) {
const grayTipElement = element.grayTipElement
const groupElement = grayTipElement?.groupElement
if (groupElement) {
if (groupElement.type === TipGroupElementType.MemberIncrease) {
/*ctx.logger.info('收到群成员增加消息', groupElement)
const { memberUid, adminUid } = groupElement
const memberUin = await ctx.ntUserApi.getUinByUid(memberUid)
const operatorUin = adminUid ? await ctx.ntUserApi.getUinByUid(adminUid) : memberUin
return new OB11GroupIncreaseEvent(+msg.peerUid, +memberUin, +operatorUin)*/
}
else if (groupElement.type === TipGroupElementType.Ban) {
if (groupElement.type === TipGroupElementType.Ban) {
ctx.logger.info('收到群成员禁言提示', groupElement)
const memberUid = groupElement.shutUp?.member.uid
const adminUid = groupElement.shutUp?.admin.uid