@kotori-bot/kotori-plugin-core 1.6.0 → 1.6.2

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,70 +1,70 @@
1
- # @kotori-bot/kotori-plugin-core
2
-
3
- Base on tencent api.
4
-
5
- ## Commands
6
-
7
- - `/core` View instance statistics
8
- - `/bot` View current bot info and running status
9
- - `/bots` View all bots info and running status
10
- - `/about` View about info
11
- - `/help [...command]` View command help info
12
- - `/menu` View Bot's menu
13
-
14
- ```bash
15
- /core
16
- > Global Language: en_US
17
- Root Directory: \usr\kotori
18
- Running Mode: dev
19
- Number of Modules: 21
20
- Number of Services: 3
21
- Number of Bots: 1
22
- Number of Middlewares: 1
23
- Number of Commands: 27
24
- Number of Regexps: 25
25
-
26
- /bot
27
- > ID: cmd-test
28
- Language: en_US
29
- Platform: cmd
30
- Self ID: 720
31
- Connect Time: 24/2/4 18:36:36
32
- Messages Received: 16
33
- Messages Sent: 15
34
- Offline Times: 0
35
- Last Message Time: 24/2/4 18:45:45
36
-
37
- /bots
38
- > Bot List:
39
- ----------
40
- ID: cmd-test
41
- Language: en_US
42
- Platform: cmd
43
- Status: online
44
-
45
- /about
46
- > Kotori Version: 1.2.0
47
- License: GPL-3.0
48
- NodeJS Version: v18.18.1
49
-
50
- > Found the following related commands:
51
- /core - View instance statistics
52
- /bot - View current bot info and running status
53
- /bots - View all bots info and running status
54
- /about - View about info
55
- /help [...command] - View command help info
56
- ```
57
-
58
- ## Config
59
-
60
- ```typescript
61
- interface Config extends ModuleConfig {
62
- alias?: string; // alias of /menu
63
- keywords?: string[]; // keyowrds of /menu
64
- content: string; // content of menu
65
- }
66
- ```
67
-
68
- ## Reference
69
-
70
- - [Kotori Docs](https://kotori.js.org/)
1
+ # @kotori-bot/kotori-plugin-core
2
+
3
+ Base on tencent api.
4
+
5
+ ## Commands
6
+
7
+ - `/core` View instance statistics
8
+ - `/bot` View current bot info and running status
9
+ - `/bots` View all bots info and running status
10
+ - `/about` View about info
11
+ - `/help [...command]` View command help info
12
+ - `/menu` View Bot's menu
13
+
14
+ ```bash
15
+ /core
16
+ > Global Language: en_US
17
+ Root Directory: \usr\kotori
18
+ Running Mode: dev
19
+ Number of Modules: 21
20
+ Number of Services: 3
21
+ Number of Bots: 1
22
+ Number of Middlewares: 1
23
+ Number of Commands: 27
24
+ Number of Regexps: 25
25
+
26
+ /bot
27
+ > ID: cmd-test
28
+ Language: en_US
29
+ Platform: cmd
30
+ Self ID: 720
31
+ Connect Time: 24/2/4 18:36:36
32
+ Messages Received: 16
33
+ Messages Sent: 15
34
+ Offline Times: 0
35
+ Last Message Time: 24/2/4 18:45:45
36
+
37
+ /bots
38
+ > Bot List:
39
+ ----------
40
+ ID: cmd-test
41
+ Language: en_US
42
+ Platform: cmd
43
+ Status: online
44
+
45
+ /about
46
+ > Kotori Version: 1.2.0
47
+ License: GPL-3.0
48
+ NodeJS Version: v18.18.1
49
+
50
+ > Found the following related commands:
51
+ /core - View instance statistics
52
+ /bot - View current bot info and running status
53
+ /bots - View all bots info and running status
54
+ /about - View about info
55
+ /help [...command] - View command help info
56
+ ```
57
+
58
+ ## Config
59
+
60
+ ```typescript
61
+ interface Config extends ModuleConfig {
62
+ alias?: string; // alias of /menu
63
+ keywords?: string[]; // keyowrds of /menu
64
+ content: string; // content of menu
65
+ }
66
+ ```
67
+
68
+ ## Reference
69
+
70
+ - [Kotori Docs](https://kotori.js.org/)
package/lib/index.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import { type Context, Tsu } from 'kotori-bot';
2
2
  export declare const lang: string[];
3
- export declare const config: any;
3
+ export declare const config: import("kotori-bot").ObjectParser<{
4
+ alias: import("kotori-bot").Parser<string | undefined>;
5
+ keywords: import("kotori-bot").Parser<string[]>;
6
+ content: import("kotori-bot").Parser<string | undefined>;
7
+ }>;
4
8
  export declare function main(ctx: Context, cfg: Tsu.infer<typeof config>): void;
package/lib/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @Package @kotori-bot/kotori-plugin-core
3
- * @Version 1.6.0
4
- * @Author Hotaru <me@hotaru.icu>
3
+ * @Version 1.6.2
4
+ * @Author Hotaru <i@arimuraromi.com>
5
5
  * @Copyright 2024-2025 Hotaru. All rights reserved.
6
6
  * @License GPL-3.0
7
7
  * @Link https://github.com/kotorijs/kotori
8
- * @Date 2026/8/15 22:55:52
8
+ * @Date 2026/11/7 15:34:40
9
9
  */
10
10
  "use strict";
11
11
  var __defProp = Object.defineProperty;
@@ -47,7 +47,9 @@ function main(ctx, cfg) {
47
47
  ctx.emit(
48
48
  "on_message",
49
49
  Object.assign(data.session, {
50
- message: /* @__PURE__ */ kotoriHTs("text", null, `${data.session.api.adapter.config.commandPrefix}help ${data.command.meta.root} --exact`)
50
+ message: new import_kotori_bot.MessageSingle("text", {
51
+ text: `${data.session.api.adapter.config.commandPrefix}help ${data.command.meta.root} --exact`
52
+ })
51
53
  })
52
54
  );
53
55
  return;
@@ -188,7 +190,7 @@ function main(ctx, cfg) {
188
190
  ).join("")
189
191
  })
190
192
  );
