@zhin.js/core 1.0.8 → 1.0.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.
- package/CHANGELOG.md +6 -0
- package/README.md +28 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -19,16 +19,27 @@ Zhin 机器人框架核心包,基于 HMR(热模块替换)系统构建的
|
|
|
19
19
|
应用核心类,继承自 `HMR<Plugin>`:
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
|
-
import {
|
|
22
|
+
import { App } from '@zhin.js/core'
|
|
23
|
+
|
|
24
|
+
// 直接使用 App 类创建实例
|
|
25
|
+
const app = new App('./zhin.config.ts')
|
|
26
|
+
|
|
27
|
+
// 启动应用
|
|
28
|
+
await app.start()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
或者使用主包的便捷方法:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { createApp } from 'zhin.js'
|
|
23
35
|
|
|
24
36
|
// 创建应用实例
|
|
25
37
|
const app = await createApp({
|
|
26
38
|
plugin_dirs: ['./plugins'],
|
|
27
39
|
plugins: ['my-plugin'],
|
|
28
40
|
bots: [{
|
|
29
|
-
context: '
|
|
30
|
-
name: 'my-bot'
|
|
31
|
-
url: 'ws://localhost:8080'
|
|
41
|
+
context: 'process',
|
|
42
|
+
name: 'my-bot'
|
|
32
43
|
}],
|
|
33
44
|
debug: true
|
|
34
45
|
})
|
|
@@ -337,19 +348,24 @@ addMiddleware(async (message, next) => {
|
|
|
337
348
|
|
|
338
349
|
```typescript
|
|
339
350
|
// zhin.config.ts
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
351
|
+
import { defineConfig } from 'zhin.js'
|
|
352
|
+
|
|
353
|
+
export default defineConfig({
|
|
354
|
+
database: {
|
|
355
|
+
dialect: 'sqlite',
|
|
356
|
+
filename: './data/bot.db'
|
|
357
|
+
},
|
|
358
|
+
plugin_dirs: ['./src/plugins', 'node_modules', 'node_modules/@zhin.js'],
|
|
359
|
+
plugins: ['http', 'console', 'adapter-process'],
|
|
343
360
|
bots: [
|
|
344
361
|
{
|
|
345
|
-
context: '
|
|
346
|
-
name: '
|
|
347
|
-
url: 'ws://localhost:8080',
|
|
348
|
-
access_token: 'your-token'
|
|
362
|
+
context: 'process',
|
|
363
|
+
name: 'console-bot'
|
|
349
364
|
}
|
|
350
365
|
],
|
|
366
|
+
log_level: 1,
|
|
351
367
|
debug: process.env.NODE_ENV === 'development'
|
|
352
|
-
}
|
|
368
|
+
})
|
|
353
369
|
```
|
|
354
370
|
|
|
355
371
|
## 开发工具
|