Merge pull request #8 from Fripine/feat/add_FriendAddNoticeEvent

feat: add FriendAddNoticeEvent
This commit is contained in:
手瓜一十雪 2024-04-25 10:27:01 +08:00 committed by GitHub
commit 39373ee63a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import { OB11GroupIncreaseEvent } from './event/notice/OB11GroupIncreaseEvent';
import { OB11GroupBanEvent } from './event/notice/OB11GroupBanEvent';
import { OB11GroupUploadNoticeEvent } from './event/notice/OB11GroupUploadNoticeEvent';
import { OB11GroupNoticeEvent } from './event/notice/OB11GroupNoticeEvent';
import { OB11FriendAddNoticeEvent } from './event/notice/OB11FriendAddNoticeEvent';
import { calcQQLevel } from '../common/utils/qqlevel';
import { log } from '../common/utils/log';
@ -371,6 +372,17 @@ 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 friend(friend: User): OB11User {
return {
user_id: parseInt(friend.uin),

View File

@ -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;
}
}

View File

@ -154,6 +154,11 @@ export class NapCatOnebot11 {
postOB11Event(groupEvent);
}
}).catch(e => log('constructGroupEvent error: ', e));
OB11Constructor.FriendAddEvent(message).then(friendAddEvent=>{
if(friendAddEvent){
postOB11Event(friendAddEvent)
}
}).catch(e => log('constructFriendAddEvent error: ', e));
}
}