@kotori-bot/core 1.4.1 → 1.5.0
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/components/config.js +109 -35
- package/lib/components/core.d.ts +2 -0
- package/lib/components/core.js +842 -30
- package/lib/components/index.js +858 -17
- package/lib/components/message.d.ts +9 -2
- package/lib/components/message.js +832 -125
- package/lib/global/constants.js +66 -17
- package/lib/global/index.js +81 -16
- package/lib/global/symbols.d.ts +2 -0
- package/lib/global/symbols.js +50 -11
- package/lib/index.js +871 -35
- package/lib/service/adapter.d.ts +2 -5
- package/lib/service/adapter.js +826 -125
- package/lib/service/api.js +81 -44
- package/lib/service/cache.js +68 -33
- package/lib/service/elements.js +74 -38
- package/lib/service/index.js +850 -19
- package/lib/types/adapter.js +28 -1
- package/lib/types/config.js +28 -1
- package/lib/types/index.js +73 -17
- package/lib/types/message.d.ts +19 -6
- package/lib/types/message.js +70 -14
- package/lib/utils/command.d.ts +18 -10
- package/lib/utils/command.js +253 -204
- package/lib/utils/commandError.js +75 -12
- package/lib/utils/container.js +60 -20
- package/lib/utils/error.js +68 -28
- package/lib/utils/factory.d.ts +11 -3
- package/lib/utils/factory.js +846 -36
- package/lib/utils/jsxFactory.js +28 -1
- package/package.json +5 -7
- package/lib/components/modules.d.ts +0 -12
- package/lib/components/modules.js +0 -127
- package/lib/constants.d.ts +0 -15
- package/lib/constants.js +0 -19
- package/lib/consts.d.ts +0 -15
- package/lib/consts.js +0 -19
- package/lib/context/context.d.ts +0 -36
- package/lib/context/context.js +0 -115
- package/lib/context/events.d.ts +0 -18
- package/lib/context/events.js +0 -2
- package/lib/context/index.d.ts +0 -5
- package/lib/context/index.js +0 -21
- package/lib/context/modules.d.ts +0 -39
- package/lib/context/modules.js +0 -65
- package/lib/context/service.d.ts +0 -16
- package/lib/context/service.js +0 -22
- package/lib/context/symbols.d.ts +0 -12
- package/lib/context/symbols.js +0 -18
- package/lib/context/test.d.ts +0 -6
- package/lib/context/test.js +0 -12
- package/lib/global/tokens.d.ts +0 -8
- package/lib/global/tokens.js +0 -12
- package/lib/service/service.d.ts +0 -16
- package/lib/service/service.js +0 -22
- package/lib/types/core.d.ts +0 -7
- package/lib/types/core.js +0 -2
- package/lib/types/modules.d.ts +0 -39
- package/lib/types/modules.js +0 -2
- package/lib/types/service.d.ts +0 -23
- package/lib/types/service.js +0 -2
- package/lib/utils/errror.d.ts +0 -24
- package/lib/utils/errror.js +0 -29
package/lib/components/config.js
CHANGED
|
@@ -1,39 +1,113 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @Package @kotori-bot/core
|
|
4
|
+
* @Version 1.4.2-beta.1
|
|
5
|
+
* @Author Hotaru <biyuehuya@gmail.com>
|
|
6
|
+
* @Copyright 2024 Hotaru. All rights reserved.
|
|
7
|
+
* @License GPL-3.0
|
|
8
|
+
* @Link https://github.com/kotorijs/kotori
|
|
9
|
+
* @Date 2024/6/6 21:03:53
|
|
10
|
+
*/
|
|
11
|
+
|
|
1
12
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
13
|
+
var __create = Object.create;
|
|
14
|
+
var __defProp = Object.defineProperty;
|
|
15
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
16
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
17
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
18
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
22
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
32
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
33
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
34
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
35
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
36
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
37
|
+
mod
|
|
38
|
+
));
|
|
39
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
|
+
|
|
41
|
+
// src/components/config.ts
|
|
42
|
+
var config_exports = {};
|
|
43
|
+
__export(config_exports, {
|
|
44
|
+
Config: () => Config,
|
|
45
|
+
default: () => config_default
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(config_exports);
|
|
48
|
+
var import_tsukiko = __toESM(require("tsukiko"));
|
|
49
|
+
var import_node_path = require("path");
|
|
50
|
+
var import_tools = require("@kotori-bot/tools");
|
|
51
|
+
|
|
52
|
+
// src/global/constants.ts
|
|
53
|
+
var import_i18n = require("@kotori-bot/i18n");
|
|
54
|
+
var PLUGIN_PREFIX = "kotori-plugin-";
|
|
55
|
+
var DATABASE_PREFIX = `${PLUGIN_PREFIX}database-`;
|
|
56
|
+
var ADAPTER_PREFIX = `${PLUGIN_PREFIX}adapter-`;
|
|
57
|
+
var CUSTOM_PREFIX = `${PLUGIN_PREFIX}custom-`;
|
|
58
|
+
var DEFAULT_PORT = 720;
|
|
59
|
+
var DEFAULT_CORE_CONFIG = {
|
|
60
|
+
global: {
|
|
61
|
+
lang: import_i18n.DEFAULT_LANG,
|
|
62
|
+
"command-prefix": "/",
|
|
63
|
+
port: DEFAULT_PORT
|
|
64
|
+
},
|
|
65
|
+
adapter: {},
|
|
66
|
+
plugin: {}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// src/global/symbols.ts
|
|
70
|
+
var Symbols = class {
|
|
71
|
+
static adapter = Symbol.for("kotori.core.adapter");
|
|
72
|
+
static bot = Symbol.for("kotori.core.bot");
|
|
73
|
+
static midware = Symbol.for("kotori.core.midware");
|
|
74
|
+
static command = Symbol.for("kotori.core.command");
|
|
75
|
+
static regexp = Symbol.for("kotori.core.regexp");
|
|
76
|
+
static modules = Symbol.for("kotori.loader.module");
|
|
77
|
+
static job = Symbol.for("kotori.loader.job");
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/components/config.ts
|
|
81
|
+
var packageInfoSchema = import_tsukiko.default.Object({
|
|
82
|
+
name: import_tsukiko.default.String(),
|
|
83
|
+
version: import_tsukiko.default.String(),
|
|
84
|
+
description: import_tsukiko.default.String(),
|
|
85
|
+
main: import_tsukiko.default.String(),
|
|
86
|
+
license: import_tsukiko.default.Literal("GPL-3.0"),
|
|
87
|
+
author: import_tsukiko.default.String()
|
|
18
88
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
const result = packageInfoSchema.parseSafe(info);
|
|
31
|
-
if (!result.value) {
|
|
32
|
-
process.stderr.write(`File package.json format error: ${result.error.message}\n`);
|
|
33
|
-
process.exit();
|
|
34
|
-
}
|
|
35
|
-
this.pkg = result.data;
|
|
89
|
+
var Config = class {
|
|
90
|
+
config;
|
|
91
|
+
pkg;
|
|
92
|
+
constructor(config = DEFAULT_CORE_CONFIG) {
|
|
93
|
+
this.config = config;
|
|
94
|
+
const info = (0, import_tools.loadConfig)((0, import_node_path.resolve)(__dirname, "../../package.json"));
|
|
95
|
+
if (!info || Object.values(info).length === 0) {
|
|
96
|
+
process.stderr.write(`Cannot find kotori-bot package.json
|
|
97
|
+
`);
|
|
98
|
+
process.exit();
|
|
36
99
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
100
|
+
const result = packageInfoSchema.parseSafe(info);
|
|
101
|
+
if (!result.value) {
|
|
102
|
+
process.stderr.write(`File package.json format error: ${result.error.message}
|
|
103
|
+
`);
|
|
104
|
+
process.exit();
|
|
105
|
+
}
|
|
106
|
+
this.pkg = result.data;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var config_default = Config;
|
|
110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
+
0 && (module.exports = {
|
|
112
|
+
Config
|
|
113
|
+
});
|
package/lib/components/core.d.ts
CHANGED