修复好友戳一戳

取缔FriendAddEvent,并入Private Event处理
This commit is contained in:
Alen 2024-07-16 20:27:44 +08:00
parent 1dd468e2ff
commit c6b302d5a8
3 changed files with 56 additions and 22 deletions

View File

@ -191,12 +191,20 @@ function onLoad() {
postOb11Event(groupEvent)
}
})
OB11Constructor.FriendAddEvent(message).then((friendAddEvent) => {
if (friendAddEvent) {
// log("post friend add event", friendAddEvent);
postOb11Event(friendAddEvent)
OB11Constructor.PrivateEvent(message).then((privateEvent) => {
log(message)
if (privateEvent) {
// log("post private event", privateEvent);
postOb11Event(privateEvent)
}
})
// OB11Constructor.FriendAddEvent(message).then((friendAddEvent) => {
// log(message)
// if (friendAddEvent) {
// // log("post friend add event", friendAddEvent);
// postOb11Event(friendAddEvent)
// }
// })
}
}
@ -215,7 +223,7 @@ function onLoad() {
pokeEvent = new OB11GroupPokeEvent(parseInt(id))
}
else {
pokeEvent = new OB11FriendPokeEvent(parseInt(id))
pokeEvent = new OB11FriendPokeEvent(parseInt(selfInfo.uin), parseInt(id))
}
postOb11Event(pokeEvent)
})

View File

@ -47,7 +47,8 @@ import { mFaceCache } from '../ntqqapi/constructor'
import { OB11FriendAddNoticeEvent } from './event/notice/OB11FriendAddNoticeEvent'
import { OB11FriendRecallNoticeEvent } from './event/notice/OB11FriendRecallNoticeEvent'
import { OB11GroupRecallNoticeEvent } from './event/notice/OB11GroupRecallNoticeEvent'
import { OB11GroupPokeEvent } from './event/notice/OB11PokeEvent'
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent'
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent';
let lastRKeyUpdateTime = 0
@ -308,7 +309,33 @@ export class OB11Constructor {
resMsg.raw_message = resMsg.raw_message.trim()
return resMsg
}
static async PrivateEvent(msg: RawMessage): Promise<OB11BaseNoticeEvent> {
if (msg.chatType !== ChatType.friend) {
return;
}
for (const element of msg.elements) {
if (element.grayTipElement) {
if (element.grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE) {
const json = JSON.parse(element.grayTipElement.jsonGrayTipElement.jsonStr);
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
//判断业务类型
//Poke事件
let pokedetail: any[] = json.items;
//筛选item带有uid的元素
pokedetail = pokedetail.filter(item => item.uid);
if (pokedetail.length == 2) {
return new OB11FriendPokeEvent(parseInt((uidMaps[pokedetail[0].uid])!), parseInt((uidMaps[pokedetail[1].uid])));
}
}
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
}
}
}
if (msg.msgType === 5 && msg.subMsgType === 12) {
const event = new OB11FriendAddNoticeEvent(parseInt(msg.peerUin))
return event
}
}
static async GroupEvent(msg: RawMessage): Promise<OB11GroupNoticeEvent> {
if (msg.chatType !== ChatType.group) {
return
@ -515,16 +542,16 @@ export class OB11Constructor {
}
}
static async FriendAddEvent(msg: RawMessage): Promise<OB11FriendAddNoticeEvent | undefined> {
if (msg.chatType !== ChatType.friend) {
return
}
if (msg.msgType === 5 && msg.subMsgType === 12) {
const event = new OB11FriendAddNoticeEvent(parseInt(msg.peerUin))
return event
}
return
}
// static async FriendAddEvent(msg: RawMessage): Promise<OB11FriendAddNoticeEvent | undefined> {
// if (msg.chatType !== ChatType.friend) {
// return
// }
// if (msg.msgType === 5 && msg.subMsgType === 12) {
// const event = new OB11FriendAddNoticeEvent(parseInt(msg.peerUin))
// return event
// }
// return
// }
static async RecallEvent(
msg: RawMessage,

View File

@ -10,11 +10,10 @@ class OB11PokeEvent extends OB11BaseNoticeEvent {
}
export class OB11FriendPokeEvent extends OB11PokeEvent {
sender_id: number
constructor(user_id: number) {
super()
this.user_id = user_id
this.sender_id = user_id
constructor(user_id: number, target_id: number) {
super();
this.target_id = target_id;
this.user_id = user_id;
}
}