hotcat-bot-qq 0.1.8 → 0.1.9

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.
@@ -35,4 +35,5 @@ export declare class BotClient {
35
35
  */
36
36
  start(): Promise<void>;
37
37
  private seedDefaultPlugin;
38
+ private syncPluginFiles;
38
39
  }
package/dist/botClient.js CHANGED
@@ -2,8 +2,8 @@ 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';
5
+ import { existsSync, mkdirSync, cpSync, readdirSync, readFileSync, statSync, lstatSync } from 'fs';
6
+ import { join, dirname, relative } from 'path';
7
7
  import { fileURLToPath } from 'url';
8
8
  /**
9
9
  * Bot 客户端,封装连接、启动流程及 bot 自身信息。
@@ -84,15 +84,60 @@ export class BotClient {
84
84
  this.plugin.watch('./plugins');
85
85
  }
86
86
  seedDefaultPlugin() {
87
- const dest = join(process.cwd(), 'plugins', 'hotCatPlugin');
88
- if (existsSync(dest))
89
- return;
90
87
  const selfDir = dirname(fileURLToPath(import.meta.url));
91
88
  const src = join(selfDir, '..', 'plugins', 'hotCatPlugin');
92
89
  if (!existsSync(src))
93
90
  return;
91
+ const dest = join(process.cwd(), 'plugins', 'hotCatPlugin');
94
92
  mkdirSync(join(process.cwd(), 'plugins'), { recursive: true });
95
- cpSync(src, dest, { recursive: true });
96
- new BotConsole('system', '默认插件 hotCatPlugin 已创建').log();
93
+ if (!existsSync(dest)) {
94
+ cpSync(src, dest, { recursive: true });
95
+ new BotConsole('system', '默认插件 hotCatPlugin 已创建').log();
96
+ return;
97
+ }
98
+ const updated = this.syncPluginFiles(src, dest);
99
+ if (updated.length > 0) {
100
+ new BotConsole('system', `默认插件 hotCatPlugin 已更新: ${updated.join(', ')}`).log();
101
+ }
102
+ }
103
+ syncPluginFiles(src, dest) {
104
+ const updated = [];
105
+ const walkDir = (dir) => {
106
+ const entries = readdirSync(dir);
107
+ const files = [];
108
+ for (const entry of entries) {
109
+ const full = join(dir, entry);
110
+ if (lstatSync(full).isDirectory()) {
111
+ files.push(...walkDir(full));
112
+ }
113
+ else {
114
+ files.push(full);
115
+ }
116
+ }
117
+ return files;
118
+ };
119
+ const srcFiles = walkDir(src);
120
+ for (const file of srcFiles) {
121
+ const rel = relative(src, file);
122
+ const target = join(dest, rel);
123
+ if (!existsSync(target)) {
124
+ mkdirSync(dirname(target), { recursive: true });
125
+ cpSync(file, target);
126
+ updated.push(rel);
127
+ continue;
128
+ }
129
+ if (statSync(file).size !== statSync(target).size) {
130
+ cpSync(file, target);
131
+ updated.push(rel);
132
+ continue;
133
+ }
134
+ const srcContent = readFileSync(file);
135
+ const destContent = readFileSync(target);
136
+ if (!srcContent.equals(destContent)) {
137
+ cpSync(file, target);
138
+ updated.push(rel);
139
+ }
140
+ }
141
+ return updated;
97
142
  }
98
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hotcat-bot-qq",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "基于 node-napcat-ts 的 TypeScript QQ 机器人框架",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -14,7 +14,12 @@ export class HotCatPlugin extends PluginBase {
14
14
  await this.api.sendGroupMessage(event.group_id, Message.reply(event.message_id), Message.text(`HotCat 信息\n` +
15
15
  `版本:${this.meta.version}\n` +
16
16
  `平台:${platform} ${arch}\n` +
17
- `运行时间:${uptime}`));
17
+ `运行时间:${uptime}\n` +
18
+ `Github: https://github.com/CHCAT1320/hotCat-bot-qq\n` +
19
+ `开发文档: https://hotcat-bot-qq.docs.chcat1320.top\n` +
20
+ `交流群: 638144340\n` +
21
+ `管理员QQ: 1095216448\n` +
22
+ `基于 MIT 许可发布 版权所有 © 2026 CHCAT1320`));
18
23
  }
19
24
  };
20
25
  }
@@ -45,7 +50,7 @@ export class HotCatPlugin extends PluginBase {
45
50
  }
46
51
  HotCatPlugin.meta = {
47
52
  name: 'hotCatPlugin',
48
- version: '0.1.8',
53
+ version: '0.1.9',
49
54
  description: 'HotCat 默认插件(#hotCat 指令查询 bot 状态)',
50
55
  author: 'CHCAT1320',
51
56
  };
@@ -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.8',
10
+ version: '0.1.9',
11
11
  description: 'HotCat 默认插件(#hotCat 指令查询 bot 状态)',
12
12
  author: 'CHCAT1320',
13
13
  }
@@ -41,7 +41,12 @@ export class HotCatPlugin extends PluginBase {
41
41
  `HotCat 信息\n` +
42
42
  `版本:${this.meta.version}\n` +
43
43
  `平台:${platform} ${arch}\n` +
44
- `运行时间:${uptime}`
44
+ `运行时间:${uptime}\n` +
45
+ `Github: https://github.com/CHCAT1320/hotCat-bot-qq\n` +
46
+ `开发文档: https://hotcat-bot-qq.docs.chcat1320.top\n` +
47
+ `交流群: 638144340\n` +
48
+ `管理员QQ: 1095216448\n` +
49
+ `基于 MIT 许可发布 版权所有 © 2026 CHCAT1320`
45
50
  )
46
51
  )
47
52
  }