koishi-plugin-rolecard 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 插件配置 Schema 定义。
3
+ *
4
+ * `types.ts` 中的 `Config` 接口是运行时配置的类型契约,
5
+ * 本文件则提供对应的 Koishi Schema 声明(默认值、校验、UI 描述),
6
+ * 二者共同构成配置层。后续提升配置复杂度与通用度时,集中在此维护。
7
+ */
8
+ import { Schema } from 'koishi';
9
+ import type { Config as ConfigType } from './types';
10
+ export declare const Config: Schema<ConfigType>;
package/lib/config.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * 插件配置 Schema 定义。
4
+ *
5
+ * `types.ts` 中的 `Config` 接口是运行时配置的类型契约,
6
+ * 本文件则提供对应的 Koishi Schema 声明(默认值、校验、UI 描述),
7
+ * 二者共同构成配置层。后续提升配置复杂度与通用度时,集中在此维护。
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Config = void 0;
11
+ const koishi_1 = require("koishi");
12
+ exports.Config = koishi_1.Schema.object({
13
+ rolecard: koishi_1.Schema.string()
14
+ .default('')
15
+ .description('要加载的角色卡 ID(留空则自动加载第一个找到的角色卡)。例如:belikov'),
16
+ cooldown: koishi_1.Schema.number()
17
+ .default(60)
18
+ .min(0)
19
+ .description('冷却时间(秒),同一频道内两次触发的最小间隔,防止刷屏'),
20
+ cooldownWhitelist: koishi_1.Schema.array(koishi_1.Schema.string())
21
+ .default([])
22
+ .description('冷却白名单:填入用户 ID,这些用户的消息不受冷却限制'),
23
+ disabledTags: koishi_1.Schema.array(koishi_1.Schema.string())
24
+ .default([])
25
+ .description('禁用的触发标签(留空表示全部启用)。例如填入 emotional 可关闭「情绪」类触发'),
26
+ enableRandom: koishi_1.Schema.boolean()
27
+ .default(true)
28
+ .description('启用全部消息概率随机触发(神预言效果)'),
29
+ randomProbability: koishi_1.Schema.number()
30
+ .default(3)
31
+ .min(0)
32
+ .max(100)
33
+ .description('随机触发概率(0-100,3 表示 3%)'),
34
+ enableImage: koishi_1.Schema.boolean().default(true).description('启用角色卡插图'),
35
+ imageWithMessage: koishi_1.Schema.boolean()
36
+ .default(true)
37
+ .description('将图片与文字一起发送(关闭则图片作为单独消息发送)'),
38
+ imageProbability: koishi_1.Schema.number()
39
+ .default(100)
40
+ .min(0)
41
+ .max(100)
42
+ .description('附带图片的概率(0-100,100 表示每次触发都发图)'),
43
+ respondIn: koishi_1.Schema.union([
44
+ koishi_1.Schema.const('group').description('仅群聊'),
45
+ koishi_1.Schema.const('private').description('仅私聊'),
46
+ koishi_1.Schema.const('both').description('群聊与私聊'),
47
+ ])
48
+ .default('group')
49
+ .description('响应范围'),
50
+ });
package/lib/index.d.ts CHANGED
@@ -3,18 +3,19 @@
3
3
  *
4
4
  * 架构概览:
5
5
  *
6
- * - `types.ts` 共享类型契约(角色卡内容 + 运行时配置)
7
- * - `loader.ts` 角色卡加载器(扫描并解析 rolecards/ 目录)
6
+ * - `types.ts` 共享类型契约(角色卡内容 + 运行时配置接口)
7
+ * - `config.ts` 配置 Schema 声明(默认值、校验、UI 描述)
8
+ * - `loader.ts` 角色卡加载器(扫描并解析 assets/ 目录)
8
9
  * - `core.ts` 核心引擎(通用台词引擎,与具体角色解耦)
9
- * - `index.ts` 本文件,组装三者并对接 Koishi 生命周期
10
+ * - `index.ts` 本文件,组装以上模块并对接 Koishi 生命周期
10
11
  *
