mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-12 16:00:27 +00:00
feat: plugin
This commit is contained in:
44
src/onebot/network/plugin.ts
Normal file
44
src/onebot/network/plugin.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user