From bdef80ede783f87b0251821a14aa0262e895b4bb Mon Sep 17 00:00:00 2001 From: Fripine Date: Thu, 1 Aug 2024 01:03:33 +0800 Subject: [PATCH] feat: support FriendAddNoticeEvent --- src/onebot11/constructor.ts | 9 ++++++++- src/onebot11/event/notice/OB11FriendAddNoticeEvent.ts | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/onebot11/event/notice/OB11FriendAddNoticeEvent.ts diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index e4eb0bac..1759250c 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -44,6 +44,7 @@ import { deleteGroup, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } import { NTQQFileApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from '@/core/apis'; import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmojiLikeEvent'; import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent'; +import { OB11FriendAddNoticeEvent } from './event/notice/OB11FriendAddNoticeEvent'; import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent'; import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent'; import { MessageUnique } from '@/common/utils/MessageUnique'; @@ -190,7 +191,7 @@ export class OB11Constructor { message_data['data']['file'] = FileElement.fileName; message_data['data']['path'] = FileElement.filePath; message_data['data']['url'] = FileElement.filePath; - message_data['data']['file_id'] = UUIDConverter.encode(msg.peerUin, msg.msgId); + message_data['data']['file_id'] = UUIDConverter.encode(msg.peerUin, msg.msgId); message_data['data']['file_size'] = FileElement.fileSize; await NTQQFileApi.addFileCache({ peerUid: msg.peerUid, @@ -353,6 +354,12 @@ export class OB11Constructor { } //下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE } + if (element.grayTipElement.subElementType == GrayTipElementSubType.INVITE_NEW_MEMBER) { + //好友添加成功事件 + if (element.grayTipElement.xmlElement.templId === '10229' && msg.peerUin !== '') { + return new OB11FriendAddNoticeEvent(parseInt(msg.peerUin)); + } + } } } } diff --git a/src/onebot11/event/notice/OB11FriendAddNoticeEvent.ts b/src/onebot11/event/notice/OB11FriendAddNoticeEvent.ts new file mode 100644 index 00000000..185b574f --- /dev/null +++ b/src/onebot11/event/notice/OB11FriendAddNoticeEvent.ts @@ -0,0 +1,11 @@ +import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent'; + +export class OB11FriendAddNoticeEvent extends OB11BaseNoticeEvent { + notice_type = 'friend_add'; + user_id: number; + + public constructor(user_Id: number) { + super(); + this.user_id = user_Id; + } +} \ No newline at end of file