feat: plugin

This commit is contained in:
手瓜一十雪
2024-12-11 17:07:21 +08:00
parent 2cef6983c5
commit 9338d86d2a
5 changed files with 77 additions and 7 deletions

View File

@@ -0,0 +1,44 @@
import { IOB11NetworkAdapter, OB11EmitEventContent, OB11NetworkReloadType } from './index';
import { OB11Message } from '@/onebot';
import { NapCatCore } from '@/core';
import { ActionMap } from '../action';
import { AdapterConfig } from '../config/config';
import { plugin_onmessage } from '@/core/plugin';
export class OB11PluginAdapter implements IOB11NetworkAdapter {
isEnable: boolean = true;
public config: AdapterConfig;
constructor(
public name: string,
public core: NapCatCore,
public actions: ActionMap,
) {
// 基础配置
this.config = {
name: name,
messagePostFormat: 'array',
reportSelfMessage: false,
enable: true,
debug: false,
}
}
onEvent<T extends OB11EmitEventContent>(event: T) {
if (event.post_type === 'message') {
plugin_onmessage(this.config.name, this.core, this.actions, event as OB11Message).then().catch();
}
}
open() {
}
async close() {
}
async reload() {
return OB11NetworkReloadType.Normal;
}
}