hotcat-bot-qq 0.1.3 → 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.
- package/dist/botClient.d.ts +1 -0
- package/dist/botClient.js +16 -0
- package/package.json +1 -4
- package/plugins/hotCatPlugin/index.ts +1 -1
- package/scripts/postinstall.mjs +0 -21
package/dist/botClient.d.ts
CHANGED
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.
|
|
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": "bun run scripts/postinstall.mjs",
|
|
58
55
|
"prepublishOnly": "bun run build",
|
|
59
56
|
"docs:dev": "vitepress dev docs",
|
|
60
57
|
"docs:build": "vitepress build docs",
|
package/scripts/postinstall.mjs
DELETED
|
@@ -1,21 +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(src)) {
|
|
10
|
-
console.log('[hotCatBot] 默认插件目录不存在,跳过')
|
|
11
|
-
process.exit(0)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (existsSync(dest)) {
|
|
15
|
-
console.log('[hotCatBot] 插件 hotCatPlugin 已存在,跳过')
|
|
16
|
-
process.exit(0)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
mkdirSync(join(process.cwd(), 'plugins'), { recursive: true })
|
|
20
|
-
cpSync(src, dest, { recursive: true })
|
|
21
|
-
console.log('[hotCatBot] 默认插件 hotCatPlugin 已创建 → ./plugins/hotCatPlugin/')
|