From c25b9f86db10903c9841229dad33a36be48b954c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=8C=E8=8E=9E=7E=28=3D=5E=E2=96=BD=5E=3D=29?= Date: Wed, 18 Dec 2024 21:27:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A7=81=E8=81=8A=E6=88=B3?= =?UTF-8?q?=E4=B8=80=E6=88=B3=E4=BA=8B=E4=BB=B6=E4=B8=8A=E6=8A=A5=20(#643)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot/api/friend.ts | 13 +++++++------ src/onebot/api/msg.ts | 2 +- src/onebot/event/notice/OB11PokeEvent.ts | 4 +++- 3 files changed, 11 insertions(+), 8 deletions(-) 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; } }