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.
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { NetworkAdapterConfig } from '@/napcat-protocol/config/config';
|
|
import { LogWrapper } from 'napcat-core/helper/log';
|
|
import { NapCatCore } from 'napcat-core';
|
|
import { NapCatProtocolAdapter } from '@/napcat-protocol/index';
|
|
import { ActionMap } from '@/napcat-protocol/action';
|
|
import { NapCatProtocolEmitEventContent, NapCatProtocolNetworkReloadType } from '@/napcat-protocol/network/index';
|
|
|
|
export abstract class INapCatProtocolNetworkAdapter<CT extends NetworkAdapterConfig> {
|
|
name: string;
|
|
isEnable: boolean = false;
|
|
config: CT;
|
|
readonly logger: LogWrapper;
|
|
readonly core: NapCatCore;
|
|
readonly protocolContext: NapCatProtocolAdapter;
|
|
readonly actions: ActionMap;
|
|
|
|
constructor (name: string, config: CT, core: NapCatCore, protocolContext: NapCatProtocolAdapter, actions: ActionMap) {
|
|
this.name = name;
|
|
this.config = structuredClone(config);
|
|
this.core = core;
|
|
this.protocolContext = protocolContext;
|
|
this.actions = actions;
|
|
this.logger = core.context.logger;
|
|
}
|
|
|
|
abstract onEvent<T extends NapCatProtocolEmitEventContent> (event: T): Promise<void>;
|
|
|
|
abstract open (): void | Promise<void>;
|
|
|
|
abstract close (): void | Promise<void>;
|
|
|
|
abstract reload (config: unknown): NapCatProtocolNetworkReloadType | Promise<NapCatProtocolNetworkReloadType>;
|
|
|
|
get isActive (): boolean {
|
|
return this.isEnable;
|
|
}
|
|
}
|