From 5fa2427c51b035fe47a287c51faa97f84ee0aa2f Mon Sep 17 00:00:00 2001 From: Alen <cnxysoft@126.com> Date: Wed, 24 Jul 2024 19:04:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9poke=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增poke事件支持上传raw信息 --- src/onebot11/constructor.ts | 16 ++++++++-------- src/onebot11/event/notice/OB11PokeEvent.ts | 10 ++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index addc4fb..dc3e159 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -321,11 +321,11 @@ export class OB11Constructor { if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) { //判断业务类型 //Poke事件 - let pokedetail: any[] = json.items; + const 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]))); + const poke_uid = pokedetail.filter(item => item.uid); + if (poke_uid.length == 2) { + return new OB11FriendPokeEvent(parseInt((uidMaps[poke_uid[0].uid])!), parseInt((uidMaps[poke_uid[1].uid])), pokedetail); } } //下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE @@ -526,11 +526,11 @@ export class OB11Constructor { if (grayTipElement.jsonGrayTipElement.busiId == 1061) { //判断业务类型 //Poke事件 - let pokedetail: any[] = json.items; + const pokedetail: any[] = json.items; //筛选item带有uid的元素 - pokedetail = pokedetail.filter(item => item.uid); - if (pokedetail.length == 2) { - return new OB11GroupPokeEvent(parseInt(msg.peerUid), parseInt((uidMaps[pokedetail[0].uid])!), parseInt((uidMaps[pokedetail[1].uid]))); + const poke_uid = pokedetail.filter(item => item.uid); + if (poke_uid.length == 2) { + return new OB11GroupPokeEvent(parseInt(msg.peerUid), parseInt((uidMaps[poke_uid[0].uid])!), parseInt((uidMaps[poke_uid[1].uid])), pokedetail); } } const memberUin = json.items[1].param[0] diff --git a/src/onebot11/event/notice/OB11PokeEvent.ts b/src/onebot11/event/notice/OB11PokeEvent.ts index 4811a35..4e6917f 100644 --- a/src/onebot11/event/notice/OB11PokeEvent.ts +++ b/src/onebot11/event/notice/OB11PokeEvent.ts @@ -5,25 +5,27 @@ import { OB11BaseEvent } from '../OB11BaseEvent' class OB11PokeEvent extends OB11BaseNoticeEvent { notice_type = 'notify' sub_type = 'poke' - target_id = parseInt(selfInfo.uin) + target_id = 0 user_id: number + raw_message: any } export class OB11FriendPokeEvent extends OB11PokeEvent { - constructor(user_id: number, target_id: number) { + constructor(user_id: number, target_id: number, raw_message: any) { super(); this.target_id = target_id; this.user_id = user_id; + this.raw_message = raw_message; } } export class OB11GroupPokeEvent extends OB11PokeEvent { group_id: number - - constructor(group_id: number, user_id: number = 0, target_id: number = 0) { + constructor(group_id: number, user_id: number = 0, target_id: number = 0, raw_message: any) { super() this.group_id = group_id this.target_id = target_id this.user_id = user_id + this.raw_message = raw_message } }