@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/service/api.js
CHANGED
|
@@ -1,45 +1,82 @@
|
|
|
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
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/service/api.ts
|
|
32
|
+
var api_exports = {};
|
|
33
|
+
__export(api_exports, {
|
|
34
|
+
Api: () => Api,
|
|
35
|
+
default: () => api_default
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(api_exports);
|
|
38
|
+
var import_tools = require("@kotori-bot/tools");
|
|
39
|
+
var Api = class {
|
|
40
|
+
adapter;
|
|
41
|
+
constructor(adapter) {
|
|
42
|
+
this.adapter = adapter;
|
|
43
|
+
}
|
|
44
|
+
sendPrivateMsg(message, userId, ...extra) {
|
|
45
|
+
(0, import_tools.none)(this, message, userId, extra);
|
|
46
|
+
}
|
|
47
|
+
sendGroupMsg(message, groupId, ...extra) {
|
|
48
|
+
(0, import_tools.none)(this, message, groupId, extra, extra);
|
|
49
|
+
}
|
|
50
|
+
deleteMsg(messageId, ...extra) {
|
|
51
|
+
(0, import_tools.none)(this, messageId, extra);
|
|
52
|
+
}
|
|
53
|
+
setGroupName(groupId, groupName, ...extra) {
|
|
54
|
+
(0, import_tools.none)(this, groupId, groupName, extra);
|
|
55
|
+
}
|
|
56
|
+
setGroupAvatar(groupId, image, ...extra) {
|
|
57
|
+
(0, import_tools.none)(this, groupId, image, extra);
|
|
58
|
+
}
|
|
59
|
+
setGroupAdmin(groupId, userId, enable, ...extra) {
|
|
60
|
+
(0, import_tools.none)(this, groupId, userId, enable, extra);
|
|
61
|
+
}
|
|
62
|
+
setGroupCard(groupId, userId, card, ...extra) {
|
|
63
|
+
(0, import_tools.none)(this, groupId, userId, card, extra);
|
|
64
|
+
}
|
|
65
|
+
setGroupBan(groupId, userId, time, ...extra) {
|
|
66
|
+
(0, import_tools.none)(this, groupId, userId, time, extra);
|
|
67
|
+
}
|
|
68
|
+
sendGroupNotice(groupId, content, image, ...extra) {
|
|
69
|
+
(0, import_tools.none)(this, groupId, content, image, extra);
|
|
70
|
+
}
|
|
71
|
+
setGroupKick(groupId, userId, ...extra) {
|
|
72
|
+
(0, import_tools.none)(this, groupId, userId, extra);
|
|
73
|
+
}
|
|
74
|
+
setGroupLeave(groupId, ...extra) {
|
|
75
|
+
(0, import_tools.none)(this, groupId, groupId, extra);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var api_default = Api;
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
Api
|
|
82
|
+
});
|
package/lib/service/cache.js
CHANGED
|
@@ -1,34 +1,69 @@
|
|
|
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
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/service/cache.ts
|
|
32
|
+
var cache_exports = {};
|
|
33
|
+
__export(cache_exports, {
|
|
34
|
+
Cache: () => Cache,
|
|
35
|
+
default: () => cache_default
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(cache_exports);
|
|
38
|
+
var import_fluoro = require("fluoro");
|
|
39
|
+
var Cache = class extends import_fluoro.Service {
|
|
40
|
+
cache;
|
|
41
|
+
constructor(ctx) {
|
|
42
|
+
super(ctx, {}, "cache");
|
|
43
|
+
}
|
|
44
|
+
start() {
|
|
45
|
+
if (this.cache) return;
|
|
46
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
47
|
+
}
|
|
48
|
+
stop() {
|
|
49
|
+
this.cache?.forEach((el) => el.clear());
|
|
50
|
+
this.cache?.clear();
|
|
51
|
+
delete this.cache;
|
|
52
|
+
}
|
|
53
|
+
getContainer() {
|
|
54
|
+
const key = this.ctx.identity ?? "root";
|
|
55
|
+
if (!this.cache.has(key)) this.cache.set(key, /* @__PURE__ */ new Map());
|
|
56
|
+
return this.cache.get(key);
|
|
57
|
+
}
|
|
58
|
+
get(prop) {
|
|
59
|
+
return this.getContainer().get(prop);
|
|
60
|
+
}
|
|
61
|
+
set(prop, value) {
|
|
62
|
+
this.getContainer().set(prop, value);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var cache_default = Cache;
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
Cache
|
|
69
|
+
});
|
package/lib/service/elements.js
CHANGED
|
@@ -1,39 +1,75 @@
|
|
|
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
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/service/elements.ts
|
|
32
|
+
var elements_exports = {};
|
|
33
|
+
__export(elements_exports, {
|
|
34
|
+
Elements: () => Elements,
|
|
35
|
+
default: () => elements_default
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(elements_exports);
|
|
38
|
+
var import_tools = require("@kotori-bot/tools");
|
|
39
|
+
var Elements = class _Elements {
|
|
40
|
+
default(...args) {
|
|
41
|
+
(0, import_tools.none)(this, args);
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
at(target, ...extra) {
|
|
45
|
+
return this.default(target, extra);
|
|
46
|
+
}
|
|
47
|
+
image(url, ...extra) {
|
|
48
|
+
return this.default(url, extra);
|
|
49
|
+
}
|
|
50
|
+
voice(url, ...extra) {
|
|
51
|
+
return this.default(url, extra);
|
|
52
|
+
}
|
|
53
|
+
video(url, ...extra) {
|
|
54
|
+
return this.default(url, extra);
|
|
55
|
+
}
|
|
56
|
+
face(id, ...extra) {
|
|
57
|
+
return this.default(id, extra);
|
|
58
|
+
}
|
|
59
|
+
file(data, ...extra) {
|
|
60
|
+
return this.default(data, extra);
|
|
61
|
+
}
|
|
62
|
+
supports() {
|
|
63
|
+
const supports = [];
|
|
64
|
+
const keys = ["at", "image", "voice", "video", "face", "file"];
|
|
65
|
+
keys.forEach((key) => {
|
|
66
|
+
if (this[key] !== new _Elements()[key]) supports.push(key);
|
|
67
|
+
});
|
|
68
|
+
return supports;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var elements_default = Elements;
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
Elements
|
|
75
|
+
});
|