feat: 注入OneBot上下文

This commit is contained in:
手瓜一十雪
2024-08-09 21:54:14 +08:00
parent af01a073ef
commit 8a93f04266
2 changed files with 85 additions and 82 deletions

View File

@@ -3,15 +3,17 @@ import { OB11Response } from './OB11Response';
import { OB11Return } from '@/onebot/types';
import Ajv, { ErrorObject, ValidateFunction } from 'ajv';
import { NapCatCore } from '@/core';
import { NapCatOneBot11Adapter } from '../main';
class BaseAction<PayloadType, ReturnDataType> {
actionName: ActionName = ActionName.Unknown;
CoreContext: NapCatCore;
private validate: undefined | ValidateFunction<any> = undefined;
PayloadSchema: any = undefined;
constructor(context: NapCatCore) {
//注入上下文
this.CoreContext = context;
OneBotContext: NapCatOneBot11Adapter;
constructor(onebotContext:NapCatOneBot11Adapter,coreContext: NapCatCore) {
this.OneBotContext = onebotContext;
this.CoreContext = coreContext;
}
protected async check(payload: PayloadType): Promise<BaseCheckResult> {
if (this.PayloadSchema) {