node-karin 0.3.5 → 0.3.8
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/lib/adapter/onebot/onebot11.d.ts +1 -0
- package/lib/core/listener.d.ts +6 -19
- package/lib/core/listener.js +3 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +5 -0
- package/lib/render/client.d.ts +1 -0
- package/lib/render/server.d.ts +1 -0
- package/lib/types/adapter.d.ts +1 -0
- package/lib/types/render.d.ts +1 -1
- package/lib/utils/config.d.ts +1 -1
- package/lib/utils/config.js +4 -4
- package/lib/utils/kritor-proto.d.ts +1 -0
- package/package.json +11 -3
package/lib/core/listener.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { KarinAdapter, contact, KarinElement } from '../types/index.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* 监听器管理
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare class Listeners extends EventEmitter {
|
|
8
8
|
/**
|
|
9
9
|
* Bot索引
|
|
10
10
|
* @type - Bot索引
|
|
@@ -24,6 +24,7 @@ export declare const listener: {
|
|
|
24
24
|
adapter: new () => KarinAdapter;
|
|
25
25
|
path: string;
|
|
26
26
|
}>;
|
|
27
|
+
constructor();
|
|
27
28
|
/**
|
|
28
29
|
* 注册Bot 返回索引id
|
|
29
30
|
*/
|
|
@@ -80,7 +81,7 @@ export declare const listener: {
|
|
|
80
81
|
* @param isType - 是否返回包含的类型列表 默认返回适配器实例列表
|
|
81
82
|
*/
|
|
82
83
|
getAdapterAll(isType?: boolean): {
|
|
83
|
-
type:
|
|
84
|
+
type: "internal" | "http" | "grpc" | "ws" | "render";
|
|
84
85
|
adapter: new () => KarinAdapter;
|
|
85
86
|
path: string;
|
|
86
87
|
}[] | (new () => KarinAdapter)[];
|
|
@@ -99,20 +100,6 @@ export declare const listener: {
|
|
|
99
100
|
}): Promise<{
|
|
100
101
|
message_id: string;
|
|
101
102
|
}>;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
106
|
-
removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
107
|
-
off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
108
|
-
removeAllListeners(eventName?: string | symbol | undefined): any;
|
|
109
|
-
setMaxListeners(n: number): any;
|
|
110
|
-
getMaxListeners(): number;
|
|
111
|
-
listeners<K_6>(eventName: string | symbol): Function[];
|
|
112
|
-
rawListeners<K_7>(eventName: string | symbol): Function[];
|
|
113
|
-
emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
|
|
114
|
-
listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
|
|
115
|
-
prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
116
|
-
prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
117
|
-
eventNames(): (string | symbol)[];
|
|
118
|
-
};
|
|
103
|
+
}
|
|
104
|
+
export declare const listener: Listeners;
|
|
105
|
+
export {};
|
package/lib/core/listener.js
CHANGED
|
@@ -5,7 +5,7 @@ import { MessageHandler } from '../event/message.handler.js'
|
|
|
5
5
|
/**
|
|
6
6
|
* 监听器管理
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
class Listeners extends EventEmitter {
|
|
9
9
|
/**
|
|
10
10
|
* Bot索引
|
|
11
11
|
* @type - Bot索引
|
|
@@ -183,4 +183,5 @@ export const listener = new (class Listeners extends EventEmitter {
|
|
|
183
183
|
}
|
|
184
184
|
return result
|
|
185
185
|
}
|
|
186
|
-
}
|
|
186
|
+
}
|
|
187
|
+
export const listener = new Listeners()
|
package/lib/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare const Cfg: {
|
|
|
35
35
|
change: Map<string, any>;
|
|
36
36
|
watcher: Map<string, any>;
|
|
37
37
|
review: boolean;
|
|
38
|
-
|
|
38
|
+
logger: import("log4js").Logger;
|
|
39
39
|
initCfg(): Promise<void>;
|
|
40
40
|
getPlugins(): string[];
|
|
41
41
|
dirPath(name: string, plugins: string[]): Promise<void>;
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/// <reference types="@types/express" />
|
|
2
|
+
/// <reference types="@types/lodash" />
|
|
3
|
+
/// <reference types="@types/node" />
|
|
4
|
+
/// <reference types="@types/node-schedule" />
|
|
5
|
+
/// <reference types="@types/ws" />
|
|
1
6
|
// 基本模块
|
|
2
7
|
export * from 'kritor-proto';
|
|
3
8
|
export * from './core/index.js';
|
package/lib/render/client.d.ts
CHANGED
package/lib/render/server.d.ts
CHANGED
package/lib/types/adapter.d.ts
CHANGED
package/lib/types/render.d.ts
CHANGED
package/lib/utils/config.d.ts
CHANGED
package/lib/utils/config.js
CHANGED
|
@@ -10,7 +10,7 @@ export const config = new (class Cfg {
|
|
|
10
10
|
change
|
|
11
11
|
watcher
|
|
12
12
|
review
|
|
13
|
-
|
|
13
|
+
logger
|
|
14
14
|
constructor () {
|
|
15
15
|
this.dir = karinDir
|
|
16
16
|
this._path = process.cwd() + '/config'
|
|
@@ -43,7 +43,7 @@ export const config = new (class Cfg {
|
|
|
43
43
|
this.dirPath('temp', plugins)
|
|
44
44
|
this.dirPath('resources', plugins)
|
|
45
45
|
this.dirPath('temp/html', plugins)
|
|
46
|
-
this.
|
|
46
|
+
this.logger = (await import('./logger.js')).default
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
getPlugins () {
|
|
@@ -212,7 +212,7 @@ export const config = new (class Cfg {
|
|
|
212
212
|
/** 监听文件变化 */
|
|
213
213
|
watcher.on('change', () => {
|
|
214
214
|
this.change.delete(key)
|
|
215
|
-
this.
|
|
215
|
+
this.logger.mark(`[修改配置文件][${type}][${name}]`)
|
|
216
216
|
/** 文件修改后调用对应的方法 */
|
|
217
217
|
switch (`change_${name}`) {
|
|
218
218
|
case 'change_App':
|
|
@@ -236,7 +236,7 @@ export const config = new (class Cfg {
|
|
|
236
236
|
|
|
237
237
|
async change_config () {
|
|
238
238
|
/** 修改日志等级 */
|
|
239
|
-
this.
|
|
239
|
+
this.logger.level = this.Config.log4jsCfg.level
|
|
240
240
|
await this.#review()
|
|
241
241
|
if (this.Server.HotUpdate) {
|
|
242
242
|
const { Bot } = await import('../index.js')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'kritor-proto'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-karin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "基于 Kritor 进行开发的nodejs机器人框架",
|
|
6
6
|
"homepage": "https://github.com/KarinJS/Karin",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"#Karin": "./lib/index.js"
|
|
19
19
|
},
|
|
20
20
|
"main": "./lib/index.js",
|
|
21
|
+
"types": "./lib/index.d.ts",
|
|
21
22
|
"bin": {
|
|
22
23
|
"init": "./lib/tools/init.js"
|
|
23
24
|
},
|
|
@@ -38,14 +39,14 @@
|
|
|
38
39
|
"scripts": {
|
|
39
40
|
"app": "node .",
|
|
40
41
|
"build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json && npm run fix && npm run cp",
|
|
41
|
-
"cp": "cp ./lib/modules.d.ts ./modules.d.ts && cp ./lib/modules.js ./modules.js",
|
|
42
|
+
"cp": "cp ./lib/modules.d.ts ./modules.d.ts && cp ./lib/modules.js ./modules.js && cp ./src/utils/kritor-proto.d.ts ./lib/utils/kritor-proto.d.ts",
|
|
42
43
|
"delete": "pm2 delete ./config/config/pm2.yaml",
|
|
44
|
+
"dev": "tsx ./lib/index.js --dev",
|
|
43
45
|
"fix": "eslint lib/**/*.js --fix",
|
|
44
46
|
"fix:all": "eslint lib/**/*.js --fix && eslint src/**/*.ts --fix",
|
|
45
47
|
"init": "node lib/tools/install.js",
|
|
46
48
|
"init:dev": "node lib/tools/install.js",
|
|
47
49
|
"init:pack": "node lib/tools/install.js",
|
|
48
|
-
"dev": "tsx ./lib/index.js --dev",
|
|
49
50
|
"log": "node lib/tools/pm2Log.js",
|
|
50
51
|
"monit": "pm2 monit",
|
|
51
52
|
"pub": "npm publish --access public",
|
|
@@ -87,6 +88,13 @@
|
|
|
87
88
|
"tsx": "^4.15.7",
|
|
88
89
|
"typescript": "^4.9.5"
|
|
89
90
|
},
|
|
91
|
+
"bundledDependencies": [
|
|
92
|
+
"@types/express",
|
|
93
|
+
"@types/lodash",
|
|
94
|
+
"@types/node",
|
|
95
|
+
"@types/node-schedule",
|
|
96
|
+
"@types/ws"
|
|
97
|
+
],
|
|
90
98
|
"engines": {
|
|
91
99
|
"node": ">=18"
|
|
92
100
|
},
|