Add plugin manager and example plugin system

Introduces a plugin manager (OB11PluginMangerAdapter) for dynamic plugin loading, initialization, and event handling. Adds an example plugin with configuration files and updates related code to support plugin directory detection and loading. Refactors plugin adapter logic for extensibility and modularity.
This commit is contained in:
手瓜一十雪 committed 2025-09-02 20:42:54 +08:00
1 parent dc87615bd6
commit c7af0384fb
9 files changed
+891 -10

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
import { EventType } from "../onebot/event/OneBotEvent";
import type { PluginModule } from "../onebot/network/plugin-manger";
const plugin_init: PluginModule["plugin_init"] = async (_core, _obContext, _actions, _instance) => {
console.log(`[Plugin: example] 插件已初始化`);
}
const plugin_onmessage: PluginModule["plugin_onmessage"] = async (adapter, _core, _obCtx, event, actions, instance) => {
if (event.post_type === EventType.MESSAGE && event.raw_message.includes('ping')) {
await actions.get('send_group_msg')?.handle({ group_id: String(event.group_id), message: 'pong' }, adapter, instance.config);
}
}
export { plugin_init, plugin_onmessage };