fix: as design

This commit is contained in:
pk5ls20
2024-12-17 07:07:04 +08:00
parent a0c479485d
commit 2d9cc4d198
3 changed files with 18 additions and 14 deletions

View File

@@ -38,15 +38,13 @@ export interface AdapterConfig extends AdapterConfigInner {
const createDefaultAdapterConfig = <T extends AdapterConfig>(config: T): T => config; const createDefaultAdapterConfig = <T extends AdapterConfig>(config: T): T => config;
export const pluginDefaultConfigs = createDefaultAdapterConfig({ export interface PluginConfig extends AdapterConfig {
name: 'plugin', name: string;
messagePostFormat: 'array', enable: boolean;
reportSelfMessage: false, messagePostFormat: string;
enable: true, reportSelfMessage: boolean;
debug: false, debug: boolean;
}); }
export type PluginConfig = typeof pluginDefaultConfigs;
export const httpServerDefaultConfigs = createDefaultAdapterConfig({ export const httpServerDefaultConfigs = createDefaultAdapterConfig({
name: 'http-server', name: 'http-server',

View File

@@ -49,7 +49,6 @@ import {
migrateOneBotConfigsV1, migrateOneBotConfigsV1,
NetworkConfigAdapter, NetworkConfigAdapter,
OneBotConfig, OneBotConfig,
pluginDefaultConfigs
} from './config/config'; } from './config/config';
import { OB11Message } from './types'; import { OB11Message } from './types';
import { OB11PluginAdapter } from './network/plugin'; import { OB11PluginAdapter } from './network/plugin';
@@ -117,7 +116,7 @@ export class NapCatOneBot11Adapter {
// 注册Plugin 如果需要基于NapCat进行快速开发 // 注册Plugin 如果需要基于NapCat进行快速开发
// this.networkManager.registerAdapter( // this.networkManager.registerAdapter(
// new OB11PluginAdapter('myPlugin', pluginDefaultConfigs, this.core, this,this.actions) // new OB11PluginAdapter('myPlugin', this.core, this,this.actions)
// ); // );
for (const key of ob11Config.network.httpServers) { for (const key of ob11Config.network.httpServers) {
if (key.enable) { if (key.enable) {

View File

@@ -8,8 +8,15 @@ import { IOB11NetworkAdapter } from "@/onebot/network/adapter";
export class OB11PluginAdapter extends IOB11NetworkAdapter<PluginConfig> { export class OB11PluginAdapter extends IOB11NetworkAdapter<PluginConfig> {
constructor( constructor(
name: string, config: PluginConfig, core: NapCatCore, obContext: NapCatOneBot11Adapter, actions: ActionMap name: string, core: NapCatCore, obContext: NapCatOneBot11Adapter, actions: ActionMap
) { ) {
const config = {
name: name,
messagePostFormat: 'array',
reportSelfMessage: false,
enable: true,
debug: false,
};
super(name, config, core, obContext, actions); super(name, config, core, obContext, actions);
} }
@@ -20,11 +27,11 @@ export class OB11PluginAdapter extends IOB11NetworkAdapter<PluginConfig> {
} }
open() { open() {
this.isEnable = true;
} }
async close() { async close() {
this.isEnable = false;
} }
async reload() { async reload() {