11
- * 角色卡是纯数据资源,存放在 `rolecards/<id>/` 下。用户通过 Config.rolecard
12
+ * 角色卡是纯数据资源,存放在 `assets/<id>/` 下。用户通过 Config.rolecard
12
13
  * 选择要激活的角色卡。新增角色卡只需添加数据目录,无需改动任何源码。
13
14
  */
14
15
  import type { Context } from 'koishi';
15
- import { Schema } from 'koishi';
16
+ import { Config } from './config';
16
17
  import type { Config as ConfigType } from './types';
17
18
  export declare const name = "rolecard";
18
- export declare const usage = "\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #4a6ee0;\">\uD83C\uDFAD \u89D2\u8272\u5361\u63D2\u4EF6 \u00B7 Rolecard</h2>\n <p>\u6570\u636E\u9A71\u52A8\u7684\u89D2\u8272\u53F0\u8BCD\u5F15\u64CE\u3002\u6838\u5FC3\u903B\u8F91\u4E0E\u89D2\u8272\u5361\u5185\u5BB9\u5B8C\u5168\u89E3\u8026\u2014\u2014\u89D2\u8272\u5361\u662F\u7EAF\u6570\u636E\u8D44\u6E90\uFF08\u53F0\u8BCD\u5E93 + \u89E6\u53D1\u8BCD + \u63D2\u56FE\uFF09\uFF0C\u5F15\u64CE\u6839\u636E\u6570\u636E\u81EA\u52A8\u9A71\u52A8\u5BF9\u8BDD\u3002</p>\n <ul>\n <li>\u5728 <code>rolecards/</code> \u76EE\u5F55\u4E0B\u653E\u7F6E\u89D2\u8272\u5361\uFF0C\u6BCF\u4E2A\u89D2\u8272\u5361\u4E00\u4E2A\u5B50\u76EE\u5F55</li>\n <li>\u901A\u8FC7\u914D\u7F6E\u9879 <code>rolecard</code> \u9009\u62E9\u8981\u52A0\u8F7D\u7684\u89D2\u8272\u5361 ID</li>\n <li>\u652F\u6301\u5173\u952E\u8BCD\u89E6\u53D1\uFF08\u6309\u4F18\u5148\u7EA7\uFF09\u4E0E\u6982\u7387\u968F\u673A\u89E6\u53D1</li>\n <li>\u51B7\u5374\u9632\u5237\u5C4F\u3001\u63D2\u56FE\u53D1\u9001\u3001\u54CD\u5E94\u8303\u56F4\u5747\u53EF\u914D\u7F6E</li>\n </ul>\n</div>\n";
19
- export declare const Config: Schema<ConfigType>;
19
+ export declare const usage = "\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #4a6ee0;\">\uD83C\uDFAD \u89D2\u8272\u5361\u63D2\u4EF6 \u00B7 Rolecard</h2>\n <p>\u6570\u636E\u9A71\u52A8\u7684\u89D2\u8272\u53F0\u8BCD\u5F15\u64CE\u3002\u6838\u5FC3\u903B\u8F91\u4E0E\u89D2\u8272\u5361\u5185\u5BB9\u5B8C\u5168\u89E3\u8026\u2014\u2014\u89D2\u8272\u5361\u662F\u7EAF\u6570\u636E\u8D44\u6E90\uFF08\u53F0\u8BCD\u5E93 + \u89E6\u53D1\u8BCD + \u63D2\u56FE\uFF09\uFF0C\u5F15\u64CE\u6839\u636E\u6570\u636E\u81EA\u52A8\u9A71\u52A8\u5BF9\u8BDD\u3002</p>\n <ul>\n <li>\u5728 <code>assets/</code> \u76EE\u5F55\u4E0B\u653E\u7F6E\u89D2\u8272\u5361\uFF0C\u6BCF\u4E2A\u89D2\u8272\u5361\u4E00\u4E2A\u5B50\u76EE\u5F55</li>\n <li>\u901A\u8FC7\u914D\u7F6E\u9879 <code>rolecard</code> \u9009\u62E9\u8981\u52A0\u8F7D\u7684\u89D2\u8272\u5361 ID</li>\n <li>\u652F\u6301\u5173\u952E\u8BCD\u89E6\u53D1\uFF08\u6309\u4F18\u5148\u7EA7\uFF09\u4E0E\u6982\u7387\u968F\u673A\u89E6\u53D1</li>\n <li>\u51B7\u5374\u9632\u5237\u5C4F\u3001\u63D2\u56FE\u53D1\u9001\u3001\u54CD\u5E94\u8303\u56F4\u5747\u53EF\u914D\u7F6E</li>\n </ul>\n</div>\n\n<div style=\"border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);\">\n <h2 style=\"margin-top: 0; color: #4a6ee0;\">\uD83D\uDCAC \u4EA4\u6D41\u4E0E\u53CD\u9988</h2>\n <p>\uD83C\uDF1F \u559C\u6B22\u8FD9\u4E2A\u63D2\u4EF6\uFF1F\u6B22\u8FCE\u52A0\u5165 QQ \u7FA4 <a href=\"https://qm.qq.com/q/WngX4RQoca\" style=\"color:#4a6ee0;text-decoration:none;\"><strong>1071284605</strong></a>\u3010\u6653\u57FA\u5730\u63D2\u4EF6\u5DE5\u574A\u3011\u8FDB\u884C\u4EA4\u6D41</p>\n <p>\uD83D\uDC1B \u9047\u5230\u95EE\u9898\uFF1F\u6B22\u8FCE\u5728\u7FA4\u5185\u53CD\u9988\uFF0C\u6216\u70B9\u51FB <a href=\"https://qm.qq.com/q/WngX4RQoca\" style=\"color:#4a6ee0;text-decoration:none;\">\u6B64\u94FE\u63A5</a> \u52A0\u5165\u7FA4\u804A</p>\n</div>\n";
20
+ export { Config };
20
21
  export declare function apply(ctx: Context, config: ConfigType): void;
