koishi-plugin-codec-tools 1.0.5 → 1.0.6
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 +8 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -9,15 +9,20 @@ const koishi_1 = require("koishi");
|
|
|
9
9
|
const jimp_1 = __importDefault(require("jimp"));
|
|
10
10
|
const jsqr_1 = __importDefault(require("jsqr"));
|
|
11
11
|
const library_1 = require("@zxing/library");
|
|
12
|
-
const
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
13
15
|
exports.name = 'codec-tools';
|
|
14
16
|
exports.using = ['i18n'];
|
|
15
17
|
exports.Config = koishi_1.Schema.object({})
|
|
16
18
|
.i18n({
|
|
17
|
-
'zh-CN':
|
|
19
|
+
'zh-CN': {},
|
|
18
20
|
});
|
|
19
21
|
function apply(ctx, config) {
|
|
20
|
-
|
|
22
|
+
const zhCNPath = path_1.default.join(__dirname, './locales/zh-CN.yml');
|
|
23
|
+
const zhCNContent = fs_1.default.readFileSync(zhCNPath, 'utf8');
|
|
24
|
+
const zhCN = yaml_1.default.parse(zhCNContent);
|
|
25
|
+
ctx.i18n.define('zh-CN', zhCN);
|
|
21
26
|
ctx.command('url-encode <text:text>')
|
|
22
27
|
.action((_, text) => encodeURIComponent(text));
|
|
23
28
|
ctx.command('url-decode <text:text>')
|