node-karin 0.10.7 → 0.11.1
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/config/defSet/group.yaml +6 -6
- package/lib/adapter/onebot/11/convert.js +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/karin/karin.d.ts +41 -54
- package/lib/core/karin/karin.js +61 -54
- package/lib/core/listener/listener.js +14 -0
- package/lib/core/plugin/base.d.ts +10 -23
- package/lib/core/plugin/base.js +6 -15
- package/lib/core/plugin/loader.d.ts +79 -102
- package/lib/core/plugin/loader.js +440 -404
- package/lib/core/server/server.d.ts +1 -1
- package/lib/event/handler/base.d.ts +13 -4
- package/lib/event/handler/base.js +38 -20
- package/lib/event/handler/message.d.ts +11 -7
- package/lib/event/handler/message.js +111 -81
- package/lib/event/handler/notice.d.ts +1 -0
- package/lib/event/handler/notice.js +37 -37
- package/lib/event/handler/request.d.ts +1 -0
- package/lib/event/handler/request.js +32 -37
- package/lib/event/handler/review.d.ts +10 -10
- package/lib/event/handler/review.js +34 -39
- package/lib/types/config/config.d.ts +12 -2
- package/lib/types/event/contact.d.ts +1 -1
- package/lib/types/event/event.d.ts +9 -106
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/plugin/app.d.ts +71 -0
- package/lib/types/plugin/app.js +1 -0
- package/lib/types/plugin/plugin.d.ts +192 -12
- package/lib/utils/common/common.d.ts +19 -7
- package/lib/utils/common/common.js +74 -73
- package/lib/utils/config/config.d.ts +2 -2
- package/lib/utils/core/handler.d.ts +0 -14
- package/lib/utils/core/handler.js +7 -76
- package/lib/utils/tools/button.d.ts +1 -1
- package/lib/utils/tools/button.js +18 -29
- package/package.json +1 -1
- package/lib/core/plugin/app.d.ts +0 -19
- package/lib/core/plugin/app.js +0 -19
package/config/defSet/group.yaml
CHANGED
|
@@ -11,10 +11,10 @@ default:
|
|
|
11
11
|
alias:
|
|
12
12
|
- k
|
|
13
13
|
|
|
14
|
-
# 白名单插件、功能,只有在白名单中的插件、功能才会响应
|
|
14
|
+
# 白名单插件、功能,只有在白名单中的插件、功能才会响应 {plugin: "插件包名", name: "文件名称或插件名称"}
|
|
15
15
|
enable: []
|
|
16
16
|
|
|
17
|
-
# 黑名单插件、功能,黑名单中的插件、功能不会响应
|
|
17
|
+
# 黑名单插件、功能,黑名单中的插件、功能不会响应 {plugin: "插件包名", name: "文件名称或插件名称"}
|
|
18
18
|
disable: []
|
|
19
19
|
|
|
20
20
|
# 单个Bot默认配置
|
|
@@ -30,10 +30,10 @@ Bot.self_id:
|
|
|
30
30
|
alias:
|
|
31
31
|
- k
|
|
32
32
|
|
|
33
|
-
# 白名单插件、功能,只有在白名单中的插件、功能才会响应
|
|
33
|
+
# 白名单插件、功能,只有在白名单中的插件、功能才会响应 {plugin: "插件包名", name: "文件名称或插件名称"}
|
|
34
34
|
enable: []
|
|
35
35
|
|
|
36
|
-
# 黑名单插件、功能,黑名单中的插件、功能不会响应
|
|
36
|
+
# 黑名单插件、功能,黑名单中的插件、功能不会响应 {plugin: "插件包名", name: "文件名称或插件名称"}
|
|
37
37
|
disable: []
|
|
38
38
|
|
|
39
39
|
# 单个Bot单个群配置
|
|
@@ -49,8 +49,8 @@ Bot.self_id.group_id:
|
|
|
49
49
|
alias:
|
|
50
50
|
- k
|
|
51
51
|
|
|
52
|
-
# 白名单插件、功能,只有在白名单中的插件、功能才会响应
|
|
52
|
+
# 白名单插件、功能,只有在白名单中的插件、功能才会响应 {plugin: "插件包名", name: "文件名称或插件名称"}
|
|
53
53
|
enable: []
|
|
54
54
|
|
|
55
|
-
# 黑名单插件、功能,黑名单中的插件、功能不会响应
|
|
55
|
+
# 黑名单插件、功能,黑名单中的插件、功能不会响应 {plugin: "插件包名", name: "文件名称或插件名称"}
|
|
56
56
|
disable: []
|
|
@@ -63,7 +63,7 @@ function fileToBase64(file, bot) {
|
|
|
63
63
|
return file;
|
|
64
64
|
const list = ['127.0.0.1', 'localhost'];
|
|
65
65
|
const url = new URL(bot.adapter.connect);
|
|
66
|
-
return list.includes(url.hostname) ? `base64://${fs.readFileSync(file).toString('base64')}
|
|
66
|
+
return list.includes(url.hostname) ? file : `base64://${fs.readFileSync(file.replace('file://', '')).toString('base64')}`;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* karin转onebot11
|
package/lib/core/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './init/init.js';
|
|
|
3
3
|
export * from './karin/karin.js';
|
|
4
4
|
export * from './listener/listener.js';
|
|
5
5
|
export * from './plugin/base.js';
|
|
6
|
-
export * from '
|
|
6
|
+
export * from '../types/plugin/app.js';
|
|
7
7
|
export * from './plugin/loader.js';
|
|
8
8
|
export * from './process/process.js';
|
|
9
9
|
export * from './server/server.js';
|
package/lib/core/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export * from './init/init.js'
|
|
|
3
3
|
export * from './karin/karin.js'
|
|
4
4
|
export * from './listener/listener.js'
|
|
5
5
|
export * from './plugin/base.js'
|
|
6
|
-
export * from '
|
|
6
|
+
export * from '../types/plugin/app.js'
|
|
7
7
|
export * from './plugin/loader.js'
|
|
8
8
|
export * from './process/process.js'
|
|
9
9
|
export * from './server/server.js'
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { Contact,
|
|
1
|
+
import { Contact, KarinElement, KarinMessage, KarinRenderType, PermissionType, RenderResult, KarinNoticeType, KarinRequestType, KarinMessageType, AllMessageSubType, CommandInfo, TaskInfo, HandlerInfo, AcceptInfo, UseInfo, AllNoticeSubType, AllRequestSubType } from '../../types/index.js';
|
|
2
2
|
type FncFunction = (e: KarinMessage) => Promise<boolean>;
|
|
3
3
|
type FncElement = string | KarinElement | Array<KarinElement>;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* 中间件类型
|
|
6
|
+
*/
|
|
7
|
+
export declare const enum MiddlewareType {
|
|
8
|
+
/** 收到消息后 */
|
|
9
|
+
ReceiveMsg = "recvMsg",
|
|
10
|
+
/** 回复消息前 */
|
|
11
|
+
ReplyMsg = "replyMsg",
|
|
12
|
+
/** 发送主动消息前 */
|
|
13
|
+
SendMsg = "sendMsg"
|
|
14
|
+
}
|
|
15
|
+
export interface Options {
|
|
5
16
|
/**
|
|
6
17
|
* - 插件名称 不传则使用 插件名称:函数名
|
|
7
18
|
*/
|
|
@@ -11,17 +22,23 @@ export interface OptionsCommand {
|
|
|
11
22
|
* @default 10000
|
|
12
23
|
*/
|
|
13
24
|
priority?: number;
|
|
14
|
-
/**
|
|
15
|
-
* - 权限
|
|
16
|
-
* @default 'all'
|
|
17
|
-
*/
|
|
18
|
-
permission?: PermissionType;
|
|
19
25
|
/**
|
|
20
26
|
* - 打印日志
|
|
21
27
|
* @default false
|
|
22
28
|
*/
|
|
23
29
|
log?: boolean | Function;
|
|
24
30
|
}
|
|
31
|
+
export interface OptionsCommand extends Options {
|
|
32
|
+
/**
|
|
33
|
+
* - 监听事件
|
|
34
|
+
*/
|
|
35
|
+
event?: `${AllMessageSubType}`;
|
|
36
|
+
/**
|
|
37
|
+
* - 权限
|
|
38
|
+
* @default 'all'
|
|
39
|
+
*/
|
|
40
|
+
permission?: PermissionType;
|
|
41
|
+
}
|
|
25
42
|
export interface OptionsElement extends OptionsCommand {
|
|
26
43
|
/**
|
|
27
44
|
* - 是否加上at 仅在群聊中有效
|
|
@@ -53,61 +70,41 @@ export declare class Karin {
|
|
|
53
70
|
constructor();
|
|
54
71
|
/**
|
|
55
72
|
* @param reg - 正则表达式
|
|
56
|
-
* @param
|
|
73
|
+
* @param fn - 函数
|
|
57
74
|
* @param options - 选项
|
|
58
75
|
*/
|
|
59
|
-
command(reg: string | RegExp,
|
|
76
|
+
command(reg: string | RegExp, fn: FncFunction, options?: OptionsCommand): CommandInfo;
|
|
60
77
|
/**
|
|
61
78
|
* @param reg - 正则表达式
|
|
62
79
|
* @param element - 字符串或者KarinElement、KarinElement数组
|
|
63
80
|
* @param options - 选项
|
|
64
81
|
*/
|
|
65
|
-
command(reg: string | RegExp, element: FncElement, options?: OptionsElement):
|
|
82
|
+
command(reg: string | RegExp, element: FncElement, options?: OptionsElement): CommandInfo;
|
|
66
83
|
/**
|
|
67
84
|
* - 构建定时任务
|
|
68
85
|
* @param name - 任务名称
|
|
69
86
|
* @param cron - cron表达式
|
|
70
|
-
* @param
|
|
87
|
+
* @param fn - 执行函数
|
|
71
88
|
* @param options - 选项
|
|
72
89
|
*/
|
|
73
|
-
task(name: string, cron: string,
|
|
74
|
-
/**
|
|
75
|
-
* - 任务插件名称
|
|
76
|
-
*/
|
|
77
|
-
name?: string;
|
|
78
|
-
/**
|
|
79
|
-
* - 任务优先级
|
|
80
|
-
*/
|
|
81
|
-
priority?: number;
|
|
82
|
-
/**
|
|
83
|
-
* - 是否打印日志 传递布尔值
|
|
84
|
-
*/
|
|
85
|
-
log?: boolean | Function;
|
|
86
|
-
}): PluginApps;
|
|
90
|
+
task(name: string, cron: string, fn: Function, options?: Omit<Options, 'priority'>): TaskInfo;
|
|
87
91
|
/**
|
|
88
92
|
* - 构建handler
|
|
89
93
|
* @param key - 事件key
|
|
90
|
-
* @param
|
|
94
|
+
* @param fn - 函数实现
|
|
91
95
|
* @param options - 选项
|
|
92
96
|
*/
|
|
93
|
-
handler(key: string,
|
|
97
|
+
handler(key: string, fn: (
|
|
94
98
|
/**
|
|
95
99
|
* - 自定义参数 由调用方传递
|
|
96
100
|
*/
|
|
97
|
-
args:
|
|
101
|
+
args: {
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
},
|
|
98
104
|
/**
|
|
99
|
-
* -
|
|
105
|
+
* - 停止循环函数 调用后则不再继续执行下一个处理器
|
|
100
106
|
*/
|
|
101
|
-
reject: (msg?: string) => void) => Promise<any>, options?:
|
|
102
|
-
/**
|
|
103
|
-
* - 插件名称
|
|
104
|
-
*/
|
|
105
|
-
name?: string;
|
|
106
|
-
/**
|
|
107
|
-
* - handler优先级
|
|
108
|
-
*/
|
|
109
|
-
priority?: number;
|
|
110
|
-
}): PluginApps;
|
|
107
|
+
reject: (msg?: string) => void) => Promise<any>, options?: Omit<Options, 'log'>): HandlerInfo;
|
|
111
108
|
/**
|
|
112
109
|
* 构建contact
|
|
113
110
|
* @param peer - 群号或者id
|
|
@@ -156,22 +153,12 @@ export declare class Karin {
|
|
|
156
153
|
/**
|
|
157
154
|
* accept
|
|
158
155
|
* @param event - 监听事件
|
|
159
|
-
* @param
|
|
156
|
+
* @param fn - 实现函数
|
|
160
157
|
*/
|
|
161
|
-
accept(event:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
name?: string;
|
|
166
|
-
/**
|
|
167
|
-
* - 优先级
|
|
168
|
-
*/
|
|
169
|
-
priority?: number;
|
|
170
|
-
/**
|
|
171
|
-
* - 触发函数是否打印日志
|
|
172
|
-
*/
|
|
173
|
-
log?: boolean;
|
|
174
|
-
}): PluginApps;
|
|
158
|
+
accept(event: AllNoticeSubType | AllRequestSubType, fn: (e: KarinNoticeType | KarinRequestType) => Promise<boolean>, options?: Options): AcceptInfo;
|
|
159
|
+
use(type: `${MiddlewareType.ReceiveMsg}`, fn: (e: KarinMessageType, next: Function) => Promise<void>, options: Omit<Options, 'log'>): UseInfo;
|
|
160
|
+
use(type: `${MiddlewareType.ReplyMsg}`, fn: (e: KarinMessageType, element: KarinElement[], next: Function) => Promise<void>, options: Omit<Options, 'log'>): UseInfo;
|
|
161
|
+
use(type: `${MiddlewareType.SendMsg}`, fn: (uid: string, contact: Contact, elements: KarinElement[]) => Promise<void>, options: Omit<Options, 'log'>): UseInfo;
|
|
175
162
|
/**
|
|
176
163
|
* - 启动
|
|
177
164
|
*/
|
package/lib/core/karin/karin.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { server } from '../server/server.js';
|
|
2
2
|
import { stateArr } from '../plugin/base.js';
|
|
3
|
-
import PluginApp from '../plugin/app.js';
|
|
4
3
|
import { common } from '../../utils/index.js';
|
|
5
4
|
import { listener } from '../listener/listener.js';
|
|
6
5
|
import onebot11 from '../../adapter/onebot/11/index.js';
|
|
@@ -20,7 +19,7 @@ export class Karin {
|
|
|
20
19
|
*/
|
|
21
20
|
command(reg, second, options = {}) {
|
|
22
21
|
reg = typeof reg === 'string' ? new RegExp(reg) : reg;
|
|
23
|
-
const
|
|
22
|
+
const fn = typeof second === 'function'
|
|
24
23
|
? second
|
|
25
24
|
: async (e) => {
|
|
26
25
|
const element = typeof second === 'number' ? String(second) : second;
|
|
@@ -33,72 +32,64 @@ export class Karin {
|
|
|
33
32
|
});
|
|
34
33
|
return !('stop' in options && !options.stop);
|
|
35
34
|
};
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
const log = options.log === false
|
|
36
|
+
? (id, text) => logger.bot('debug', id, text)
|
|
37
|
+
: (id, text) => logger.bot('info', id, text);
|
|
38
|
+
return {
|
|
39
|
+
data: '',
|
|
40
|
+
event: options.event || 'message',
|
|
41
|
+
fn,
|
|
42
|
+
fnname: 'fnc',
|
|
43
|
+
log,
|
|
44
|
+
name: options.name || 'command',
|
|
45
|
+
perm: options.permission || 'all',
|
|
46
|
+
rank: options.priority || 10000,
|
|
47
|
+
reg,
|
|
48
|
+
type: 'command',
|
|
47
49
|
};
|
|
48
|
-
return PluginApp(data);
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* - 构建定时任务
|
|
52
53
|
* @param name - 任务名称
|
|
53
54
|
* @param cron - cron表达式
|
|
54
|
-
* @param
|
|
55
|
+
* @param fn - 执行函数
|
|
55
56
|
* @param options - 选项
|
|
56
57
|
*/
|
|
57
|
-
task(name, cron,
|
|
58
|
+
task(name, cron, fn, options) {
|
|
58
59
|
if (!name)
|
|
59
60
|
throw new Error('[task]: 缺少参数[name]');
|
|
60
61
|
if (!cron)
|
|
61
62
|
throw new Error('[task]: 缺少参数[cron]');
|
|
62
|
-
if (!
|
|
63
|
+
if (!fn)
|
|
63
64
|
throw new Error('[task]: 缺少参数[fnc]');
|
|
64
|
-
const
|
|
65
|
+
const log = options?.log === false ? (text) => logger.debug(text) : (text) => logger.info(text);
|
|
66
|
+
return {
|
|
67
|
+
cron,
|
|
68
|
+
fn,
|
|
69
|
+
log,
|
|
65
70
|
name: options?.name || 'task',
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
name,
|
|
70
|
-
cron,
|
|
71
|
-
fnc,
|
|
72
|
-
log: options?.log ?? true,
|
|
73
|
-
},
|
|
74
|
-
],
|
|
71
|
+
fnname: name,
|
|
72
|
+
type: 'task',
|
|
75
73
|
};
|
|
76
|
-
return PluginApp(data);
|
|
77
74
|
}
|
|
78
75
|
/**
|
|
79
76
|
* - 构建handler
|
|
80
77
|
* @param key - 事件key
|
|
81
|
-
* @param
|
|
78
|
+
* @param fn - 函数实现
|
|
82
79
|
* @param options - 选项
|
|
83
80
|
*/
|
|
84
|
-
handler(key,
|
|
81
|
+
handler(key, fn, options) {
|
|
85
82
|
if (!key)
|
|
86
83
|
throw new Error('[handler]: 缺少参数[key]');
|
|
87
|
-
if (!
|
|
84
|
+
if (!fn)
|
|
88
85
|
throw new Error('[handler]: 缺少参数[fnc]');
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
return {
|
|
87
|
+
fn,
|
|
88
|
+
key,
|
|
91
89
|
name: options?.name || 'handler',
|
|
92
|
-
priority,
|
|
93
|
-
|
|
94
|
-
{
|
|
95
|
-
key,
|
|
96
|
-
fnc,
|
|
97
|
-
priority,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
90
|
+
rank: options?.priority || 10000,
|
|
91
|
+
type: 'handler',
|
|
100
92
|
};
|
|
101
|
-
return PluginApp(data);
|
|
102
93
|
}
|
|
103
94
|
/**
|
|
104
95
|
* 构建contact
|
|
@@ -109,14 +100,14 @@ export class Karin {
|
|
|
109
100
|
contact(peer, isGroup = true, sub_peer) {
|
|
110
101
|
if (isGroup) {
|
|
111
102
|
return {
|
|
112
|
-
scene: "group" /* Scene.Group */,
|
|
113
103
|
peer,
|
|
104
|
+
scene: "group" /* Scene.Group */,
|
|
114
105
|
sub_peer: sub_peer || '',
|
|
115
106
|
};
|
|
116
107
|
}
|
|
117
108
|
return {
|
|
118
|
-
scene: "friend" /* Scene.Private */,
|
|
119
109
|
peer,
|
|
110
|
+
scene: "friend" /* Scene.Private */,
|
|
120
111
|
sub_peer: sub_peer || '',
|
|
121
112
|
};
|
|
122
113
|
}
|
|
@@ -129,9 +120,8 @@ export class Karin {
|
|
|
129
120
|
render(data, multiPage) {
|
|
130
121
|
if (typeof data === 'string') {
|
|
131
122
|
/** 分片 */
|
|
132
|
-
if (typeof multiPage === 'number' || multiPage === true)
|
|
123
|
+
if (typeof multiPage === 'number' || multiPage === true)
|
|
133
124
|
return render.renderMultiHtml(data, multiPage);
|
|
134
|
-
}
|
|
135
125
|
/** 快速渲染 */
|
|
136
126
|
return render.renderHtml(data);
|
|
137
127
|
}
|
|
@@ -165,17 +155,34 @@ export class Karin {
|
|
|
165
155
|
/**
|
|
166
156
|
* accept
|
|
167
157
|
* @param event - 监听事件
|
|
168
|
-
* @param
|
|
158
|
+
* @param fn - 实现函数
|
|
169
159
|
*/
|
|
170
|
-
accept(event,
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
accept(event, fn, options) {
|
|
161
|
+
const log = options?.log === false
|
|
162
|
+
? (id, text) => logger.bot('debug', id, text)
|
|
163
|
+
: (id, text) => logger.bot('info', id, text);
|
|
164
|
+
return {
|
|
174
165
|
event,
|
|
175
|
-
|
|
176
|
-
log
|
|
166
|
+
fn,
|
|
167
|
+
log,
|
|
168
|
+
name: options?.name || 'accept',
|
|
169
|
+
rank: options?.priority || 10000,
|
|
170
|
+
type: 'accept',
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* 中间件
|
|
175
|
+
* @param type 中间件类型
|
|
176
|
+
* @param fn 中间件函数
|
|
177
|
+
*/
|
|
178
|
+
use(type, fn, options) {
|
|
179
|
+
return {
|
|
180
|
+
fn,
|
|
181
|
+
key: type,
|
|
182
|
+
name: options?.name || 'use',
|
|
183
|
+
rank: options?.priority || 10000,
|
|
184
|
+
type: 'use',
|
|
177
185
|
};
|
|
178
|
-
return PluginApp(data);
|
|
179
186
|
}
|
|
180
187
|
/**
|
|
181
188
|
* - 启动
|
|
@@ -176,6 +176,20 @@ export class Listeners extends EventEmitter {
|
|
|
176
176
|
* @param options.retry_count - 重试次数
|
|
177
177
|
*/
|
|
178
178
|
async sendMsg(uid, contact, elements, options = { recallMsg: 0, retry_count: 1 }) {
|
|
179
|
+
/** 先调用中间件 */
|
|
180
|
+
for (const info of pluginLoader.use.sendMsg) {
|
|
181
|
+
try {
|
|
182
|
+
let next = false;
|
|
183
|
+
const nextFn = () => { next = true; };
|
|
184
|
+
await info.fn(uid, contact, elements, nextFn);
|
|
185
|
+
if (!next)
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
logger.error('[消息中间件] 调用失败,已跳过');
|
|
190
|
+
logger.error(e);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
179
193
|
const bot = this.getBot(uid);
|
|
180
194
|
if (!bot)
|
|
181
195
|
throw new Error('发送消息失败: 未找到对应Bot实例');
|
|
@@ -7,17 +7,12 @@ export declare class Plugin implements PluginType {
|
|
|
7
7
|
* @param name - 插件名称
|
|
8
8
|
*/
|
|
9
9
|
name: PluginType['name'];
|
|
10
|
-
/**
|
|
11
|
-
* @param dsc - 插件描述
|
|
12
|
-
* @deprecated 请使用desc
|
|
13
|
-
*/
|
|
14
|
-
dsc: PluginType['dsc'];
|
|
15
10
|
/**
|
|
16
11
|
* @param desc - 插件描述
|
|
17
12
|
*/
|
|
18
13
|
desc: PluginType['desc'];
|
|
19
14
|
/**
|
|
20
|
-
* @param event - 监听事件
|
|
15
|
+
* @param event - 监听事件 仅支持消息事件 其他事件请使用accept
|
|
21
16
|
*/
|
|
22
17
|
event: PluginType['event'];
|
|
23
18
|
/**
|
|
@@ -25,7 +20,8 @@ export declare class Plugin implements PluginType {
|
|
|
25
20
|
*/
|
|
26
21
|
priority: PluginType['priority'];
|
|
27
22
|
/**
|
|
28
|
-
* @param task - 定时任务
|
|
23
|
+
* @param task - 定时任务 即将废弃 请使用karin.task
|
|
24
|
+
* @deprecated
|
|
29
25
|
*/
|
|
30
26
|
task: PluginType['task'];
|
|
31
27
|
/**
|
|
@@ -33,11 +29,8 @@ export declare class Plugin implements PluginType {
|
|
|
33
29
|
*/
|
|
34
30
|
rule: PluginType['rule'];
|
|
35
31
|
/**
|
|
36
|
-
* @param
|
|
37
|
-
|
|
38
|
-
button: PluginType['button'];
|
|
39
|
-
/**
|
|
40
|
-
* @param handler - handler
|
|
32
|
+
* @param handler - handler 已废弃 请使用karin.handler
|
|
33
|
+
* @deprecated
|
|
41
34
|
*/
|
|
42
35
|
handler: PluginType['handler'];
|
|
43
36
|
/**
|
|
@@ -48,15 +41,11 @@ export declare class Plugin implements PluginType {
|
|
|
48
41
|
* @param timeout - 上下文超时
|
|
49
42
|
*/
|
|
50
43
|
timeout: PluginType['timeout'];
|
|
51
|
-
constructor({ name,
|
|
44
|
+
constructor({ name, desc, event, priority, task, rule, handler, }: {
|
|
52
45
|
/**
|
|
53
46
|
* - 插件名称
|
|
54
47
|
*/
|
|
55
48
|
name: string;
|
|
56
|
-
/**
|
|
57
|
-
* - 插件描述 没有则默认为名称
|
|
58
|
-
*/
|
|
59
|
-
dsc: string;
|
|
60
49
|
/**
|
|
61
50
|
* - 插件描述 没有则默认为插件名称
|
|
62
51
|
*/
|
|
@@ -70,7 +59,8 @@ export declare class Plugin implements PluginType {
|
|
|
70
59
|
*/
|
|
71
60
|
priority?: PluginType['priority'];
|
|
72
61
|
/**
|
|
73
|
-
* - 定时任务
|
|
62
|
+
* - 定时任务 即将废弃 请使用karin.task
|
|
63
|
+
* @deprecated
|
|
74
64
|
*/
|
|
75
65
|
task?: PluginType['task'];
|
|
76
66
|
/**
|
|
@@ -78,13 +68,10 @@ export declare class Plugin implements PluginType {
|
|
|
78
68
|
*/
|
|
79
69
|
rule?: PluginType['rule'];
|
|
80
70
|
/**
|
|
81
|
-
* - handler
|
|
71
|
+
* - handler 已废弃 请使用karin.handler
|
|
72
|
+
* @deprecated
|
|
82
73
|
*/
|
|
83
74
|
handler?: PluginType['handler'];
|
|
84
|
-
/**
|
|
85
|
-
* - 按钮
|
|
86
|
-
*/
|
|
87
|
-
button?: PluginType['button'];
|
|
88
75
|
});
|
|
89
76
|
/**
|
|
90
77
|
* - 快速回复
|
package/lib/core/plugin/base.js
CHANGED
|
@@ -6,17 +6,12 @@ export class Plugin {
|
|
|
6
6
|
* @param name - 插件名称
|
|
7
7
|
*/
|
|
8
8
|
name;
|
|
9
|
-
/**
|
|
10
|
-
* @param dsc - 插件描述
|
|
11
|
-
* @deprecated 请使用desc
|
|
12
|
-
*/
|
|
13
|
-
dsc;
|
|
14
9
|
/**
|
|
15
10
|
* @param desc - 插件描述
|
|
16
11
|
*/
|
|
17
12
|
desc;
|
|
18
13
|
/**
|
|
19
|
-
* @param event - 监听事件
|
|
14
|
+
* @param event - 监听事件 仅支持消息事件 其他事件请使用accept
|
|
20
15
|
*/
|
|
21
16
|
event;
|
|
22
17
|
/**
|
|
@@ -24,7 +19,8 @@ export class Plugin {
|
|
|
24
19
|
*/
|
|
25
20
|
priority;
|
|
26
21
|
/**
|
|
27
|
-
* @param task - 定时任务
|
|
22
|
+
* @param task - 定时任务 即将废弃 请使用karin.task
|
|
23
|
+
* @deprecated
|
|
28
24
|
*/
|
|
29
25
|
task;
|
|
30
26
|
/**
|
|
@@ -32,11 +28,8 @@ export class Plugin {
|
|
|
32
28
|
*/
|
|
33
29
|
rule;
|
|
34
30
|
/**
|
|
35
|
-
* @param
|
|
36
|
-
|
|
37
|
-
button;
|
|
38
|
-
/**
|
|
39
|
-
* @param handler - handler
|
|
31
|
+
* @param handler - handler 已废弃 请使用karin.handler
|
|
32
|
+
* @deprecated
|
|
40
33
|
*/
|
|
41
34
|
handler;
|
|
42
35
|
/**
|
|
@@ -47,15 +40,13 @@ export class Plugin {
|
|
|
47
40
|
* @param timeout - 上下文超时
|
|
48
41
|
*/
|
|
49
42
|
timeout;
|
|
50
|
-
constructor({ name,
|
|
43
|
+
constructor({ name, desc = name, event = "message" /* EventType.Message */, priority = 10000, task = [], rule = [], handler = [], }) {
|
|
51
44
|
this.name = name;
|
|
52
|
-
this.dsc = dsc;
|
|
53
45
|
this.desc = desc;
|
|
54
46
|
this.event = event;
|
|
55
47
|
this.priority = priority;
|
|
56
48
|
this.task = task;
|
|
57
49
|
this.rule = rule;
|
|
58
|
-
this.button = button;
|
|
59
50
|
this.handler = handler;
|
|
60
51
|
}
|
|
61
52
|
/**
|