hotcat-bot-qq 0.1.2 → 0.1.4

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.
@@ -34,4 +34,5 @@ export declare class BotClient {
34
34
  * 连接 napcat 并初始化事件监听,启动成功后自动填充 {@link nickname} 和 {@link id}。
35
35
  */
36
36
  start(): Promise<void>;
37
+ private seedDefaultPlugin;
37
38
  }
package/dist/botClient.js CHANGED
@@ -2,6 +2,9 @@ import { BotApi } from './botApi';
2
2
  import { BotConsole } from './botConsole';
3
3
  import { BotEvent } from './botEvent';
4
4
  import { BotScheduler } from './botScheduler';
5
+ import { existsSync, mkdirSync, cpSync } from 'fs';
6
+ import { join, dirname } from 'path';
7
+ import { fileURLToPath } from 'url';
5
8
  /**
6
9
  * Bot 客户端,封装连接、启动流程及 bot 自身信息。
7
10
  *
@@ -76,7 +79,20 @@ export class BotClient {
76
79
  catch (e) {
77
80
  new BotConsole('error', e instanceof Error ? e.message : JSON.stringify(e)).log();
78
81
  }
82
+ this.seedDefaultPlugin();
79
83
  await this.plugin.scan('./plugins');
80
84
  this.plugin.watch('./plugins');
81
85
  }
86
+ seedDefaultPlugin() {
87
+ const dest = join(process.cwd(), 'plugins', 'hotCatPlugin');
88
+ if (existsSync(dest))
89
+ return;
90
+ const selfDir = dirname(fileURLToPath(import.meta.url));
91
+ const src = join(selfDir, '..', 'plugins', 'hotCatPlugin');
92
+ if (!existsSync(src))
93
+ return;
94
+ mkdirSync(join(process.cwd(), 'plugins'), { recursive: true });
95
+ cpSync(src, dest, { recursive: true });
96
+ new BotConsole('system', '默认插件 hotCatPlugin 已创建').log();
97
+ }
82
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hotcat-bot-qq",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "基于 node-napcat-ts 的 TypeScript QQ 机器人框架",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -46,15 +46,12 @@
46
46
  "files": [
47
47
  "dist",
48
48
  "plugins/hotCatPlugin",
49
- "scripts/postinstall.mjs",
50
49
  "LICENSE",
51
50
  "README.md",
52
51
  "logo.png"
53
52
  ],
54
53
  "scripts": {
55
54
  "build": "tsc -p tsconfig.build.json",
56
- "test": "echo \"Error: no test specified\" && exit 1",
57
- "postinstall": "node scripts/postinstall.mjs || bun scripts/postinstall.mjs || echo skip",
58
55
  "prepublishOnly": "bun run build",
59
56
  "docs:dev": "vitepress dev docs",
60
57
  "docs:build": "vitepress build docs",
@@ -7,7 +7,7 @@ import * as os from 'os'
7
7
  export class HotCatPlugin extends PluginBase {
8
8
  static meta = {
9
9
  name: 'hotCatPlugin',
10
- version: '0.1.1',
10
+ version: '0.1.4',
11
11
  description: 'HotCat 默认插件(#hotCat 指令查询 bot 状态)',
12
12
  author: 'CHCAT1320',
13
13
  }
@@ -1,19 +0,0 @@
1
- import { existsSync, mkdirSync, cpSync } from 'fs'
2
- import { join, dirname } from 'path'
3
- import { fileURLToPath } from 'url'
4
-
5
- const __dirname = dirname(fileURLToPath(import.meta.url))
6
- const src = join(__dirname, '..', 'plugins', 'hotCatPlugin')
7
- const dest = join(process.cwd(), 'plugins', 'hotCatPlugin')
8
-
9
- if (existsSync(dest)) {
10
- console.log('[hotCatBot] 插件 hotCatPlugin 已存在,跳过复制')
11
- process.exit(0)
12
- }
13
-
14
- if (!existsSync(join(process.cwd(), 'plugins'))) {
15
- mkdirSync(join(process.cwd(), 'plugins'), { recursive: true })
16
- }
17
-
18
- cpSync(src, dest, { recursive: true })
19
- console.log('[hotCatBot] 默认插件 hotCatPlugin 已复制到 ./plugins/hotCatPlugin/')