191
- ctx.command("about - core.descr.about").alias("version").shortcut(["\u5C0F\u9E1F", "\u5C0F\u9CE5", "\u3053\u3068\u308A", "kotori", "Kotori"]).hide().action((_, session) => {
193
+ ctx.command("about - core.descr.about").alias("version").shortcut(["\u5C0F\u9E1F", "\u5C0F\u9CE5", "\u3053\u3068\u308A", "kotoribot", "Kotoribot", "KotoriBot"]).hide().action((_, session) => {
192
194
  const { version, license, coreVersion, loaderVersion } = session.api.adapter.ctx.meta;
193
195
  return session.format("core.msg.about", {
194
196
  version,
@@ -235,39 +237,43 @@ function main(ctx, cfg) {
235
237
  await session.quick("core.msg.restart");
236
238
  setTimeout(() => process.exit(233), 1);
237
239
  });
238
- ctx.command("help [...command] - core.descr.help").option("E", "exact:boolean core.option.help.exact").action(({ args: [args], options: { exact } }, session) => {
240
+ ctx.command("help [...command] - core.descr.help").option("E", "exact:boolean core.option.help.exact").action(({ args, options: { exact } }, session) => {
241
+ const target = (Array.isArray(args) ? args.join(" ") : String(args ?? "")).trim();
239
242
  const filterResult = [];
240
243
  for (const command of ctx[import_kotori_bot.Symbols.command]) {
241
244
  if (command.meta.hide) continue;
242
- const matched = exact ? command.meta.root === args || command.meta.alias.some((alias) => alias === args) : command.meta.root.startsWith(args) || command.meta.alias.some((alias) => alias.startsWith(args));
245
+ if (!target) {
246
+ filterResult.push(command.meta);
247
+ continue;
248
+ }
249
+ const matched = exact ? command.meta.root === target || command.meta.alias.some((alias) => alias === target) : command.meta.root.startsWith(target) || command.meta.alias.some((alias) => alias.startsWith(target));
243
250
  if (matched) filterResult.push(command.meta);
244
251
  }
245
252
  if (filterResult.length === 0) return "core.msg.descr.fail";
246
253
  let commands = "";
247
- const short = filterResult.length === 1;
254
+ const short = Boolean(target) && filterResult.length === 1;
248
255
  for (const cmd of filterResult) {
249
256
  const alias = cmd.alias.length > 0 ? session.format("core.template.alias", {
250
257
  content: cmd.alias.join(session.i18n.locale("core.template.alias.delimiter"))
251
258
  }) : "";
252
- let args2 = "";
259
+ let cmdArgs = "";
253
260
  let options = "";
254
- const handle = (values) => {
255
- for (const value of values) {
256
- let defaultValue = "";
257
- if ("rest" in value) {
258
- const valueType = typeof value.default;
259
- if (valueType === "string" || valueType === "number") {
260
- defaultValue = session.format("core.template.default", { content: value.default });
261
- } else if (valueType === "boolean") {
262
- defaultValue = session.format("core.template.default", { content: value.default ? "true" : "false" });
263
- }
264
- args2 += session.format(`core.template.arg.${value.optional ? "optional" : "required"}`, {
265
- name: value.rest ? `...${value.name}` : value.name,
266
- type: value.type === "string" ? "" : session.format("core.template.arg.type", { content: value.type }),
267
- default: defaultValue
268
- });
269
- }
270
- if (!("realname" in value) || !("description" in value)) return;
261
+ for (const value of cmd.args) {
262
+ let defaultValue = "";
263
+ const valueType = typeof value.default;
264
+ if (valueType === "string" || valueType === "number") {
265
+ defaultValue = session.format("core.template.default", { content: String(value.default) });
266
+ } else if (valueType === "boolean") {
267
+ defaultValue = session.format("core.template.default", { content: value.default ? "true" : "false" });
268
+ }
269
+ cmdArgs += session.format(`core.template.arg.${value.optional ? "optional" : "required"}`, {
270
+ name: value.rest ? `...${value.name}` : value.name,
271
+ type: value.type === "string" ? "" : session.format("core.template.arg.type", { content: value.type }),
272
+ default: defaultValue
273
+ });
274
+ }
275
+ if (short) {
276
+ for (const value of cmd.options) {
271
277
  options += session.format("core.template.option", {
272
278
  name: value.name,
273
279
  realname: value.realname,
@@ -275,13 +281,13 @@ function main(ctx, cfg) {
275
281
  description: value.description ? session.format("core.template.description", { content: session.i18n.locale(value.description) }) : ""
276
282
  });
277
283
  }
278
- };
279
- handle(cmd.args);
280
- if (short) handle(cmd.options);
281
- if (options) options = session.format("core.template.options", { content: options });
284
+ if (options) {
285
+ options = session.format("core.template.options", { content: options });
286
+ }
287
+ }
282
288
  commands += session.format(`core.msg.descr.command${short ? "2" : ""}`, {
283
289
  root: `${session.api.adapter.config.commandPrefix}${cmd.root}`,
284
- args: args2,
290
+ args: cmdArgs,
285
291
  description: cmd.description ? session.format("core.template.description", { content: session.i18n.locale(cmd.description) }) : "",
286
292
  options,
287
293
  help: cmd.help && short ? session.format("core.template.help", { content: session.i18n.locale(cmd.help) }) : "",
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@kotori-bot/kotori-plugin-core",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "core plugin",
5
5
  "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
6
7
  "keywords": [
7
8
  "kotori",
8
9
  "chatbot",
@@ -15,9 +16,9 @@
15
16
  "LICENSE",
16
17
  "README.md"
17
18
  ],
18
- "author": "Hotaru <me@hotaru.icu>",
19
+ "author": "Hotaru <i@arimuraromi.com>",
19
20
  "peerDependencies": {
20
- "kotori-bot": "^1.7.3"
21
+ "kotori-bot": "^1.7.7"
21
22
  },
22
23
  "kotori": {
23
24
  "meta": {