package/lib/index.js CHANGED
@@ -4,19 +4,21 @@
4
4
  *
5
5
  * 架构概览:
6
6
  *
7
- * - `types.ts` 共享类型契约(角色卡内容 + 运行时配置)
8
- * - `loader.ts` 角色卡加载器(扫描并解析 rolecards/ 目录)
7
+ * - `types.ts` 共享类型契约(角色卡内容 + 运行时配置接口)
8
+ * - `config.ts` 配置 Schema 声明(默认值、校验、UI 描述)
9
+ * - `loader.ts` 角色卡加载器(扫描并解析 assets/ 目录)
9
10
  * - `core.ts` 核心引擎(通用台词引擎,与具体角色解耦)
10
- * - `index.ts` 本文件,组装三者并对接 Koishi 生命周期
11
+ * - `index.ts` 本文件,组装以上模块并对接 Koishi 生命周期
11
12
  *
12
- * 角色卡是纯数据资源,存放在 `rolecards/<id>/` 下。用户通过 Config.rolecard
13
+ * 角色卡是纯数据资源,存放在 `assets/<id>/` 下。用户通过 Config.rolecard
13
14
  * 选择要激活的角色卡。新增角色卡只需添加数据目录,无需改动任何源码。
14
15
  */
15
16
  Object.defineProperty(exports, "__esModule", { value: true });
16
17
  exports.Config = exports.usage = exports.name = void 0;
17
18
  exports.apply = apply;
18
19
  const node_path_1 = require("node:path");
19
- const koishi_1 = require("koishi");
20
+ const config_1 = require("./config");
21
+ Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
20
22
  const core_1 = require("./core");
21
23
  const loader_1 = require("./loader");
22
24
  exports.name = 'rolecard';
