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/listener.js
CHANGED
|
@@ -1,188 +1,188 @@
|
|
|
1
|
-
import { EventEmitter } from 'events'
|
|
2
|
-
import loader from './plugin.loader.js'
|
|
3
|
-
import Common from '../utils/common.js'
|
|
4
|
-
import logger from '../utils/logger.js'
|
|
5
|
-
import Config from '../utils/config.js'
|
|
6
|
-
import MessageHandller from '../event/message.handler.js'
|
|
7
|
-
/**
|
|
8
|
-
* 监听器管理
|
|
9
|
-
*/
|
|
10
|
-
export default new (class Listeners extends EventEmitter {
|
|
11
|
-
/**
|
|
12
|
-
* Bot索引
|
|
13
|
-
* @type - Bot索引
|
|
14
|
-
*/
|
|
15
|
-
index
|
|
16
|
-
/**
|
|
17
|
-
* 框架名称
|
|
18
|
-
*/
|
|
19
|
-
name
|
|
20
|
-
list
|
|
21
|
-
adapter
|
|
22
|
-
constructor () {
|
|
23
|
-
super()
|
|
24
|
-
this.index = 0
|
|
25
|
-
this.name = 'Karin'
|
|
26
|
-
this.list = []
|
|
27
|
-
this.adapter = []
|
|
28
|
-
this.on('error', data => logger.error(data))
|
|
29
|
-
this.on('plugin', () => loader.load())
|
|
30
|
-
this.on('adapter', data => {
|
|
31
|
-
let path = data.path || '无'
|
|
32
|
-
if (path && data.type !== 'grpc') { path = `ws://127.0.0.1:/${Config.Server.http.port}${data.path}` }
|
|
33
|
-
path = logger.green(path)
|
|
34
|
-
logger.info(`[适配器][注册][${data.type}] ` + path)
|
|
35
|
-
this.addAdapter(data)
|
|
36
|
-
})
|
|
37
|
-
this.on('bot', data => {
|
|
38
|
-
this.addBot(data)
|
|
39
|
-
logger.info(`[机器人][注册][${data.type}] ` + logger.green(`[account:${data.bot.account.uid || data.bot.account.uin}(${data.bot.account.name})]`))
|
|
40
|
-
this.emit('karin:online', data.bot.account.uid || data.bot.account.uin)
|
|
41
|
-
})
|
|
42
|
-
this.on('message', data => new MessageHandller(data))
|
|
1
|
+
import { EventEmitter } from 'events'
|
|
2
|
+
import loader from './plugin.loader.js'
|
|
3
|
+
import Common from '../utils/common.js'
|
|
4
|
+
import logger from '../utils/logger.js'
|
|
5
|
+
import Config from '../utils/config.js'
|
|
6
|
+
import MessageHandller from '../event/message.handler.js'
|
|
7
|
+
/**
|
|
8
|
+
* 监听器管理
|
|
9
|
+
*/
|
|
10
|
+
export default new (class Listeners extends EventEmitter {
|
|
11
|
+
/**
|
|
12
|
+
* Bot索引
|
|
13
|
+
* @type - Bot索引
|
|
14
|
+
*/
|
|
15
|
+
index
|
|
16
|
+
/**
|
|
17
|
+
* 框架名称
|
|
18
|
+
*/
|
|
19
|
+
name
|
|
20
|
+
list
|
|
21
|
+
adapter
|
|
22
|
+
constructor () {
|
|
23
|
+
super()
|
|
24
|
+
this.index = 0
|
|
25
|
+
this.name = 'Karin'
|
|
26
|
+
this.list = []
|
|
27
|
+
this.adapter = []
|
|
28
|
+
this.on('error', data => logger.error(data))
|
|
29
|
+
this.on('plugin', () => loader.load())
|
|
30
|
+
this.on('adapter', data => {
|
|
31
|
+
let path = data.path || '无'
|
|
32
|
+
if (path && data.type !== 'grpc') { path = `ws://127.0.0.1:/${Config.Server.http.port}${data.path}` }
|
|
33
|
+
path = logger.green(path)
|
|
34
|
+
logger.info(`[适配器][注册][${data.type}] ` + path)
|
|
35
|
+
this.addAdapter(data)
|
|
36
|
+
})
|
|
37
|
+
this.on('bot', data => {
|
|
38
|
+
this.addBot(data)
|
|
39
|
+
logger.info(`[机器人][注册][${data.type}] ` + logger.green(`[account:${data.bot.account.uid || data.bot.account.uin}(${data.bot.account.name})]`))
|
|
40
|
+
this.emit('karin:online', data.bot.account.uid || data.bot.account.uin)
|
|
41
|
+
})
|
|
42
|
+
this.on('message', data => new MessageHandller(data))
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 注册Bot 返回索引id
|
|
47
|
-
*/
|
|
48
|
-
addBot (data) {
|
|
49
|
-
this.index++
|
|
50
|
-
const index = this.index
|
|
51
|
-
if (!data.bot) {
|
|
52
|
-
logger.error('[Bot管理][注册] 注册失败: Bot实例不能为空')
|
|
53
|
-
return false
|
|
54
|
-
}
|
|
55
|
-
this.list.push({ index, type: data.type, bot: data.bot })
|
|
56
|
-
return index
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 注册Bot 返回索引id
|
|
47
|
+
*/
|
|
48
|
+
addBot (data) {
|
|
49
|
+
this.index++
|
|
50
|
+
const index = this.index
|
|
51
|
+
if (!data.bot) {
|
|
52
|
+
logger.error('[Bot管理][注册] 注册失败: Bot实例不能为空')
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
this.list.push({ index, type: data.type, bot: data.bot })
|
|
56
|
+
return index
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 卸载Bot
|
|
61
|
-
* @param index - Bot的索引id
|
|
62
|
-
*/
|
|
63
|
-
delBot (index) {
|
|
64
|
-
this.list = this.list.filter(item => item.index !== index)
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 卸载Bot
|
|
61
|
+
* @param index - Bot的索引id
|
|
62
|
+
*/
|
|
63
|
+
delBot (index) {
|
|
64
|
+
this.list = this.list.filter(item => item.index !== index)
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 通过Bot uid 获取Bot
|
|
69
|
-
* @param uid - Bot的uid 未传入则返回第一个Bot
|
|
70
|
-
*/
|
|
71
|
-
getBot (uid = '') {
|
|
72
|
-
uid = String(uid)
|
|
73
|
-
if (this.list.length === 0) {
|
|
74
|
-
logger.error('[Bot管理][UID] 当前Bot列表为空')
|
|
75
|
-
return undefined
|
|
76
|
-
}
|
|
77
|
-
if (!uid) { return this.list[0].bot }
|
|
78
|
-
const index = this.list.findIndex(item => String(item.bot.account.uid) === uid)
|
|
79
|
-
if (index === -1) {
|
|
80
|
-
logger.error('[Bot管理][UID] 无法找到对应的 Bot 实例')
|
|
81
|
-
return undefined
|
|
82
|
-
}
|
|
83
|
-
return this.list[index].bot
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 通过Bot uid 获取Bot
|
|
69
|
+
* @param uid - Bot的uid 未传入则返回第一个Bot
|
|
70
|
+
*/
|
|
71
|
+
getBot (uid = '') {
|
|
72
|
+
uid = String(uid)
|
|
73
|
+
if (this.list.length === 0) {
|
|
74
|
+
logger.error('[Bot管理][UID] 当前Bot列表为空')
|
|
75
|
+
return undefined
|
|
76
|
+
}
|
|
77
|
+
if (!uid) { return this.list[0].bot }
|
|
78
|
+
const index = this.list.findIndex(item => String(item.bot.account.uid) === uid)
|
|
79
|
+
if (index === -1) {
|
|
80
|
+
logger.error('[Bot管理][UID] 无法找到对应的 Bot 实例')
|
|
81
|
+
return undefined
|
|
82
|
+
}
|
|
83
|
+
return this.list[index].bot
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 根据索引获取Bot
|
|
88
|
-
* @param index - Bot的索引id
|
|
89
|
-
*/
|
|
90
|
-
getBotByIndex (index) {
|
|
91
|
-
index = this.list.findIndex(item => item.index === index)
|
|
92
|
-
if (index === -1) {
|
|
93
|
-
throw new Error('[Bot管理][索引] 无法找到对应的 Bot 实例')
|
|
94
|
-
}
|
|
95
|
-
return this.list[index].bot
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 根据索引获取Bot
|
|
88
|
+
* @param index - Bot的索引id
|
|
89
|
+
*/
|
|
90
|
+
getBotByIndex (index) {
|
|
91
|
+
index = this.list.findIndex(item => item.index === index)
|
|
92
|
+
if (index === -1) {
|
|
93
|
+
throw new Error('[Bot管理][索引] 无法找到对应的 Bot 实例')
|
|
94
|
+
}
|
|
95
|
+
return this.list[index].bot
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* 获取当前已注册Bot数量
|
|
100
|
-
*/
|
|
101
|
-
getBotCount () {
|
|
102
|
-
return this.list.length
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 获取当前已注册Bot数量
|
|
100
|
+
*/
|
|
101
|
+
getBotCount () {
|
|
102
|
+
return this.list.length
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 获取所有Bot列表
|
|
107
|
-
* @param isIndex - 是否返回包含的索引列表 默认返回Bot实例列表
|
|
108
|
-
*/
|
|
109
|
-
getBotAll (isIndex = false) {
|
|
110
|
-
if (isIndex) { return this.list }
|
|
111
|
-
return this.list.map(item => item.bot)
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 获取所有Bot列表
|
|
107
|
+
* @param isIndex - 是否返回包含的索引列表 默认返回Bot实例列表
|
|
108
|
+
*/
|
|
109
|
+
getBotAll (isIndex = false) {
|
|
110
|
+
if (isIndex) { return this.list }
|
|
111
|
+
return this.list.map(item => item.bot)
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* 注册适配器
|
|
116
|
-
* @param data - 适配器信息
|
|
117
|
-
* @param data.type - 适配器类型
|
|
118
|
-
* @param data.adapter - 适配器实例
|
|
119
|
-
* @param data.path - 适配器路径
|
|
120
|
-
*/
|
|
121
|
-
addAdapter (data) {
|
|
122
|
-
const adapter = { type: data.type, adapter: data.adapter, path: '' }
|
|
123
|
-
if (data.path) { adapter.path = data.path }
|
|
124
|
-
this.adapter.push(adapter)
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 注册适配器
|
|
116
|
+
* @param data - 适配器信息
|
|
117
|
+
* @param data.type - 适配器类型
|
|
118
|
+
* @param data.adapter - 适配器实例
|
|
119
|
+
* @param data.path - 适配器路径
|
|
120
|
+
*/
|
|
121
|
+
addAdapter (data) {
|
|
122
|
+
const adapter = { type: data.type, adapter: data.adapter, path: '' }
|
|
123
|
+
if (data.path) { adapter.path = data.path }
|
|
124
|
+
this.adapter.push(adapter)
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 通过path获取适配器 仅适用于反向WS适配器
|
|
129
|
-
* @param path - 适配器路径
|
|
130
|
-
*/
|
|
131
|
-
getAdapter (path = '') {
|
|
132
|
-
const index = this.adapter.findIndex(item => item?.path === path)
|
|
133
|
-
if (index === -1) {
|
|
134
|
-
logger.error('[适配器管理] 无法找到对应的适配器实例')
|
|
135
|
-
return undefined
|
|
136
|
-
}
|
|
137
|
-
return this.adapter[index].adapter
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 通过path获取适配器 仅适用于反向WS适配器
|
|
129
|
+
* @param path - 适配器路径
|
|
130
|
+
*/
|
|
131
|
+
getAdapter (path = '') {
|
|
132
|
+
const index = this.adapter.findIndex(item => item?.path === path)
|
|
133
|
+
if (index === -1) {
|
|
134
|
+
logger.error('[适配器管理] 无法找到对应的适配器实例')
|
|
135
|
+
return undefined
|
|
136
|
+
}
|
|
137
|
+
return this.adapter[index].adapter
|
|
138
138
|
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* 获取适配器列表
|
|
142
|
-
* @param isType - 是否返回包含的类型列表 默认返回适配器实例列表
|
|
143
|
-
*/
|
|
144
|
-
getAdapterAll (isType = false) {
|
|
145
|
-
if (isType) { return this.adapter }
|
|
146
|
-
return this.adapter.map(item => item.adapter)
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 获取适配器列表
|
|
142
|
+
* @param isType - 是否返回包含的类型列表 默认返回适配器实例列表
|
|
143
|
+
*/
|
|
144
|
+
getAdapterAll (isType = false) {
|
|
145
|
+
if (isType) { return this.adapter }
|
|
146
|
+
return this.adapter.map(item => item.adapter)
|
|
147
147
|
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* 发送主动消息
|
|
151
|
-
* @param uid - Bot的uid
|
|
152
|
-
* @param contact - 目标信息
|
|
153
|
-
* @param elements - 消息内容
|
|
154
|
-
* @param options - 消息选项
|
|
155
|
-
* @param options.recallMsg - 发送成功后撤回消息时间
|
|
156
|
-
* @param options.retry_count - 重试次数
|
|
157
|
-
*/
|
|
158
|
-
async sendMsg (uid, contact, elements, options = { recallMsg: 0, retry_count: 1 }) {
|
|
159
|
-
const bot = this.getBot(uid)
|
|
160
|
-
if (!bot) { throw new Error('发送消息失败: 未找到对应Bot实例') }
|
|
161
|
-
const { recallMsg, retry_count } = options
|
|
162
|
-
/** 标准化 */
|
|
163
|
-
const NewElements = Common.makeMessage(elements)
|
|
164
|
-
/** 结果 */
|
|
165
|
-
let result = { message_id: '' }
|
|
166
|
-
const reply_log = Common.makeMessageLog(NewElements)
|
|
167
|
-
const self_id = bot.account.uid || bot.account.uin
|
|
168
|
-
if (contact.scene === 'group') {
|
|
169
|
-
logger.bot('info', self_id, `Send Proactive Group ${contact.peer}: ${reply_log}`)
|
|
170
|
-
} else {
|
|
171
|
-
logger.bot('info', self_id, `Send Proactive private ${contact.peer}: ${reply_log}`)
|
|
172
|
-
}
|
|
173
|
-
try {
|
|
174
|
-
this.emit('karin:count:send', 1)
|
|
175
|
-
/** 取结果 */
|
|
176
|
-
result = await bot.SendMessage(contact, NewElements, retry_count)
|
|
177
|
-
logger.bot('debug', self_id, `主动消息结果:${JSON.stringify(result, null, 2)}`)
|
|
178
|
-
} catch (error) {
|
|
179
|
-
logger.bot('error', self_id, `主动消息发送失败:${reply_log}`)
|
|
180
|
-
logger.bot('error', self_id, error)
|
|
181
|
-
}
|
|
182
|
-
/** 快速撤回 */
|
|
183
|
-
if (bot.RecallMessage && recallMsg > 0 && result?.message_id) {
|
|
184
|
-
setTimeout(() => bot.RecallMessage(contact, result.message_id), recallMsg * 1000)
|
|
185
|
-
}
|
|
186
|
-
return result
|
|
187
|
-
}
|
|
188
|
-
})()
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 发送主动消息
|
|
151
|
+
* @param uid - Bot的uid
|
|
152
|
+
* @param contact - 目标信息
|
|
153
|
+
* @param elements - 消息内容
|
|
154
|
+
* @param options - 消息选项
|
|
155
|
+
* @param options.recallMsg - 发送成功后撤回消息时间
|
|
156
|
+
* @param options.retry_count - 重试次数
|
|
157
|
+
*/
|
|
158
|
+
async sendMsg (uid, contact, elements, options = { recallMsg: 0, retry_count: 1 }) {
|
|
159
|
+
const bot = this.getBot(uid)
|
|
160
|
+
if (!bot) { throw new Error('发送消息失败: 未找到对应Bot实例') }
|
|
161
|
+
const { recallMsg, retry_count } = options
|
|
162
|
+
/** 标准化 */
|
|
163
|
+
const NewElements = Common.makeMessage(elements)
|
|
164
|
+
/** 结果 */
|
|
165
|
+
let result = { message_id: '' }
|
|
166
|
+
const reply_log = Common.makeMessageLog(NewElements)
|
|
167
|
+
const self_id = bot.account.uid || bot.account.uin
|
|
168
|
+
if (contact.scene === 'group') {
|
|
169
|
+
logger.bot('info', self_id, `Send Proactive Group ${contact.peer}: ${reply_log}`)
|
|
170
|
+
} else {
|
|
171
|
+
logger.bot('info', self_id, `Send Proactive private ${contact.peer}: ${reply_log}`)
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
this.emit('karin:count:send', 1)
|
|
175
|
+
/** 取结果 */
|
|
176
|
+
result = await bot.SendMessage(contact, NewElements, retry_count)
|
|
177
|
+
logger.bot('debug', self_id, `主动消息结果:${JSON.stringify(result, null, 2)}`)
|
|
178
|
+
} catch (error) {
|
|
179
|
+
logger.bot('error', self_id, `主动消息发送失败:${reply_log}`)
|
|
180
|
+
logger.bot('error', self_id, error)
|
|
181
|
+
}
|
|
182
|
+
/** 快速撤回 */
|
|
183
|
+
if (bot.RecallMessage && recallMsg > 0 && result?.message_id) {
|
|
184
|
+
setTimeout(() => bot.RecallMessage(contact, result.message_id), recallMsg * 1000)
|
|
185
|
+
}
|
|
186
|
+
return result
|
|
187
|
+
}
|
|
188
|
+
})()
|
package/lib/core/plugin.app.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { dirName, fileName, PluginApps } from '../types/plugin.js';
|
|
2
|
-
export interface PluginAppType {
|
|
3
|
-
file?: {
|
|
4
|
-
dir?: dirName;
|
|
5
|
-
name?: fileName;
|
|
6
|
-
type?: PluginApps['file']['type'];
|
|
7
|
-
fnc?: PluginApps['file']['Fnc'];
|
|
8
|
-
};
|
|
9
|
-
name?: string;
|
|
10
|
-
event?: PluginApps['event'];
|
|
11
|
-
priority?: number;
|
|
12
|
-
accept?: boolean;
|
|
13
|
-
rule?: PluginApps['rule'];
|
|
14
|
-
}
|
|
15
|
-
export default function PluginApp(options: PluginAppType): PluginApps;
|
|
1
|
+
import { dirName, fileName, PluginApps } from '../types/plugin.js';
|
|
2
|
+
export interface PluginAppType {
|
|
3
|
+
file?: {
|
|
4
|
+
dir?: dirName;
|
|
5
|
+
name?: fileName;
|
|
6
|
+
type?: PluginApps['file']['type'];
|
|
7
|
+
fnc?: PluginApps['file']['Fnc'];
|
|
8
|
+
};
|
|
9
|
+
name?: string;
|
|
10
|
+
event?: PluginApps['event'];
|
|
11
|
+
priority?: number;
|
|
12
|
+
accept?: boolean;
|
|
13
|
+
rule?: PluginApps['rule'];
|
|
14
|
+
}
|
|
15
|
+
export default function PluginApp(options: PluginAppType): PluginApps;
|
package/lib/core/plugin.app.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export default function PluginApp (options) {
|
|
2
|
-
return {
|
|
3
|
-
file: {
|
|
4
|
-
dir: options?.file?.dir || '',
|
|
5
|
-
name: options?.file?.name || '',
|
|
6
|
-
type: options?.file?.type || 'function',
|
|
7
|
-
Fnc: options?.file?.fnc || '',
|
|
8
|
-
},
|
|
9
|
-
name: options.name || '',
|
|
10
|
-
event: options.event || 'message',
|
|
11
|
-
priority: options.priority || 10000,
|
|
12
|
-
accept: options.accept ?? false,
|
|
13
|
-
rule: options.rule || [],
|
|
14
|
-
task: [],
|
|
15
|
-
handler: [],
|
|
16
|
-
button: [],
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
export default function PluginApp (options) {
|
|
2
|
+
return {
|
|
3
|
+
file: {
|
|
4
|
+
dir: options?.file?.dir || '',
|
|
5
|
+
name: options?.file?.name || '',
|
|
6
|
+
type: options?.file?.type || 'function',
|
|
7
|
+
Fnc: options?.file?.fnc || '',
|
|
8
|
+
},
|
|
9
|
+
name: options.name || '',
|
|
10
|
+
event: options.event || 'message',
|
|
11
|
+
priority: options.priority || 10000,
|
|
12
|
+
accept: options.accept ?? false,
|
|
13
|
+
rule: options.rule || [],
|
|
14
|
+
task: [],
|
|
15
|
+
handler: [],
|
|
16
|
+
button: [],
|
|
17
|
+
}
|
|
18
|
+
}
|