@kotori-bot/core 1.4.2-beta.1 → 1.5.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.
package/README.md CHANGED
@@ -1,17 +1,17 @@
1
- # @kotori-bot/core
2
-
3
- - Context
4
- - Symbols
5
- - Service
6
- - Modules
7
- - Core
8
- - Config
9
- - Message
10
- - Adapter
11
- - Api
12
- - Elements
13
- - Cache
14
-
15
- ## Reference
16
-
17
- - [Kotori Docs](https://kotori.js.org/)
1
+ # @kotori-bot/core
2
+
3
+ - Context
4
+ - Symbols
5
+ - Service
6
+ - Modules
7
+ - Core
8
+ - Config
9
+ - Message
10
+ - Adapter
11
+ - Api
12
+ - Elements
13
+ - Cache
14
+
15
+ ## Reference
16
+
17
+ - [Kotori Docs](https://kotori.js.org/)
@@ -1,39 +1,82 @@
1
+
2
+ /**
3
+ * @Package @kotori-bot/core
4
+ * @Version 1.5.0
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/7 11:22:22
10
+ */
11
+
1
12
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Config = void 0;
7
- const tsukiko_1 = __importDefault(require("tsukiko"));
8
- const node_path_1 = require("node:path");
9
- const tools_1 = require("@kotori-bot/tools");
10
- const global_1 = require("../global");
11
- const packageInfoSchema = tsukiko_1.default.Object({
12
- name: tsukiko_1.default.String(),
13
- version: tsukiko_1.default.String(),
14
- description: tsukiko_1.default.String(),
15
- main: tsukiko_1.default.String(),
16
- license: tsukiko_1.default.Literal('GPL-3.0'),
17
- author: tsukiko_1.default.String()
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
+ var config_exports = {};
41
+ __export(config_exports, {
42
+ Config: () => Config,
43
+ default: () => config_default
44
+ });
45
+ module.exports = __toCommonJS(config_exports);
46
+ var import_tsukiko = __toESM(require("tsukiko"));
47
+ var import_node_path = require("node:path");
48
+ var import_tools = require("@kotori-bot/tools");
49
+ var import_global = require("../global");
50
+ const packageInfoSchema = import_tsukiko.default.Object({
51
+ name: import_tsukiko.default.String(),
52
+ version: import_tsukiko.default.String(),
53
+ description: import_tsukiko.default.String(),
54
+ main: import_tsukiko.default.String(),
55
+ license: import_tsukiko.default.Literal("GPL-3.0"),
56
+ author: import_tsukiko.default.String()
18
57
  });
19
58
  class Config {
20
- config;
21
- pkg;
22
- constructor(config = global_1.DEFAULT_CORE_CONFIG) {
23
- this.config = config;
24
- /* load package.json */
25
- const info = (0, tools_1.loadConfig)((0, node_path_1.join)(__dirname, '../../package.json'));
26
- if (!info || Object.values(info).length === 0) {
27
- process.stderr.write(`Cannot find kotori-bot package.json\n`);
28
- process.exit();
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;
59
+ config;
60
+ pkg;
61
+ constructor(config = import_global.DEFAULT_CORE_CONFIG) {
62
+ this.config = config;
63
+ const info = (0, import_tools.loadConfig)((0, import_node_path.resolve)(__dirname, "../../package.json"));
64
+ if (!info || Object.values(info).length === 0) {
65
+ process.stderr.write(`Cannot find kotori-bot package.json
66
+ `);
67
+ process.exit();
36
68
  }
69
+ const result = packageInfoSchema.parseSafe(info);
70
+ if (!result.value) {
71
+ process.stderr.write(`File package.json format error: ${result.error.message}
72
+ `);
73
+ process.exit();
74
+ }
75
+ this.pkg = result.data;
76
+ }
37
77
  }
38
- exports.Config = Config;
39
- exports.default = Config;
78
+ var config_default = Config;
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ Config
82
+ });
@@ -19,6 +19,8 @@ declare module 'fluoro' {
19
19
  midware: Message['midware'];
20
20
  command: Message['command'];
21
21
  regexp: Message['regexp'];
22
+ notify: Message['notify'];
23
+ task: Message['task'];
22
24
  http: Http;
23
25
  i18n: I18n;
24
26
  cache: Cache;
@@ -1,31 +1,73 @@
1
+
2
+ /**
3
+ * @Package @kotori-bot/core
4
+ * @Version 1.5.0
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/7 11:22:22
10
+ */
11
+
1
12
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Core = void 0;
7
- const tools_1 = require("@kotori-bot/tools");
8
- const i18n_1 = __importDefault(require("@kotori-bot/i18n"));
9
- const fluoro_1 = require("fluoro");
10
- const config_1 = __importDefault(require("./config"));
11
- const message_1 = __importDefault(require("./message"));
12
- const service_1 = require("../service");
13
- const global_1 = require("../global");
14
- class Core extends fluoro_1.Context {
15
- [global_1.Symbols.adapter] = new Map();
16
- [global_1.Symbols.bot] = new Map();
17
- constructor(config) {
18
- super();
19
- this.provide('config', new config_1.default(config));
20
- this.mixin('config', ['config', 'pkg']);
21
- this.provide('message', new message_1.default(this));
22
- this.mixin('message', ['midware', 'command', 'regexp']);
23
- this.provide('http', new tools_1.Http({ validateStatus: () => true }));
24
- this.inject('http');
25
- this.provide('i18n', new i18n_1.default({ lang: this.config.global.lang }));
26
- this.inject('i18n');
27
- this.service('cache', new service_1.Cache(this.extends()));
28
- }
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
+ var core_exports = {};
41
+ __export(core_exports, {
42
+ Core: () => Core,
43
+ default: () => core_default
44
+ });
45
+ module.exports = __toCommonJS(core_exports);
46
+ var import_tools = require("@kotori-bot/tools");
47
+ var import_i18n = __toESM(require("@kotori-bot/i18n"));
48
+ var import_fluoro = require("fluoro");
49
+ var import_config = __toESM(require("./config"));
50
+ var import_message = __toESM(require("./message"));
51
+ var import_service = require("../service");
52
+ var import_global = require("../global");
53
+ class Core extends import_fluoro.Context {
54
+ [import_global.Symbols.adapter] = /* @__PURE__ */ new Map();
55
+ [import_global.Symbols.bot] = /* @__PURE__ */ new Map();
56
+ constructor(config) {
57
+ super();
58
+ this.provide("config", new import_config.default(config));
59
+ this.mixin("config", ["config", "pkg"]);
60
+ this.provide("message", new import_message.default(this));
61
+ this.mixin("message", ["midware", "command", "regexp", "notify", "task"]);
62
+ this.provide("http", new import_tools.Http({ validateStatus: () => true }));
63
+ this.inject("http");
64
+ this.provide("i18n", new import_i18n.default({ lang: this.config.global.lang }));
65
+ this.inject("i18n");
66
+ this.service("cache", new import_service.Cache(this.extends()));
67
+ }
29
68
  }
30
- exports.Core = Core;
31
- exports.default = Core;
69
+ var core_default = Core;
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ Core
73
+ });
@@ -1,18 +1,35 @@
1
+
2
+ /**
3
+ * @Package @kotori-bot/core
4
+ * @Version 1.5.0
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/7 11:22:22
10
+ */
11
+
1
12
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
15
24
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./core"), exports);
18
- __exportStar(require("../global"), exports);
25
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var components_exports = {};
28
+ module.exports = __toCommonJS(components_exports);
29
+ __reExport(components_exports, require("./core"), module.exports);
30
+ __reExport(components_exports, require("../global"), module.exports);
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ ...require("./core"),
34
+ ...require("../global")
35
+ });
@@ -1,5 +1,6 @@
1
1
  import { type Context } from 'fluoro';
2
- import { type CommandConfig, type MidwareCallback, type RegexpCallback } from '../types';
2
+ import { CronJob } from 'cron';
3
+ import { type CommandConfig, type MidwareCallback, type RegexpCallback, MessageQuick, TaskCallback } from '../types';
3
4
  import { Command } from '../utils/command';
4
5
  import { Symbols } from '../global';
5
6
  interface MidwareData {
@@ -20,7 +21,13 @@ export declare class Message {
20
21
  private readonly ctx;
21
22
  constructor(ctx: Context);
22
23
  midware(callback: MidwareCallback, priority?: number): () => boolean;
23
- command(template: string, config?: CommandConfig): Command;
24
+ command<T extends string>(template: T, config?: CommandConfig): Command<T, {}>;
24
25
  regexp(match: RegExp, callback: RegexpCallback): () => boolean;
26
+ notify(message: MessageQuick): void;
27
+ task(options: string | {
28
+ cron: string;
29
+ start?: boolean;
30
+ timeZone?: string;
31
+ }, callback: TaskCallback): CronJob<null, null>;
25
32
  }
26
33
  export default Message;