diff --git a/packages/napcat-plugin-builtin/index.ts b/packages/napcat-plugin-builtin/index.ts
index 0652a277..4aa59117 100644
--- a/packages/napcat-plugin-builtin/index.ts
+++ b/packages/napcat-plugin-builtin/index.ts
@@ -6,8 +6,6 @@ import type { OB11Message, OB11PostSendMsg } from 'napcat-types/napcat-onebot/ty
import fs from 'fs';
import path from 'path';
import type { PluginConfigSchema } from 'napcat-types/napcat-onebot/network/plugin-manger';
-
-let actions: ActionMap | undefined = undefined;
let startTime: number = Date.now();
interface BuiltinPluginConfig {
@@ -28,33 +26,26 @@ let currentConfig: BuiltinPluginConfig = {
export let plugin_config_ui: PluginConfigSchema = [];
-/**
- * 插件初始化
- */
/**
* 插件初始化
*/
const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
console.log('[Plugin: builtin] NapCat 内置插件已初始化');
- actions = ctx.actions;
- // platformInstance = _instance; // No longer valid or needed like this
-
- const NapCatConfig = ctx.NapCatConfig;
- plugin_config_ui = NapCatConfig.combine(
- NapCatConfig.html('
👋 Welcome to NapCat Builtin Plugin
This is a demonstration of the plugin configuration interface.
'),
- NapCatConfig.text('prefix', 'Command Prefix', '#napcat', 'The prefix to trigger the version info command'),
- NapCatConfig.boolean('enableReply', 'Enable Reply', true, 'Switch to enable or disable the reply functionality'),
- NapCatConfig.select('theme', 'Theme Selection', [
+ plugin_config_ui = ctx.NapCatConfig.combine(
+ ctx.NapCatConfig.html('👋 Welcome to NapCat Builtin Plugin
This is a demonstration of the plugin configuration interface.
'),
+ ctx.NapCatConfig.text('prefix', 'Command Prefix', '#napcat', 'The prefix to trigger the version info command'),
+ ctx.NapCatConfig.boolean('enableReply', 'Enable Reply', true, 'Switch to enable or disable the reply functionality'),
+ ctx.NapCatConfig.select('theme', 'Theme Selection', [
{ label: 'Light Mode', value: 'light' },
{ label: 'Dark Mode', value: 'dark' },
{ label: 'Auto', value: 'auto' }
], 'light', 'Select a theme for the response (Demo purpose only)'),
- NapCatConfig.multiSelect('features', 'Enabled Features', [
+ ctx.NapCatConfig.multiSelect('features', 'Enabled Features', [
{ label: 'Version Info', value: 'version' },
{ label: 'Status Report', value: 'status' },
{ label: 'Debug Log', value: 'debug' }
], ['version'], 'Select features to enable'),
- NapCatConfig.text('description', 'Description', '这是一个内置插件的配置示例', 'A multi-line text area for notes')
+ ctx.NapCatConfig.text('description', 'Description', '这是一个内置插件的配置示例', 'A multi-line text area for notes')
);
// Try to load config
@@ -107,11 +98,11 @@ const plugin_onmessage: PluginModule['plugin_onmessage'] = async (_ctx, event) =
}
try {
- const versionInfo = await getVersionInfo('ob11', {});
+ const versionInfo = await getVersionInfo(_ctx.actions, _ctx.adapterName, {});
if (!versionInfo) return;
const message = formatVersionMessage(versionInfo);
- await sendMessage(event, message, 'ob11', {});
+ await sendMessage(_ctx.actions, event, message, _ctx.adapterName, {});
console.log('[Plugin: builtin] 已回复版本信息');
} catch (error) {
@@ -122,7 +113,7 @@ const plugin_onmessage: PluginModule['plugin_onmessage'] = async (_ctx, event) =
/**
* 获取版本信息(完美的类型推导,无需 as 断言)
*/
-async function getVersionInfo (adapter: string, config: any) {
+async function getVersionInfo (actions: ActionMap, adapter: string, config: any) {
if (!actions) return null;
try {
@@ -169,9 +160,7 @@ function formatVersionMessage (info: { appName: string; appVersion: string; prot
/**
* 发送消息(完美的类型推导)
*/
-async function sendMessage (event: OB11Message, message: string, adapter: string, config: any) {
- if (!actions) return;
-
+async function sendMessage (actions: ActionMap, event: OB11Message, message: string, adapter: string, config: any) {
const params: OB11PostSendMsg = {
message,
message_type: event.message_type,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 78bd2bdb..7040067a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -210,21 +210,11 @@ importers:
specifier: ^1.6.7
version: 1.6.7
- packages/napcat-plugin:
- dependencies:
- napcat-types:
- specifier: workspace:*
- version: link:../napcat-types
- devDependencies:
- '@types/node':
- specifier: ^22.0.1
- version: 22.19.1
-
packages/napcat-plugin-builtin:
dependencies:
napcat-types:
- specifier: 0.0.7
- version: 0.0.7
+ specifier: 0.0.8
+ version: 0.0.8
devDependencies:
'@types/node':
specifier: ^22.0.1
@@ -5448,8 +5438,8 @@ packages:
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
- napcat-types@0.0.7:
- resolution: {integrity: sha512-PIDaQ6YnTxxpC1yb+VIDsQDamV6Ry+fUhHUBCXUVSzj1outisf6jSKFr2O7c9wX9zdX6Pi6NaVECNRy0ob4dmg==}
+ napcat-types@0.0.8:
+ resolution: {integrity: sha512-QxpYmAWr44tGimWmA6Az+eODlSOU3H2cJ9QzHvC09eaEwLvP6BpD0TApdWFYkzNBFFiHVLXv6lqdCAyAV3RAPg==}
napcat.protobuf@1.1.4:
resolution: {integrity: sha512-z7XtLSBJ/PxmYb0VD/w+eYr/X3LyGz+SZ2QejFTOczwt6zWNxy2yV1mTMTvJoc3BWkI3ESVFRxkuT6+pj1tb1Q==}
@@ -12819,7 +12809,7 @@ snapshots:
nanoid@3.3.11: {}
- napcat-types@0.0.7:
+ napcat-types@0.0.8:
dependencies:
'@sinclair/typebox': 0.34.41
'@types/cors': 2.8.19