mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-04 06:31:13 +00:00
Added the new napcat-protocol package with protocol config, event, API, and network management modules. Introduced napcat-adapter package to unify protocol adapter management, replacing direct OneBot usage in framework and shell. Updated napcat-framework and napcat-shell to use NapCatAdapterManager for protocol initialization and registration. Adjusted dependencies and Vite configs to include new packages.
67 lines
1.7 KiB
TypeScript
67 lines
1.7 KiB
TypeScript
import { NapCatCore } from 'napcat-core';
|
|
|
|
// NapCat Protocol 事件基类
|
|
export abstract class NapCatProtocolEvent {
|
|
protected core: NapCatCore;
|
|
public time: number;
|
|
public self_id: number;
|
|
public post_type: string;
|
|
|
|
constructor (core: NapCatCore) {
|
|
this.core = core;
|
|
this.time = Math.floor(Date.now() / 1000);
|
|
this.self_id = parseInt(core.selfInfo.uin);
|
|
this.post_type = 'event';
|
|
}
|
|
|
|
abstract toJSON (): Record<string, unknown>;
|
|
}
|
|
|
|
// 消息事件基类
|
|
export abstract class NapCatProtocolMessageEvent extends NapCatProtocolEvent {
|
|
public message_type: 'private' | 'group';
|
|
public message_id: number;
|
|
public user_id: number;
|
|
|
|
constructor (core: NapCatCore, messageType: 'private' | 'group', messageId: number, userId: number) {
|
|
super(core);
|
|
this.post_type = 'message';
|
|
this.message_type = messageType;
|
|
this.message_id = messageId;
|
|
this.user_id = userId;
|
|
}
|
|
}
|
|
|
|
// 通知事件基类
|
|
export abstract class NapCatProtocolNoticeEvent extends NapCatProtocolEvent {
|
|
public notice_type: string;
|
|
|
|
constructor (core: NapCatCore, noticeType: string) {
|
|
super(core);
|
|
this.post_type = 'notice';
|
|
this.notice_type = noticeType;
|
|
}
|
|
}
|
|
|
|
// 请求事件基类
|
|
export abstract class NapCatProtocolRequestEvent extends NapCatProtocolEvent {
|
|
public request_type: string;
|
|
|
|
constructor (core: NapCatCore, requestType: string) {
|
|
super(core);
|
|
this.post_type = 'request';
|
|
this.request_type = requestType;
|
|
}
|
|
}
|
|
|
|
// 元事件基类
|
|
export abstract class NapCatProtocolMetaEvent extends NapCatProtocolEvent {
|
|
public meta_event_type: string;
|
|
|
|
constructor (core: NapCatCore, metaEventType: string) {
|
|
super(core);
|
|
this.post_type = 'meta_event';
|
|
this.meta_event_type = metaEventType;
|
|
}
|
|
}
|