diff --git a/src/core/plugin/index.ts b/src/core/plugin/index.ts index 1a67f00e..bd8bd870 100644 --- a/src/core/plugin/index.ts +++ b/src/core/plugin/index.ts @@ -1,10 +1,10 @@ -import { OB11Message } from "@/onebot"; +import { NapCatOneBot11Adapter, OB11Message } from "@/onebot"; +import SendGroupMsg from "@/onebot/action/group/SendGroupMsg"; import { NapCatCore } from ".."; -import { ActionMap } from "@/onebot/action"; -export const plugin_onmessage = async (adapter: string, core: NapCatCore, action: ActionMap, message: OB11Message) => { +export const plugin_onmessage = async (adapter: string, core: NapCatCore, obCore: NapCatOneBot11Adapter, message: OB11Message) => { if (message.raw_message === 'ping') { - const ret = await action.get('send_group_msg')?.handle({ group_id: message.group_id, message: 'pong' }, adapter); + const ret = await new SendGroupMsg(obCore, core).handle({ group_id: String(message.group_id), message: 'pong' }, adapter); console.log(ret); } } \ No newline at end of file diff --git a/src/onebot/index.ts b/src/onebot/index.ts index cb64fa6e..029660b8 100644 --- a/src/onebot/index.ts +++ b/src/onebot/index.ts @@ -111,7 +111,7 @@ export class NapCatOneBot11Adapter { // 注册Plugin this.networkManager.registerAdapter( - new OB11PluginAdapter('plugin', this.core, this.actions) + new OB11PluginAdapter('plugin', this.core, this,this.actions) ); for (const key of ob11Config.network.httpServers) { if (key.enable) { diff --git a/src/onebot/network/plugin.ts b/src/onebot/network/plugin.ts index 1c2c8134..d16747c7 100644 --- a/src/onebot/network/plugin.ts +++ b/src/onebot/network/plugin.ts @@ -1,5 +1,5 @@ import { IOB11NetworkAdapter, OB11EmitEventContent, OB11NetworkReloadType } from './index'; -import { OB11Message } from '@/onebot'; +import { NapCatOneBot11Adapter, OB11Message } from '@/onebot'; import { NapCatCore } from '@/core'; import { ActionMap } from '../action'; import { AdapterConfig } from '../config/config'; @@ -12,6 +12,7 @@ export class OB11PluginAdapter implements IOB11NetworkAdapter { constructor( public name: string, public core: NapCatCore, + public obCore: NapCatOneBot11Adapter, public actions: ActionMap, ) { // 基础配置 @@ -26,7 +27,7 @@ export class OB11PluginAdapter implements IOB11NetworkAdapter { onEvent(event: T) { if (event.post_type === 'message') { - plugin_onmessage(this.config.name, this.core, this.actions, event as OB11Message).then().catch(); + plugin_onmessage(this.config.name, this.core, this.obCore, event as OB11Message).then().catch(); } }