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

View File

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

View File

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

View File

@@ -71,7 +71,7 @@ export namespace OB11Entities {
sub_type: 'friend', sub_type: 'friend',
message: messagePostFormat === 'string' ? '' : [], message: messagePostFormat === 'string' ? '' : [],
message_format: messagePostFormat === 'string' ? 'string' : 'array', 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) { if (debug) {
resMsg.raw = msg resMsg.raw = msg
@@ -376,11 +376,23 @@ export namespace OB11Entities {
if (msg.chatType !== ChatType.C2C) { if (msg.chatType !== ChatType.C2C) {
return return
} }
if (msg.msgType !== 5) {
return
}
for (const element of msg.elements) { for (const element of msg.elements) {
if (element.grayTipElement) { if (element.grayTipElement) {
const { grayTipElement } = element const { grayTipElement } = element
if (grayTipElement.jsonGrayTipElement?.busiId === '1061') { if (grayTipElement.jsonGrayTipElement?.busiId === '1061') {
const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr) 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 const pokedetail: Dict[] = json.items
//筛选item带有uid的元素 //筛选item带有uid的元素
const poke_uid = pokedetail.filter(item => item.uid) const poke_uid = pokedetail.filter(item => item.uid)
@@ -405,31 +417,15 @@ export namespace OB11Entities {
if (msg.chatType !== ChatType.Group) { if (msg.chatType !== ChatType.Group) {
return return
} }
/**if (msg.senderUin) { if (msg.msgType !== 5 && msg.msgType !== 3) {
const member = await ctx.ntGroupApi.getGroupMember(msg.peerUid, msg.senderUin) return
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
} }
}*/
for (const element of msg.elements) { for (const element of msg.elements) {
const grayTipElement = element.grayTipElement const grayTipElement = element.grayTipElement
const groupElement = grayTipElement?.groupElement const groupElement = grayTipElement?.groupElement
if (groupElement) { if (groupElement) {
if (groupElement.type === TipGroupElementType.MemberIncrease) { if (groupElement.type === TipGroupElementType.Ban) {
/*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) {
ctx.logger.info('收到群成员禁言提示', groupElement) ctx.logger.info('收到群成员禁言提示', groupElement)
const memberUid = groupElement.shutUp?.member.uid const memberUid = groupElement.shutUp?.member.uid
const adminUid = groupElement.shutUp?.admin.uid const adminUid = groupElement.shutUp?.admin.uid