diff --git a/src/onebot/api/friend.ts b/src/onebot/api/friend.ts index a8db7682..610c93bf 100644 --- a/src/onebot/api/friend.ts +++ b/src/onebot/api/friend.ts @@ -12,16 +12,17 @@ export class OneBotFriendApi { } //使用前预先判断 busiId 1061 - async parsePrivatePokeEvent(grayTipElement: GrayTipElement) { + async parsePrivatePokeEvent(grayTipElement: GrayTipElement, uin: number) { const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr); - let pokedetail: Array<{ uid: string }> = json.items; + const pokedetail: Array<{ uid: string }> = json.items; //筛选item带有uid的元素 - pokedetail = pokedetail.filter(item => item.uid); - if (pokedetail.length == 2) { + const poke_uid = pokedetail.filter(item => item.uid); + if (poke_uid.length == 2) { return new OB11FriendPokeEvent( this.core, - parseInt((await this.core.apis.UserApi.getUinByUidV2(pokedetail[0].uid))), - parseInt((await this.core.apis.UserApi.getUinByUidV2(pokedetail[1].uid))), + uin, + parseInt((await this.core.apis.UserApi.getUinByUidV2(poke_uid[0].uid))), + parseInt((await this.core.apis.UserApi.getUinByUidV2(poke_uid[1].uid))), pokedetail, ); } diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index ecf4fc7d..5755ca70 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -679,7 +679,7 @@ export class OneBotMsgApi { async parsePrivateMsgEvent(msg: RawMessage, grayTipElement: GrayTipElement) { if (grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) { if (grayTipElement.jsonGrayTipElement.busiId == 1061) { - const PokeEvent = await this.obContext.apis.FriendApi.parsePrivatePokeEvent(grayTipElement); + const PokeEvent = await this.obContext.apis.FriendApi.parsePrivatePokeEvent(grayTipElement, Number(await this.core.apis.UserApi.getUinByUidV2(msg.peerUid))); if (PokeEvent) { return PokeEvent; }; } else if (grayTipElement.jsonGrayTipElement.busiId == 19324 && msg.peerUid !== '') { return new OB11FriendAddNoticeEvent(this.core, Number(await this.core.apis.UserApi.getUinByUidV2(msg.peerUid))); diff --git a/src/onebot/event/notice/OB11PokeEvent.ts b/src/onebot/event/notice/OB11PokeEvent.ts index 80a2e760..26f313d3 100644 --- a/src/onebot/event/notice/OB11PokeEvent.ts +++ b/src/onebot/event/notice/OB11PokeEvent.ts @@ -10,12 +10,14 @@ class OB11PokeEvent extends OB11BaseNoticeEvent { export class OB11FriendPokeEvent extends OB11PokeEvent { raw_info: any; + sender_id: number; //raw_message nb等框架标准为string - constructor(core: NapCatCore, user_id: number, target_id: number, raw_message: any) { + constructor(core: NapCatCore, user_id: number, sender_id: number, target_id: number, raw_message: any) { super(core); this.target_id = target_id; this.user_id = user_id; + this.sender_id = sender_id; this.raw_info = raw_message; } }