build: OB11InputStatusEvent

This commit is contained in:
手瓜一十雪 2024-08-06 23:39:22 +08:00
parent 85a8cef628
commit 667dba01ae
3 changed files with 33 additions and 1 deletions

View File

@ -2,5 +2,5 @@ import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
export class OB11GroupAdminNoticeEvent extends OB11GroupNoticeEvent {
notice_type = 'group_admin';
sub_type: 'set' | 'unset'; // "set" | "unset"
sub_type: 'set' | 'unset' = "set"; // "set" | "unset"
}

View File

@ -0,0 +1,16 @@
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
export class OB11InputStatusEvent extends OB11BaseNoticeEvent {
notice_type = 'notify';
sub_type = 'input_status';
status_text = "对方正在输入..."
eventType = 1;
user_id = 0;
constructor(user_id: number, eventType: number, status_text: string) {
super();
this.user_id = user_id;
this.eventType = eventType;
this.status_text = status_text;
}
}

View File

@ -33,6 +33,7 @@ import { logMessage, logNotice, logRequest } from '@/onebot11/log';
import { OB11Message } from '@/onebot11/types';
import { isEqual } from '@/common/utils/helper';
import { MessageUnique } from '@/common/utils/MessageUnique';
import { OB11InputStatusEvent } from './event/notice/OB11InputStatusEvent';
//下面几个其实应该移进Core-Data 缓存实现 但是现在在这里方便
//
@ -92,6 +93,21 @@ export class NapCatOnebot11 {
}
// Create MsgListener
const msgListener = new MsgListener();
msgListener.onInputStatusPush = async (data: {
chatType: number;
eventType: number;
fromUin: string;
interval: string;
showTime: string;
statusText: string;
timestamp: string;
toUin: string;
}
) => {
let uin = await NTQQUserApi.getUinByUid(data.fromUin);
logNotice(`[输入状态] ${uin} ${data.statusText}`);
postOB11Event(new OB11InputStatusEvent(parseInt(uin), data.eventType, data.statusText));
}
msgListener.onRecvSysMsg = async (protobufData: number[]) => {
// function buf2hex(buffer: Buffer) {
// return [...new Uint8Array(buffer)]