node-karin 0.0.3 → 0.1.0
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/LICENSE +674 -674
- package/README.md +57 -57
- package/config/defSet/App.yaml +37 -37
- package/config/defSet/config.yaml +43 -43
- package/config/defSet/group.yaml +18 -18
- package/config/defSet/pm2.yaml +21 -21
- package/config/defSet/server.yaml +42 -42
- package/config/view/App.yaml +74 -74
- package/config/view/config.yaml +100 -100
- package/config/view/group.yaml +62 -62
- package/config/view/pm2.yaml +41 -41
- package/config/view/redis.yaml +25 -25
- package/config/view/server.yaml +93 -93
- package/lib/adapter/onebot/onebot11.d.ts +430 -430
- package/lib/adapter/onebot/onebot11.js +1265 -1302
- package/lib/core/init.js +4 -4
- package/lib/core/karin.d.ts +72 -72
- package/lib/core/karin.js +51 -51
- package/lib/core/listener.d.ts +121 -121
- package/lib/core/listener.js +178 -178
- package/lib/core/plugin.app.d.ts +15 -15
- package/lib/core/plugin.app.js +18 -18
- package/lib/core/plugin.d.ts +182 -182
- package/lib/core/plugin.js +132 -132
- package/lib/core/plugin.loader.d.ts +149 -149
- package/lib/core/plugin.loader.js +451 -451
- package/lib/core/server.d.ts +26 -26
- package/lib/core/server.js +209 -209
- package/lib/db/level.d.ts +20 -20
- package/lib/db/level.js +36 -36
- package/lib/db/redis.d.ts +41 -41
- package/lib/db/redis.js +131 -131
- package/lib/db/redis_level.d.ts +113 -113
- package/lib/db/redis_level.js +274 -274
- package/lib/event/event.d.ts +138 -138
- package/lib/event/event.handler.d.ts +29 -29
- package/lib/event/event.handler.js +138 -138
- package/lib/event/event.js +120 -120
- package/lib/event/message.d.ts +102 -102
- package/lib/event/message.handler.d.ts +25 -25
- package/lib/event/message.handler.js +237 -237
- package/lib/event/message.js +69 -69
- package/lib/event/notice.d.ts +49 -49
- package/lib/event/notice.js +14 -14
- package/lib/event/request.d.ts +49 -49
- package/lib/event/request.js +14 -14
- package/lib/event/review.handler.d.ts +54 -54
- package/lib/event/review.handler.js +374 -374
- package/lib/index.d.ts +23 -23
- package/lib/index.js +39 -40
- package/lib/renderer/app.d.ts +53 -53
- package/lib/renderer/app.js +88 -88
- package/lib/renderer/base.d.ts +30 -30
- package/lib/renderer/base.js +68 -68
- package/lib/renderer/client.d.ts +30 -30
- package/lib/renderer/client.js +155 -155
- package/lib/renderer/http.d.ts +19 -19
- package/lib/renderer/http.js +50 -50
- package/lib/renderer/server.d.ts +42 -42
- package/lib/renderer/server.js +110 -110
- package/lib/renderer/wormhole.d.ts +1 -1
- package/lib/renderer/wormhole.js +154 -154
- package/lib/types/adapter.d.ts +575 -575
- package/lib/types/adapter.js +1 -1
- package/lib/types/config.d.ts +327 -327
- package/lib/types/config.js +1 -1
- package/lib/types/element.d.ts +576 -576
- package/lib/types/element.js +1 -1
- package/lib/types/index.d.ts +8 -8
- package/lib/types/index.js +8 -8
- package/lib/types/logger.d.ts +109 -109
- package/lib/types/logger.js +1 -1
- package/lib/types/onebots11.d.ts +1371 -1371
- package/lib/types/onebots11.js +1 -1
- package/lib/types/plugin.d.ts +282 -282
- package/lib/types/plugin.js +1 -1
- package/lib/types/render.d.ts +111 -111
- package/lib/types/render.js +1 -1
- package/lib/types/reply.d.ts +40 -40
- package/lib/types/reply.js +1 -1
- package/lib/types/types.d.ts +898 -898
- package/lib/types/types.js +1 -1
- package/lib/utils/YamlEditor.d.ts +62 -62
- package/lib/utils/YamlEditor.js +197 -197
- package/lib/utils/button.d.ts +49 -49
- package/lib/utils/button.js +75 -75
- package/lib/utils/common.d.ts +123 -123
- package/lib/utils/common.js +396 -396
- package/lib/utils/config.d.ts +72 -72
- package/lib/utils/config.js +254 -254
- package/lib/utils/exec.d.ts +22 -22
- package/lib/utils/exec.js +36 -36
- package/lib/utils/ffmpeg.d.ts +12 -12
- package/lib/utils/ffmpeg.js +25 -25
- package/lib/utils/handler.d.ts +76 -76
- package/lib/utils/handler.js +98 -98
- package/lib/utils/logger.d.ts +3 -3
- package/lib/utils/logger.js +104 -104
- package/lib/utils/segment.d.ts +276 -276
- package/lib/utils/segment.js +420 -420
- package/lib/utils/update.d.ts +69 -69
- package/lib/utils/update.js +145 -145
- package/lib/utils/updateVersion.d.ts +33 -33
- package/lib/utils/updateVersion.js +140 -140
- package/package.json +92 -91
package/lib/core/init.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
process.title = 'karin'
|
|
3
|
-
process.env.karin_app_mode = process.argv[2]?.includes('dev') ? 'dev' : 'prod'
|
|
4
|
-
process.env.karin_app_lang = JSON.stringify(process.execArgv).includes('tsx@') ? 'ts' : 'js'
|
|
1
|
+
'use strict'
|
|
2
|
+
process.title = 'karin'
|
|
3
|
+
process.env.karin_app_mode = process.argv[2]?.includes('dev') ? 'dev' : 'prod'
|
|
4
|
+
process.env.karin_app_lang = JSON.stringify(process.execArgv).includes('tsx@') ? 'ts' : 'js'
|
package/lib/core/karin.d.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { Permission } from '../types/types.js';
|
|
2
|
-
import { PluginApps } from '../types/plugin.js';
|
|
3
|
-
import { KarinElement } from '../types/element.js';
|
|
4
|
-
import { KarinMessage } from '../event/message.js';
|
|
5
|
-
type FncFunction = (e: KarinMessage) => Promise<boolean>;
|
|
6
|
-
type FncElement = string | KarinElement | Array<KarinElement>;
|
|
7
|
-
export interface OptionsCommand {
|
|
8
|
-
/**
|
|
9
|
-
* - 插件名称 不传则使用 插件名称:函数名
|
|
10
|
-
*/
|
|
11
|
-
name?: string;
|
|
12
|
-
/**
|
|
13
|
-
* - 插件描述
|
|
14
|
-
*/
|
|
15
|
-
desc?: string;
|
|
16
|
-
/**
|
|
17
|
-
* - 插件优先级 数字越小优先级越高
|
|
18
|
-
* @default 10000
|
|
19
|
-
*/
|
|
20
|
-
priority?: number;
|
|
21
|
-
/**
|
|
22
|
-
* - 权限
|
|
23
|
-
* @default 'all'
|
|
24
|
-
*/
|
|
25
|
-
permission?: Permission;
|
|
26
|
-
/**
|
|
27
|
-
* - 打印日志
|
|
28
|
-
* @default false
|
|
29
|
-
*/
|
|
30
|
-
log?: boolean | Function;
|
|
31
|
-
}
|
|
32
|
-
export interface OptionsElement extends OptionsCommand {
|
|
33
|
-
/**
|
|
34
|
-
* - 是否加上at 仅在群聊中有效
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
37
|
-
at?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* - 是否加上引用回复
|
|
40
|
-
* @default false
|
|
41
|
-
*/
|
|
42
|
-
reply?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* - 延迟回复 单位毫秒
|
|
45
|
-
*/
|
|
46
|
-
delay?: number;
|
|
47
|
-
/**
|
|
48
|
-
* - 发送是否撤回消息 单位秒
|
|
49
|
-
* @default 0
|
|
50
|
-
*/
|
|
51
|
-
recallMsg?: number;
|
|
52
|
-
/**
|
|
53
|
-
* - 是否停止执行后续插件
|
|
54
|
-
* @default true
|
|
55
|
-
*/
|
|
56
|
-
stop?: boolean;
|
|
57
|
-
}
|
|
58
|
-
export default class Karin {
|
|
59
|
-
/**
|
|
60
|
-
* @param reg - 正则表达式
|
|
61
|
-
* @param fnc - 函数
|
|
62
|
-
* @param options - 选项
|
|
63
|
-
*/
|
|
64
|
-
command(reg: string | RegExp, fnc: FncFunction, options?: OptionsCommand): PluginApps;
|
|
65
|
-
/**
|
|
66
|
-
* @param reg - 正则表达式
|
|
67
|
-
* @param element - 字符串或者KarinElement、KarinElement数组
|
|
68
|
-
* @param options - 选项
|
|
69
|
-
*/
|
|
70
|
-
command(reg: string | RegExp, element: FncElement, options?: OptionsElement): PluginApps;
|
|
71
|
-
}
|
|
72
|
-
export {};
|
|
1
|
+
import { Permission } from '../types/types.js';
|
|
2
|
+
import { PluginApps } from '../types/plugin.js';
|
|
3
|
+
import { KarinElement } from '../types/element.js';
|
|
4
|
+
import { KarinMessage } from '../event/message.js';
|
|
5
|
+
type FncFunction = (e: KarinMessage) => Promise<boolean>;
|
|
6
|
+
type FncElement = string | KarinElement | Array<KarinElement>;
|
|
7
|
+
export interface OptionsCommand {
|
|
8
|
+
/**
|
|
9
|
+
* - 插件名称 不传则使用 插件名称:函数名
|
|
10
|
+
*/
|
|
11
|
+
name?: string;
|
|
12
|
+
/**
|
|
13
|
+
* - 插件描述
|
|
14
|
+
*/
|
|
15
|
+
desc?: string;
|
|
16
|
+
/**
|
|
17
|
+
* - 插件优先级 数字越小优先级越高
|
|
18
|
+
* @default 10000
|
|
19
|
+
*/
|
|
20
|
+
priority?: number;
|
|
21
|
+
/**
|
|
22
|
+
* - 权限
|
|
23
|
+
* @default 'all'
|
|
24
|
+
*/
|
|
25
|
+
permission?: Permission;
|
|
26
|
+
/**
|
|
27
|
+
* - 打印日志
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
log?: boolean | Function;
|
|
31
|
+
}
|
|
32
|
+
export interface OptionsElement extends OptionsCommand {
|
|
33
|
+
/**
|
|
34
|
+
* - 是否加上at 仅在群聊中有效
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
at?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* - 是否加上引用回复
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
reply?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* - 延迟回复 单位毫秒
|
|
45
|
+
*/
|
|
46
|
+
delay?: number;
|
|
47
|
+
/**
|
|
48
|
+
* - 发送是否撤回消息 单位秒
|
|
49
|
+
* @default 0
|
|
50
|
+
*/
|
|
51
|
+
recallMsg?: number;
|
|
52
|
+
/**
|
|
53
|
+
* - 是否停止执行后续插件
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
stop?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export default class Karin {
|
|
59
|
+
/**
|
|
60
|
+
* @param reg - 正则表达式
|
|
61
|
+
* @param fnc - 函数
|
|
62
|
+
* @param options - 选项
|
|
63
|
+
*/
|
|
64
|
+
command(reg: string | RegExp, fnc: FncFunction, options?: OptionsCommand): PluginApps;
|
|
65
|
+
/**
|
|
66
|
+
* @param reg - 正则表达式
|
|
67
|
+
* @param element - 字符串或者KarinElement、KarinElement数组
|
|
68
|
+
* @param options - 选项
|
|
69
|
+
*/
|
|
70
|
+
command(reg: string | RegExp, element: FncElement, options?: OptionsElement): PluginApps;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
package/lib/core/karin.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import common from '../utils/common.js'
|
|
2
|
-
import PluginApp from './plugin.app.js'
|
|
3
|
-
export default class Karin {
|
|
4
|
-
/**
|
|
5
|
-
* - 快速构建命令
|
|
6
|
-
* @param reg - 正则表达式
|
|
7
|
-
* @param second - 函数或者字符串或者KarinElement、KarinElement数组
|
|
8
|
-
* @param options - 选项
|
|
9
|
-
* @returns - 返回插件对象
|
|
10
|
-
*/
|
|
11
|
-
command (reg, second, options = {}) {
|
|
12
|
-
const Reg = typeof reg === 'string' ? new RegExp(reg) : reg
|
|
13
|
-
const data = {
|
|
14
|
-
name: options.name || 'function',
|
|
15
|
-
priority: options.priority,
|
|
16
|
-
rule: [
|
|
17
|
-
{
|
|
18
|
-
reg: Reg,
|
|
19
|
-
fnc: second,
|
|
20
|
-
permission: options.permission || 'all',
|
|
21
|
-
log: options.log ?? true,
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
}
|
|
25
|
-
switch (typeof second) {
|
|
26
|
-
case 'function': {
|
|
27
|
-
return PluginApp(data)
|
|
28
|
-
}
|
|
29
|
-
case 'string':
|
|
30
|
-
case 'number':
|
|
31
|
-
case 'object': {
|
|
32
|
-
const element = common.makeMessage(typeof second === 'function' ? second : String(second))
|
|
33
|
-
const fnc = async (e) => {
|
|
34
|
-
if ('delay' in options && options.delay) { await common.sleep(options.delay) }
|
|
35
|
-
await e.reply(element, {
|
|
36
|
-
at: ('at' in options && options.at) || false,
|
|
37
|
-
reply: ('reply' in options && options.reply) || false,
|
|
38
|
-
recallMsg: ('recallMsg' in options && Number(options.recallMsg)) || 0,
|
|
39
|
-
})
|
|
40
|
-
if ('stop' in options && !options.stop) { return false }
|
|
41
|
-
return true
|
|
42
|
-
}
|
|
43
|
-
data.rule[0].fnc = fnc
|
|
44
|
-
return PluginApp(data)
|
|
45
|
-
}
|
|
46
|
-
default: {
|
|
47
|
-
throw new Error('command: second argument must be a function or string')
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
import common from '../utils/common.js'
|
|
2
|
+
import PluginApp from './plugin.app.js'
|
|
3
|
+
export default class Karin {
|
|
4
|
+
/**
|
|
5
|
+
* - 快速构建命令
|
|
6
|
+
* @param reg - 正则表达式
|
|
7
|
+
* @param second - 函数或者字符串或者KarinElement、KarinElement数组
|
|
8
|
+
* @param options - 选项
|
|
9
|
+
* @returns - 返回插件对象
|
|
10
|
+
*/
|
|
11
|
+
command (reg, second, options = {}) {
|
|
12
|
+
const Reg = typeof reg === 'string' ? new RegExp(reg) : reg
|
|
13
|
+
const data = {
|
|
14
|
+
name: options.name || 'function',
|
|
15
|
+
priority: options.priority,
|
|
16
|
+
rule: [
|
|
17
|
+
{
|
|
18
|
+
reg: Reg,
|
|
19
|
+
fnc: second,
|
|
20
|
+
permission: options.permission || 'all',
|
|
21
|
+
log: options.log ?? true,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
}
|
|
25
|
+
switch (typeof second) {
|
|
26
|
+
case 'function': {
|
|
27
|
+
return PluginApp(data)
|
|
28
|
+
}
|
|
29
|
+
case 'string':
|
|
30
|
+
case 'number':
|
|
31
|
+
case 'object': {
|
|
32
|
+
const element = common.makeMessage(typeof second === 'function' ? second : String(second))
|
|
33
|
+
const fnc = async (e) => {
|
|
34
|
+
if ('delay' in options && options.delay) { await common.sleep(options.delay) }
|
|
35
|
+
await e.reply(element, {
|
|
36
|
+
at: ('at' in options && options.at) || false,
|
|
37
|
+
reply: ('reply' in options && options.reply) || false,
|
|
38
|
+
recallMsg: ('recallMsg' in options && Number(options.recallMsg)) || 0,
|
|
39
|
+
})
|
|
40
|
+
if ('stop' in options && !options.stop) { return false }
|
|
41
|
+
return true
|
|
42
|
+
}
|
|
43
|
+
data.rule[0].fnc = fnc
|
|
44
|
+
return PluginApp(data)
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
throw new Error('command: second argument must be a function or string')
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
package/lib/core/listener.d.ts
CHANGED
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
import { KarinAdapter } from '../types/adapter.js';
|
|
4
|
-
import { contact } from '../types/types.js';
|
|
5
|
-
import { KarinElement } from '../types/element.js';
|
|
6
|
-
/**
|
|
7
|
-
* 监听器管理
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: {
|
|
10
|
-
/**
|
|
11
|
-
* Bot索引
|
|
12
|
-
* @type - Bot索引
|
|
13
|
-
*/
|
|
14
|
-
index: number;
|
|
15
|
-
/**
|
|
16
|
-
* 框架名称
|
|
17
|
-
*/
|
|
18
|
-
name: string;
|
|
19
|
-
list: Array<{
|
|
20
|
-
index: number;
|
|
21
|
-
type: KarinAdapter['adapter']['type'];
|
|
22
|
-
bot: KarinAdapter;
|
|
23
|
-
}>;
|
|
24
|
-
adapter: Array<{
|
|
25
|
-
type: KarinAdapter['adapter']['type'];
|
|
26
|
-
adapter: new () => KarinAdapter;
|
|
27
|
-
path: string;
|
|
28
|
-
}>;
|
|
29
|
-
/**
|
|
30
|
-
* 注册Bot 返回索引id
|
|
31
|
-
*/
|
|
32
|
-
addBot(data: {
|
|
33
|
-
bot: KarinAdapter;
|
|
34
|
-
type: KarinAdapter['adapter']['type'];
|
|
35
|
-
}): number | false;
|
|
36
|
-
/**
|
|
37
|
-
* 卸载Bot
|
|
38
|
-
* @param index - Bot的索引id
|
|
39
|
-
*/
|
|
40
|
-
delBot(index: number): void;
|
|
41
|
-
/**
|
|
42
|
-
* 通过Bot uid 获取Bot
|
|
43
|
-
* @param uid - Bot的uid 未传入则返回第一个Bot
|
|
44
|
-
*/
|
|
45
|
-
getBot(uid?: string): KarinAdapter | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* 根据索引获取Bot
|
|
48
|
-
* @param index - Bot的索引id
|
|
49
|
-
*/
|
|
50
|
-
getBotByIndex(index: number): KarinAdapter;
|
|
51
|
-
/**
|
|
52
|
-
* 获取当前已注册Bot数量
|
|
53
|
-
*/
|
|
54
|
-
getBotCount(): number;
|
|
55
|
-
/**
|
|
56
|
-
* 获取所有Bot列表
|
|
57
|
-
* @param isIndex - 是否返回包含的索引列表 默认返回Bot实例列表
|
|
58
|
-
*/
|
|
59
|
-
getBotAll(isIndex?: boolean): KarinAdapter[] | {
|
|
60
|
-
index: number;
|
|
61
|
-
bot: KarinAdapter;
|
|
62
|
-
}[];
|
|
63
|
-
/**
|
|
64
|
-
* 注册适配器
|
|
65
|
-
* @param data - 适配器信息
|
|
66
|
-
* @param data.type - 适配器类型
|
|
67
|
-
* @param data.adapter - 适配器实例
|
|
68
|
-
* @param data.path - 适配器路径
|
|
69
|
-
*/
|
|
70
|
-
addAdapter(data: {
|
|
71
|
-
type: KarinAdapter['adapter']['type'];
|
|
72
|
-
adapter: new () => KarinAdapter;
|
|
73
|
-
path?: string;
|
|
74
|
-
}): void;
|
|
75
|
-
/**
|
|
76
|
-
* 通过path获取适配器 仅适用于反向WS适配器
|
|
77
|
-
* @param path - 适配器路径
|
|
78
|
-
*/
|
|
79
|
-
getAdapter(path?: string): (new () => KarinAdapter) | undefined;
|
|
80
|
-
/**
|
|
81
|
-
* 获取适配器列表
|
|
82
|
-
* @param isType - 是否返回包含的类型列表 默认返回适配器实例列表
|
|
83
|
-
*/
|
|
84
|
-
getAdapterAll(isType?: boolean): {
|
|
85
|
-
type: KarinAdapter['adapter']['type'];
|
|
86
|
-
adapter: new () => KarinAdapter;
|
|
87
|
-
path: string;
|
|
88
|
-
}[] | (new () => KarinAdapter)[];
|
|
89
|
-
/**
|
|
90
|
-
* 发送主动消息
|
|
91
|
-
* @param uid - Bot的uid
|
|
92
|
-
* @param contact - 目标信息
|
|
93
|
-
* @param elements - 消息内容
|
|
94
|
-
* @param options - 消息选项
|
|
95
|
-
* @param options.recallMsg - 发送成功后撤回消息时间
|
|
96
|
-
* @param options.retry_count - 重试次数
|
|
97
|
-
*/
|
|
98
|
-
sendMsg(uid: string, contact: contact, elements: KarinElement, options?: {
|
|
99
|
-
recallMsg: number;
|
|
100
|
-
retry_count: number;
|
|
101
|
-
}): Promise<{
|
|
102
|
-
message_id: string;
|
|
103
|
-
}>;
|
|
104
|
-
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
|
|
105
|
-
addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
106
|
-
on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
107
|
-
once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
108
|
-
removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
109
|
-
off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
110
|
-
removeAllListeners(eventName?: string | symbol | undefined): any;
|
|
111
|
-
setMaxListeners(n: number): any;
|
|
112
|
-
getMaxListeners(): number;
|
|
113
|
-
listeners<K_6>(eventName: string | symbol): Function[];
|
|
114
|
-
rawListeners<K_7>(eventName: string | symbol): Function[];
|
|
115
|
-
emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
|
|
116
|
-
listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
|
|
117
|
-
prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
118
|
-
prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
119
|
-
eventNames(): (string | symbol)[];
|
|
120
|
-
};
|
|
121
|
-
export default _default;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { KarinAdapter } from '../types/adapter.js';
|
|
4
|
+
import { contact } from '../types/types.js';
|
|
5
|
+
import { KarinElement } from '../types/element.js';
|
|
6
|
+
/**
|
|
7
|
+
* 监听器管理
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: {
|
|
10
|
+
/**
|
|
11
|
+
* Bot索引
|
|
12
|
+
* @type - Bot索引
|
|
13
|
+
*/
|
|
14
|
+
index: number;
|
|
15
|
+
/**
|
|
16
|
+
* 框架名称
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
list: Array<{
|
|
20
|
+
index: number;
|
|
21
|
+
type: KarinAdapter['adapter']['type'];
|
|
22
|
+
bot: KarinAdapter;
|
|
23
|
+
}>;
|
|
24
|
+
adapter: Array<{
|
|
25
|
+
type: KarinAdapter['adapter']['type'];
|
|
26
|
+
adapter: new () => KarinAdapter;
|
|
27
|
+
path: string;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* 注册Bot 返回索引id
|
|
31
|
+
*/
|
|
32
|
+
addBot(data: {
|
|
33
|
+
bot: KarinAdapter;
|
|
34
|
+
type: KarinAdapter['adapter']['type'];
|
|
35
|
+
}): number | false;
|
|
36
|
+
/**
|
|
37
|
+
* 卸载Bot
|
|
38
|
+
* @param index - Bot的索引id
|
|
39
|
+
*/
|
|
40
|
+
delBot(index: number): void;
|
|
41
|
+
/**
|
|
42
|
+
* 通过Bot uid 获取Bot
|
|
43
|
+
* @param uid - Bot的uid 未传入则返回第一个Bot
|
|
44
|
+
*/
|
|
45
|
+
getBot(uid?: string): KarinAdapter | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* 根据索引获取Bot
|
|
48
|
+
* @param index - Bot的索引id
|
|
49
|
+
*/
|
|
50
|
+
getBotByIndex(index: number): KarinAdapter;
|
|
51
|
+
/**
|
|
52
|
+
* 获取当前已注册Bot数量
|
|
53
|
+
*/
|
|
54
|
+
getBotCount(): number;
|
|
55
|
+
/**
|
|
56
|
+
* 获取所有Bot列表
|
|
57
|
+
* @param isIndex - 是否返回包含的索引列表 默认返回Bot实例列表
|
|
58
|
+
*/
|
|
59
|
+
getBotAll(isIndex?: boolean): KarinAdapter[] | {
|
|
60
|
+
index: number;
|
|
61
|
+
bot: KarinAdapter;
|
|
62
|
+
}[];
|
|
63
|
+
/**
|
|
64
|
+
* 注册适配器
|
|
65
|
+
* @param data - 适配器信息
|
|
66
|
+
* @param data.type - 适配器类型
|
|
67
|
+
* @param data.adapter - 适配器实例
|
|
68
|
+
* @param data.path - 适配器路径
|
|
69
|
+
*/
|
|
70
|
+
addAdapter(data: {
|
|
71
|
+
type: KarinAdapter['adapter']['type'];
|
|
72
|
+
adapter: new () => KarinAdapter;
|
|
73
|
+
path?: string;
|
|
74
|
+
}): void;
|
|
75
|
+
/**
|
|
76
|
+
* 通过path获取适配器 仅适用于反向WS适配器
|
|
77
|
+
* @param path - 适配器路径
|
|
78
|
+
*/
|
|
79
|
+
getAdapter(path?: string): (new () => KarinAdapter) | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* 获取适配器列表
|
|
82
|
+
* @param isType - 是否返回包含的类型列表 默认返回适配器实例列表
|
|
83
|
+
*/
|
|
84
|
+
getAdapterAll(isType?: boolean): {
|
|
85
|
+
type: KarinAdapter['adapter']['type'];
|
|
86
|
+
adapter: new () => KarinAdapter;
|
|
87
|
+
path: string;
|
|
88
|
+
}[] | (new () => KarinAdapter)[];
|
|
89
|
+
/**
|
|
90
|
+
* 发送主动消息
|
|
91
|
+
* @param uid - Bot的uid
|
|
92
|
+
* @param contact - 目标信息
|
|
93
|
+
* @param elements - 消息内容
|
|
94
|
+
* @param options - 消息选项
|
|
95
|
+
* @param options.recallMsg - 发送成功后撤回消息时间
|
|
96
|
+
* @param options.retry_count - 重试次数
|
|
97
|
+
*/
|
|
98
|
+
sendMsg(uid: string, contact: contact, elements: KarinElement, options?: {
|
|
99
|
+
recallMsg: number;
|
|
100
|
+
retry_count: number;
|
|
101
|
+
}): Promise<{
|
|
102
|
+
message_id: string;
|
|
103
|
+
}>;
|
|
104
|
+
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
|
|
105
|
+
addListener<K_1>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
106
|
+
on<K_2>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
107
|
+
once<K_3>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
108
|
+
removeListener<K_4>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
109
|
+
off<K_5>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
110
|
+
removeAllListeners(eventName?: string | symbol | undefined): any;
|
|
111
|
+
setMaxListeners(n: number): any;
|
|
112
|
+
getMaxListeners(): number;
|
|
113
|
+
listeners<K_6>(eventName: string | symbol): Function[];
|
|
114
|
+
rawListeners<K_7>(eventName: string | symbol): Function[];
|
|
115
|
+
emit<K_8>(eventName: string | symbol, ...args: any[]): boolean;
|
|
116
|
+
listenerCount<K_9>(eventName: string | symbol, listener?: Function | undefined): number;
|
|
117
|
+
prependListener<K_10>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
118
|
+
prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
119
|
+
eventNames(): (string | symbol)[];
|
|
120
|
+
};
|
|
121
|
+
export default _default;
|