@@ -25,59 +27,26 @@ exports.usage = `
25
27
  <h2 style="margin-top: 0; color: #4a6ee0;">🎭 角色卡插件 · Rolecard</h2>
26
28
  <p>数据驱动的角色台词引擎。核心逻辑与角色卡内容完全解耦——角色卡是纯数据资源(台词库 + 触发词 + 插图),引擎根据数据自动驱动对话。</p>
27
29
  <ul>
28
- <li>在 <code>rolecards/</code> 目录下放置角色卡,每个角色卡一个子目录</li>
30
+ <li>在 <code>assets/</code> 目录下放置角色卡,每个角色卡一个子目录</li>
29
31
  <li>通过配置项 <code>rolecard</code> 选择要加载的角色卡 ID</li>
30
32
  <li>支持关键词触发(按优先级)与概率随机触发</li>
31
33
  <li>冷却防刷屏、插图发送、响应范围均可配置</li>
32
34
  </ul>
33
35
  </div>
36
+
37
+ <div style="border-radius: 10px; border: 1px solid #ddd; padding: 16px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
38
+ <h2 style="margin-top: 0; color: #4a6ee0;">💬 交流与反馈</h2>
39
+ <p>🌟 喜欢这个插件?欢迎加入 QQ 群 <a href="https://qm.qq.com/q/WngX4RQoca" style="color:#4a6ee0;text-decoration:none;"><strong>1071284605</strong></a>【晓基地插件工坊】进行交流</p>
40
+ <p>🐛 遇到问题?欢迎在群内反馈,或点击 <a href="https://qm.qq.com/q/WngX4RQoca" style="color:#4a6ee0;text-decoration:none;">此链接</a> 加入群聊</p>
41
+ </div>
34
42
  `;
35
- exports.Config = koishi_1.Schema.object({
36
- rolecard: koishi_1.Schema.string()
37
- .default('')
38
- .description('要加载的角色卡 ID(留空则自动加载第一个找到的角色卡)。例如:belikov'),
39
- cooldown: koishi_1.Schema.number()
40
- .default(60)
41
- .min(0)
42
- .description('冷却时间(秒),同一频道内两次触发的最小间隔,防止刷屏'),
43
- cooldownWhitelist: koishi_1.Schema.array(koishi_1.Schema.string())
44
- .default([])
45
- .description('冷却白名单:填入用户 ID,这些用户的消息不受冷却限制'),
46
- disabledTags: koishi_1.Schema.array(koishi_1.Schema.string())
47
- .default([])
48
- .description('禁用的触发标签(留空表示全部启用)。例如填入 emotional 可关闭「情绪」类触发'),
49
- enableRandom: koishi_1.Schema.boolean()
50
- .default(true)
51
- .description('启用全部消息概率随机触发(神预言效果)'),
52
- randomProbability: koishi_1.Schema.number()
53
- .default(3)
54
- .min(0)
55
- .max(100)
56
- .description('随机触发概率(0-100,3 表示 3%)'),
57
- enableImage: koishi_1.Schema.boolean().default(true).description('启用角色卡插图'),
58
- imageWithMessage: koishi_1.Schema.boolean()
59
- .default(true)
60
- .description('将图片与文字一起发送(关闭则图片作为单独消息发送)'),
61
- imageProbability: koishi_1.Schema.number()
62
- .default(100)
63
- .min(0)
64
- .max(100)
65
- .description('附带图片的概率(0-100,100 表示每次触发都发图)'),
66
- respondIn: koishi_1.Schema.union([
67
- koishi_1.Schema.const('group').description('仅群聊'),
68
- koishi_1.Schema.const('private').description('仅私聊'),
69
- koishi_1.Schema.const('both').description('群聊与私聊'),
70
- ])
71
- .default('group')
72
- .description('响应范围'),
73
- });
74
43
  function apply(ctx, config) {
75
44
  const logger = ctx.logger('rolecard');
76
- // 角色卡目录位于插件包根目录下的 rolecards/
77
- const rolecardsDir = (0, node_path_1.resolve)(__dirname, '..', 'rolecards');
78
- const rolecards = (0, loader_1.loadRolecards)(rolecardsDir);
45
+ // 角色卡目录位于插件包根目录下的 assets/
46
+ const assetsDir = (0, node_path_1.resolve)(__dirname, '..', 'assets');
47
+ const rolecards = (0, loader_1.loadRolecards)(assetsDir);
79
48
  if (rolecards.length === 0) {
80
- logger.warn('未找到任何角色卡,请检查 rolecards 目录');
49
+ logger.warn('未找到任何角色卡,请检查 assets 目录');
81
50
  return;
82
51
  }
83
52
  const availableIds = rolecards.map((r) => r.manifest.id).join(', ');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-rolecard",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "contributors": [
5
5
  "Oppenheymu <oppenheymu@gmail.com>"
6
6
  ],
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "files": [
18
18
  "lib",
19
- "rolecards"
19
+ "assets"
20
20
  ],
21
21
  "license": "MIT",
22
22
  "publishConfig": {
File without changes
File without changes
File without changes