koishi-plugin-eula-regen 1.0.1 → 1.0.3
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.
- package/lib/index.js +22 -2
- package/package.json +3 -2
package/lib/index.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
// 动态导入 ES Module - 使用 Promise 缓存
|
|
4
|
+
let jsx_runtime_1_promise = import("@satorijs/element/jsx-runtime");
|
|
5
|
+
let jsx_runtime_1;
|
|
6
|
+
// 立即开始加载,并在加载完成后缓存
|
|
7
|
+
// ES Module 可能使用 default 导出或命名导出
|
|
8
|
+
jsx_runtime_1_promise.then(mod => {
|
|
9
|
+
// 处理可能的 default 导出
|
|
10
|
+
jsx_runtime_1 = mod.default || mod;
|
|
11
|
+
});
|
|
4
12
|
const koishi_1 = require("koishi");
|
|
5
13
|
const module_1 = require("module");
|
|
6
14
|
const path_1 = require("path");
|
|
@@ -46,10 +54,22 @@ class Eula extends koishi_1.Service {
|
|
|
46
54
|
.action((_) => this.eula(_));
|
|
47
55
|
}
|
|
48
56
|
async eula(argv) {
|
|
57
|
+
// 确保 jsx_runtime 已加载
|
|
58
|
+
if (!jsx_runtime_1) {
|
|
59
|
+
const mod = await jsx_runtime_1_promise;
|
|
60
|
+
jsx_runtime_1 = mod.default || mod;
|
|
61
|
+
}
|
|
49
62
|
const session = argv.session;
|
|
50
63
|
const userLocale = session.user.locale || session.user.locales[0] || 'zh';
|
|
51
64
|
const accept = koishi_1.Random.pick(this.configs.accept) ?? session.text('eula.defaultAccept');
|
|
52
|
-
|
|
65
|
+
// 确保 jsx 和 jsxs 函数存在
|
|
66
|
+
const jsx = jsx_runtime_1.jsx;
|
|
67
|
+
const jsxs = jsx_runtime_1.jsxs;
|
|
68
|
+
const Fragment = jsx_runtime_1.Fragment;
|
|
69
|
+
if (!jsx || !jsxs || !Fragment) {
|
|
70
|
+
throw new Error("jsx-runtime functions not available. Module keys: " + Object.keys(jsx_runtime_1).join(', '));
|
|
71
|
+
}
|
|
72
|
+
await session.send((0, jsxs)(Fragment, { children: [(0, jsx)("message", { id: "{0}", children: (0, jsx)("i18n", { path: "eula.eulaMessage.title", children: [this.configs.alias] }) }), (0, jsxs)("message", { forward: this.configs.forwardMessgae, children: [(0, jsx)("message", { id: "{0}", children: this.configs.content[userLocale] ?? this.configs.content['zh'] }), (0, jsx)("message", { id: "{0}", children: (0, jsx)("i18n", { path: "eula.eulaMessage.confirm", children: [accept] }) })] })] }));
|
|
53
73
|
const prompt = await session.prompt(this.configs.waitTime * 1000);
|
|
54
74
|
this.log.info(`[platfrom: ${session.platform}]user ${session.userId} reply to (${prompt}) eula`);
|
|
55
75
|
if (prompt) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-eula-regen",
|
|
3
3
|
"description": "EULA(End-user licence agreement) for your koishi bot.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"repository": "https://github.com/Lipraty/koishi-plugin-eula",
|
|
6
6
|
"author": "Lipraty <i@lonay.me>",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "tsc && cp -r src/locales lib/"
|
|
15
|
+
"build": "tsc && cp -r src/locales lib/ || true",
|
|
16
|
+
"postbuild": "node fix-jsx.mjs"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"@types/node": "^20.0.0",
|