alemonjs 1.0.11 → 1.0.13
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/bin/main.js +0 -9
- package/lib/config/index.js +1 -0
- package/lib/{alemon → core}/apps.js +2 -5
- package/lib/{alemon → core}/dealmsg.js +31 -49
- package/lib/{alemon → core}/index.js +6 -28
- package/lib/define/index.js +1 -1
- package/lib/define/main.js +39 -37
- package/lib/discord/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
- package/lib/index.js +1 -1
- package/lib/kook/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
- package/lib/ntqq/alemon/message/C2C_MESSAGE_CREATE.js +1 -1
- package/lib/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.js +1 -1
- package/lib/qq/alemon/message/AUDIO_ACTION.js +1 -1
- package/lib/qq/alemon/message/DIRECT_MESSAGE.js +1 -1
- package/lib/qq/alemon/message/FORUMS_EVENT.js +1 -1
- package/lib/qq/alemon/message/GUILDS.js +1 -1
- package/lib/qq/alemon/message/GUILD_MEMBERS.js +1 -1
- package/lib/qq/alemon/message/GUILD_MESSAGES.js +1 -1
- package/lib/qq/alemon/message/GUILD_MESSAGE_REACTIONS.js +1 -1
- package/lib/qq/alemon/message/INTERACTION.js +1 -1
- package/lib/qq/alemon/message/MESSAGE.js +1 -1
- package/lib/qq/alemon/message/MESSAGE_AUDIT.js +1 -1
- package/lib/qq/alemon/message/OPEN_FORUMS_EVENT.js +1 -1
- package/lib/qq/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
- package/lib/villa/alemon/message/GUILDS.js +1 -1
- package/lib/villa/alemon/message/GUILD_MEMBERS.js +1 -1
- package/lib/villa/alemon/message/GUILD_MESSAGE_REACTIONS.js +1 -1
- package/lib/villa/alemon/message/MESSAGES.js +1 -1
- package/lib/villa/alemon/message/MESSAGE_AUDIT.js +1 -1
- package/package.json +10 -2
- package/run.d.ts +1 -0
- package/run.js +19 -0
- package/types/config/index.d.ts +1 -0
- package/types/{alemon → core}/apps.d.ts +1 -1
- package/types/{alemon → core}/dealmsg.d.ts +2 -4
- package/types/{alemon → core}/index.d.ts +6 -28
- package/types/define/index.d.ts +1 -1
- package/types/define/types.d.ts +12 -0
- package/types/index.d.ts +1 -1
- package/types/qq/alemon/message/MESSAGE.d.ts +1 -1
- package/types/villa/alemon/message/e.d.ts +1 -1
- /package/lib/{alemon → core}/app.js +0 -0
- /package/lib/{alemon → core}/buffer.js +0 -0
- /package/lib/{alemon → core}/dialogue.js +0 -0
- /package/lib/{alemon → core}/message.js +0 -0
- /package/lib/{alemon → core}/plugin.js +0 -0
- /package/lib/{alemon → core}/puppeteer.js +0 -0
- /package/lib/{alemon → core}/qrcode.js +0 -0
- /package/lib/{alemon → core}/screenshot.js +0 -0
- /package/lib/{alemon → core}/typings.js +0 -0
- /package/types/{alemon → core}/app.d.ts +0 -0
- /package/types/{alemon → core}/buffer.d.ts +0 -0
- /package/types/{alemon → core}/dialogue.d.ts +0 -0
- /package/types/{alemon → core}/message.d.ts +0 -0
- /package/types/{alemon → core}/plugin.d.ts +0 -0
- /package/types/{alemon → core}/puppeteer.d.ts +0 -0
- /package/types/{alemon → core}/qrcode.d.ts +0 -0
- /package/types/{alemon → core}/screenshot.d.ts +0 -0
- /package/types/{alemon → core}/typings.d.ts +0 -0
package/bin/main.js
CHANGED
|
@@ -3,26 +3,17 @@
|
|
|
3
3
|
import { spawn } from 'child_process'
|
|
4
4
|
const ars = process.argv.slice(2)
|
|
5
5
|
const msg = ars.join(' ')
|
|
6
|
-
|
|
7
6
|
const files = msg.match(/(\S+\.js|\S+\.ts)/g) ?? ['alemon.config.ts']
|
|
8
|
-
|
|
9
7
|
const argsWithoutFiles = msg.replace(/(\S+\.js|\S+\.ts)/g, '')
|
|
10
|
-
|
|
11
8
|
for (const item of files) {
|
|
12
9
|
const isTypeScript = item.endsWith('.ts')
|
|
13
|
-
|
|
14
10
|
const command = isTypeScript ? 'npx ts-node' : 'node'
|
|
15
|
-
|
|
16
11
|
const cmd = `${command} ${item} ${argsWithoutFiles}`
|
|
17
|
-
|
|
18
12
|
console.log('[alemonjs]', cmd)
|
|
19
|
-
|
|
20
13
|
const childProcess = spawn(cmd, { shell: true })
|
|
21
|
-
|
|
22
14
|
childProcess.stdout.on('data', data => {
|
|
23
15
|
process.stdout.write(data.toString())
|
|
24
16
|
})
|
|
25
|
-
|
|
26
17
|
childProcess.stderr.on('data', data => {
|
|
27
18
|
process.stderr.write(data.toString())
|
|
28
19
|
})
|
package/lib/config/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { dirname, basename } from 'path';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { setMessage } from './message.js';
|
|
4
4
|
import { setApp } from './app.js';
|
|
5
|
-
import {
|
|
5
|
+
import { setAppsHelp } from './dealmsg.js';
|
|
6
6
|
/**
|
|
7
7
|
* 得到执行路径
|
|
8
8
|
* @param url
|
|
@@ -106,16 +106,13 @@ export function createApp(AppName) {
|
|
|
106
106
|
* 挂起应用
|
|
107
107
|
* @returns
|
|
108
108
|
*/
|
|
109
|
-
mount: (
|
|
109
|
+
mount: () => {
|
|
110
110
|
try {
|
|
111
111
|
setApp(AppName, apps);
|
|
112
112
|
}
|
|
113
113
|
catch (err) {
|
|
114
114
|
console.error(err);
|
|
115
115
|
}
|
|
116
|
-
// 存在挂载指令则重新加载
|
|
117
|
-
if (instruct)
|
|
118
|
-
appsInit();
|
|
119
116
|
}
|
|
120
117
|
};
|
|
121
118
|
}
|
|
@@ -6,21 +6,14 @@ import { getMessage } from './message.js';
|
|
|
6
6
|
import { getApp, delApp, getAppKey } from './app.js';
|
|
7
7
|
import { EventEnum } from './typings.js';
|
|
8
8
|
import { conversationHandlers, getConversationState } from './dialogue.js';
|
|
9
|
-
/**
|
|
10
|
-
* 指令合集
|
|
11
|
-
*/
|
|
12
9
|
const Command = {};
|
|
13
|
-
/**
|
|
14
|
-
* 指令合集
|
|
15
|
-
*/
|
|
16
10
|
const CommandNotR = {};
|
|
17
11
|
/**
|
|
18
|
-
*
|
|
12
|
+
* ***********
|
|
13
|
+
* plugins管理
|
|
14
|
+
* ***********
|
|
19
15
|
*/
|
|
20
16
|
let PluginsArr = [];
|
|
21
|
-
/**
|
|
22
|
-
* 指令json
|
|
23
|
-
*/
|
|
24
17
|
const plugins = {};
|
|
25
18
|
/**
|
|
26
19
|
* 默认执行地址
|
|
@@ -30,11 +23,11 @@ const route = '/public/defset';
|
|
|
30
23
|
* 执行文件
|
|
31
24
|
*/
|
|
32
25
|
let addressMenu = join(process.cwd(), route);
|
|
33
|
-
|
|
34
|
-
* 大正则
|
|
35
|
-
*/
|
|
26
|
+
// 大正则
|
|
36
27
|
let mergedRegex;
|
|
28
|
+
// 插件目录匹配规则
|
|
37
29
|
let appRegex = /./;
|
|
30
|
+
// 插件目录取消规则
|
|
38
31
|
let appRegexClose;
|
|
39
32
|
/**
|
|
40
33
|
* 插件名匹配
|
|
@@ -109,9 +102,8 @@ function createPluginHelp() {
|
|
|
109
102
|
* 应用挂载
|
|
110
103
|
* @param AppsObj
|
|
111
104
|
* @param appname
|
|
112
|
-
* @param belong
|
|
113
105
|
*/
|
|
114
|
-
async function synthesis(AppsObj, appname
|
|
106
|
+
async function synthesis(AppsObj, appname) {
|
|
115
107
|
// 没有记载
|
|
116
108
|
if (!plugins[appname]) {
|
|
117
109
|
plugins[appname] = [];
|
|
@@ -166,7 +158,6 @@ async function synthesis(AppsObj, appname, belong) {
|
|
|
166
158
|
});
|
|
167
159
|
// 保存
|
|
168
160
|
Command[event].push({
|
|
169
|
-
belong,
|
|
170
161
|
event: event,
|
|
171
162
|
eventType: eventType,
|
|
172
163
|
reg: new RegExp(reg),
|
|
@@ -189,7 +180,6 @@ async function synthesis(AppsObj, appname, belong) {
|
|
|
189
180
|
});
|
|
190
181
|
// 保存
|
|
191
182
|
CommandNotR[event].push({
|
|
192
|
-
belong,
|
|
193
183
|
event: event,
|
|
194
184
|
eventType: eventType,
|
|
195
185
|
priority,
|
|
@@ -287,7 +277,7 @@ export async function appsInit() {
|
|
|
287
277
|
/**
|
|
288
278
|
* 分析插件集
|
|
289
279
|
*/
|
|
290
|
-
await synthesis(apps, item
|
|
280
|
+
await synthesis(apps, item);
|
|
291
281
|
/**
|
|
292
282
|
* 记录该插件
|
|
293
283
|
*/
|
|
@@ -297,15 +287,21 @@ export async function appsInit() {
|
|
|
297
287
|
*/
|
|
298
288
|
delApp(item);
|
|
299
289
|
}
|
|
300
|
-
/***
|
|
301
|
-
* 排序之后把所有正则变成一条正则
|
|
302
|
-
*/
|
|
303
290
|
/**
|
|
304
291
|
* 排序
|
|
305
292
|
*/
|
|
306
293
|
for (const val in Command) {
|
|
307
294
|
Command[val] = lodash.orderBy(Command[val], ['priority'], ['asc']);
|
|
308
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* 排序
|
|
298
|
+
*/
|
|
299
|
+
for (const val in CommandNotR) {
|
|
300
|
+
CommandNotR[val] = lodash.orderBy(CommandNotR[val], ['priority'], ['asc']);
|
|
301
|
+
}
|
|
302
|
+
/***
|
|
303
|
+
* 排序之后把所有正则变成一条正则
|
|
304
|
+
*/
|
|
309
305
|
const mergedRegexArr = [];
|
|
310
306
|
for (const val in Command) {
|
|
311
307
|
for (const data of Command[val]) {
|
|
@@ -316,12 +312,6 @@ export async function appsInit() {
|
|
|
316
312
|
}
|
|
317
313
|
// 机器人整体指令正则
|
|
318
314
|
mergedRegex = new RegExp(mergedRegexArr.map(regex => regex.source).join('|'));
|
|
319
|
-
/**
|
|
320
|
-
* 排序
|
|
321
|
-
*/
|
|
322
|
-
for (const val in CommandNotR) {
|
|
323
|
-
CommandNotR[val] = lodash.orderBy(CommandNotR[val], ['priority'], ['asc']);
|
|
324
|
-
}
|
|
325
315
|
/**
|
|
326
316
|
* 生成指令json
|
|
327
317
|
*/
|
|
@@ -329,7 +319,7 @@ export async function appsInit() {
|
|
|
329
319
|
/**
|
|
330
320
|
* 打印
|
|
331
321
|
*/
|
|
332
|
-
console.info(`[LOAD]
|
|
322
|
+
console.info(`[LOAD] APPS*${PluginsArr.length} `);
|
|
333
323
|
return;
|
|
334
324
|
}
|
|
335
325
|
export function getMergedRegex() {
|
|
@@ -339,27 +329,16 @@ let appDir = '/application';
|
|
|
339
329
|
export function getAppDir() {
|
|
340
330
|
return appDir;
|
|
341
331
|
}
|
|
332
|
+
export function setAppDir(val) {
|
|
333
|
+
appDir = val;
|
|
334
|
+
}
|
|
342
335
|
/**
|
|
343
336
|
* 初始化应用 mount = ture 则直接应用
|
|
344
337
|
* @param param0 { mount = false, address = '/application' }
|
|
345
338
|
* @returns
|
|
346
339
|
*/
|
|
347
|
-
export async function loadInit(
|
|
348
|
-
|
|
349
|
-
appDir = address ?? '/application';
|
|
350
|
-
/**
|
|
351
|
-
* 加载插件
|
|
352
|
-
*/
|
|
353
|
-
await loadPlugins(join(process.cwd(), address ?? '/application'));
|
|
354
|
-
/**
|
|
355
|
-
* 取消集成
|
|
356
|
-
*/
|
|
357
|
-
if (mount)
|
|
358
|
-
return;
|
|
359
|
-
/**
|
|
360
|
-
* 开始集成
|
|
361
|
-
*/
|
|
362
|
-
await appsInit();
|
|
340
|
+
export async function loadInit() {
|
|
341
|
+
await loadPlugins(join(process.cwd(), getAppDir()));
|
|
363
342
|
return;
|
|
364
343
|
}
|
|
365
344
|
/**
|
|
@@ -376,6 +355,9 @@ export async function InstructionMatching(e) {
|
|
|
376
355
|
* 获取对话处理函数
|
|
377
356
|
*/
|
|
378
357
|
const handler = conversationHandlers.get(e.user_id);
|
|
358
|
+
/**
|
|
359
|
+
* 拦截
|
|
360
|
+
*/
|
|
379
361
|
if (handler && state) {
|
|
380
362
|
/**
|
|
381
363
|
* 如果用户处于对话状态
|
|
@@ -405,11 +387,11 @@ export async function InstructionMatching(e) {
|
|
|
405
387
|
const res = await data
|
|
406
388
|
.fnc(e)
|
|
407
389
|
.then((res) => {
|
|
408
|
-
console.info(`\n[${data.event}][${data.
|
|
390
|
+
console.info(`\n[${data.event}][${data.AppName}][${data.fncName}][${true}]`);
|
|
409
391
|
return res;
|
|
410
392
|
})
|
|
411
393
|
.catch((err) => {
|
|
412
|
-
console.error(`\n[${data.event}][${data.
|
|
394
|
+
console.error(`\n[${data.event}][${data.AppName}][${data.fncName}][${false}]\n[${err}]`);
|
|
413
395
|
return false;
|
|
414
396
|
});
|
|
415
397
|
// 不是false都直接中断匹配
|
|
@@ -444,11 +426,11 @@ export async function typeMessage(e) {
|
|
|
444
426
|
const res = await data
|
|
445
427
|
.fnc(e)
|
|
446
428
|
.then((res) => {
|
|
447
|
-
console.info(`\n[${data.event}][${data.
|
|
429
|
+
console.info(`\n[${data.event}][${data.AppName}][${data.fncName}][${true}]`);
|
|
448
430
|
return res;
|
|
449
431
|
})
|
|
450
432
|
.catch((err) => {
|
|
451
|
-
console.error(`\n[${data.event}][${data.
|
|
433
|
+
console.error(`\n[${data.event}][${data.AppName}][${data.fncName}][${false}]\n[${err}]`);
|
|
452
434
|
return false;
|
|
453
435
|
});
|
|
454
436
|
if (res) {
|
|
@@ -468,6 +450,6 @@ export async function typeMessage(e) {
|
|
|
468
450
|
* @param data
|
|
469
451
|
*/
|
|
470
452
|
function logErr(err, data) {
|
|
471
|
-
console.error(`\n[${data.event}][${data.
|
|
453
|
+
console.error(`\n[${data.event}][${data.AppName}][${data.fncName}][${false}]\n[${err}]`);
|
|
472
454
|
return;
|
|
473
455
|
}
|
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ********
|
|
3
|
+
* 暴露
|
|
4
|
+
* ********
|
|
5
|
+
* 公共方法及
|
|
6
|
+
* 核心处理器
|
|
7
|
+
* *******
|
|
3
8
|
*/
|
|
4
9
|
export * from './plugin.js';
|
|
5
|
-
/**
|
|
6
|
-
* 应用
|
|
7
|
-
*/
|
|
8
10
|
export * from './apps.js';
|
|
9
|
-
/**
|
|
10
|
-
* 消息
|
|
11
|
-
*/
|
|
12
11
|
export * from './message.js';
|
|
13
|
-
/**
|
|
14
|
-
* 对话机
|
|
15
|
-
*/
|
|
16
12
|
export * from './dialogue.js';
|
|
17
|
-
/**
|
|
18
|
-
* 接口
|
|
19
|
-
*/
|
|
20
13
|
export * from './qrcode.js';
|
|
21
|
-
/**
|
|
22
|
-
* 模块加载
|
|
23
|
-
*/
|
|
24
14
|
export * from './dealmsg.js';
|
|
25
|
-
/**
|
|
26
|
-
* 浏览器
|
|
27
|
-
*/
|
|
28
15
|
export * from './puppeteer.js';
|
|
29
|
-
/**
|
|
30
|
-
* 截图
|
|
31
|
-
*/
|
|
32
16
|
export * from './screenshot.js';
|
|
33
|
-
/**
|
|
34
|
-
* 类型
|
|
35
|
-
*/
|
|
36
17
|
export * from './typings.js';
|
|
37
|
-
/**
|
|
38
|
-
* 二进制
|
|
39
|
-
*/
|
|
40
18
|
export * from './buffer.js';
|
package/lib/define/index.js
CHANGED
package/lib/define/main.js
CHANGED
|
@@ -2,13 +2,13 @@ import { compilationTools } from 'alemon-rollup';
|
|
|
2
2
|
import PupOptions from '../default/pup.js';
|
|
3
3
|
import { rebotMap } from './map.js';
|
|
4
4
|
import { nodeScripts } from './child_process.js';
|
|
5
|
+
import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
|
|
5
6
|
import { ClientAPIByQQ as ClientByNTQQ } from '../ntqq/sdk/index.js';
|
|
6
|
-
import { createApp, loadInit, setBotConfigByKey, setLanchConfig, getPupPath, getBotConfigByKey, setAppRegex } from '../index.js';
|
|
7
7
|
import { command } from './command.js';
|
|
8
|
-
import {
|
|
8
|
+
import { createApp, setLanchConfig, loadInit, appsInit, setAppRegex, setAppDir, getAppDir } from '../core/index.js';
|
|
9
|
+
import { getPupPath, setBotConfigByKey, getBotConfigByKey } from '../config/index.js';
|
|
9
10
|
// 设置ntqq独立鉴权路径
|
|
10
11
|
export const setAuthenticationByNtqq = ClientByNTQQ.setAuthentication;
|
|
11
|
-
let appDir = 'application';
|
|
12
12
|
/**
|
|
13
13
|
* 应用模块集成
|
|
14
14
|
* @param AppName
|
|
@@ -16,6 +16,7 @@ let appDir = 'application';
|
|
|
16
16
|
* @returns
|
|
17
17
|
*/
|
|
18
18
|
export function ApplicationTools(AppName, name = 'apps') {
|
|
19
|
+
const appDir = getAppDir();
|
|
19
20
|
return compilationTools({
|
|
20
21
|
aInput: `${appDir}/${AppName}/${name}/**/*.ts`,
|
|
21
22
|
aOutput: `${appDir}/${AppName}/apps.js`
|
|
@@ -46,7 +47,7 @@ export async function defineAlemonConfig(Options) {
|
|
|
46
47
|
// 设置旧的值
|
|
47
48
|
setBotConfigByKey('puppeteer', pCig);
|
|
48
49
|
if (Options?.puppeteer) {
|
|
49
|
-
//
|
|
50
|
+
// 存在则替换新的值
|
|
50
51
|
setBotConfigByKey('puppeteer', Options?.puppeteer);
|
|
51
52
|
}
|
|
52
53
|
const pData = getBotConfigByKey('puppeteer');
|
|
@@ -156,16 +157,35 @@ export async function defineAlemonConfig(Options) {
|
|
|
156
157
|
console.info('[LOGIN] 无登录配置');
|
|
157
158
|
}
|
|
158
159
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
160
|
+
* ***********
|
|
161
|
+
* 加载应用
|
|
161
162
|
* ************
|
|
162
163
|
*/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
if (Options?.login && Options?.app?.init !== false) {
|
|
165
|
+
const app = createApp(Options?.app?.name ?? 'bot');
|
|
166
|
+
if (Options?.app?.regJSon?.address) {
|
|
167
|
+
app.setHelp(Options?.app?.regJSon?.address ?? '/public/defset');
|
|
168
|
+
}
|
|
169
|
+
if (Options?.app?.module) {
|
|
170
|
+
const word = await compilationTools({
|
|
171
|
+
aInput: Options?.app?.module?.input ?? 'apps/**/*.ts',
|
|
172
|
+
aOutput: Options?.app?.module?.input ?? '.apps/index.js'
|
|
173
|
+
});
|
|
174
|
+
app.component(word);
|
|
175
|
+
}
|
|
176
|
+
if (Options?.app?.component) {
|
|
177
|
+
for await (const item of Options.app.component) {
|
|
178
|
+
app.component(item);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
app.mount();
|
|
166
182
|
}
|
|
167
|
-
|
|
168
|
-
|
|
183
|
+
/**
|
|
184
|
+
* ************
|
|
185
|
+
* 设置加载目录
|
|
186
|
+
* ************
|
|
187
|
+
*/
|
|
188
|
+
setAppDir(Options?.plugin?.directory ?? '/application');
|
|
169
189
|
/**
|
|
170
190
|
* ************
|
|
171
191
|
* 设置扫描规则
|
|
@@ -183,34 +203,16 @@ export async function defineAlemonConfig(Options) {
|
|
|
183
203
|
* ************
|
|
184
204
|
*/
|
|
185
205
|
if (Options?.plugin?.init) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
address: address == undefined ? '/application' : `/${address}`
|
|
189
|
-
});
|
|
206
|
+
// 加载插件
|
|
207
|
+
await loadInit();
|
|
190
208
|
}
|
|
191
209
|
/**
|
|
192
210
|
* ************
|
|
193
|
-
*
|
|
211
|
+
* 开始解析
|
|
194
212
|
* ************
|
|
195
213
|
*/
|
|
196
|
-
if (mount) {
|
|
197
|
-
|
|
198
|
-
if (Options?.app?.regJSon?.address) {
|
|
199
|
-
app.setHelp(Options?.app?.regJSon?.address ?? '/public/defset');
|
|
200
|
-
}
|
|
201
|
-
if (Options?.app?.module) {
|
|
202
|
-
const word = await compilationTools({
|
|
203
|
-
aInput: Options?.app?.module?.input ?? 'src/apps/**/*.ts',
|
|
204
|
-
aOutput: Options?.app?.module?.input ?? '.apps/index.js'
|
|
205
|
-
});
|
|
206
|
-
app.component(word);
|
|
207
|
-
}
|
|
208
|
-
if (Options?.app?.component) {
|
|
209
|
-
for await (const item of Options.app.component) {
|
|
210
|
-
app.component(item);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
app.mount('#app');
|
|
214
|
+
if (Options?.mount) {
|
|
215
|
+
await appsInit();
|
|
214
216
|
}
|
|
215
217
|
setTimeout(async () => {
|
|
216
218
|
/**
|
|
@@ -227,9 +229,9 @@ export async function defineAlemonConfig(Options) {
|
|
|
227
229
|
}
|
|
228
230
|
}
|
|
229
231
|
/**
|
|
230
|
-
*
|
|
232
|
+
* **********
|
|
231
233
|
* 附加脚本
|
|
232
|
-
*
|
|
234
|
+
* **********
|
|
233
235
|
*/
|
|
234
236
|
if (Options?.scripts) {
|
|
235
237
|
for await (const item of Options.scripts) {
|
|
@@ -237,6 +239,6 @@ export async function defineAlemonConfig(Options) {
|
|
|
237
239
|
nodeScripts(name, item?.file, item?.ars ?? []);
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
|
-
}, Options?.waitingTime ??
|
|
242
|
+
}, Options?.waitingTime ?? Object.keys(Options?.login ?? {}).length * 1000);
|
|
241
243
|
return;
|
|
242
244
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InstructionMatching } from '../../../
|
|
1
|
+
import { InstructionMatching } from '../../../core/index.js';
|
|
2
2
|
import { ClientAPIByQQ as Client, ClinetWeb, getWebConfig } from '../../sdk/index.js';
|
|
3
3
|
import { segmentQQ } from '../segment.js';
|
|
4
4
|
import { getBotMsgByNtqq } from '../bot.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InstructionMatching } from '../../../
|
|
1
|
+
import { InstructionMatching } from '../../../core/index.js';
|
|
2
2
|
import { ClientAPIByQQ as Client, ClinetWeb, getWebConfig } from '../../sdk/index.js';
|
|
3
3
|
import { segmentQQ } from '../segment.js';
|
|
4
4
|
import { getBotMsgByNtqq } from '../bot.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { typeMessage, InstructionMatching } from '../../../
|
|
1
|
+
import { typeMessage, InstructionMatching } from '../../../core/index.js';
|
|
2
2
|
import { ClientAPIByQQ as Client } from 'qq-channel';
|
|
3
3
|
import { segmentQQ } from '../segment.js';
|
|
4
4
|
import { getBotMsgByQQ } from '../bot.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InstructionMatching } from '../../../
|
|
1
|
+
import { InstructionMatching } from '../../../core/index.js';
|
|
2
2
|
import { ClientAPIByQQ as Client } from 'qq-channel';
|
|
3
3
|
import { Private } from '../privatechat.js';
|
|
4
4
|
import { segmentQQ } from '../segment.js';
|
package/package.json
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alemonjs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "阿柠檬框架",
|
|
5
5
|
"author": "ningmengchongshui",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"license": "GPL-2.0",
|
|
8
8
|
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./run": {
|
|
11
|
+
"types": "./run.d.ts",
|
|
12
|
+
"import": "./run.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
9
15
|
"scripts": {
|
|
10
16
|
"app": "alemonjs",
|
|
11
17
|
"dev": "alemonjs dev",
|
|
@@ -48,7 +54,9 @@
|
|
|
48
54
|
"files": [
|
|
49
55
|
"bin",
|
|
50
56
|
"lib",
|
|
51
|
-
"types"
|
|
57
|
+
"types",
|
|
58
|
+
"run.js",
|
|
59
|
+
"run.d.ts"
|
|
52
60
|
],
|
|
53
61
|
"bin": {
|
|
54
62
|
"alemonjs": "bin/main.js"
|
package/run.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function commandRun(ars: string[]): void
|
package/run.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { spawn } from 'child_process'
|
|
2
|
+
export function commandRun(ars) {
|
|
3
|
+
const msg = ars.join(' ')
|
|
4
|
+
const files = msg.match(/(\S+\.js|\S+\.ts)/g) ?? ['alemon.config.ts']
|
|
5
|
+
const argsWithoutFiles = msg.replace(/(\S+\.js|\S+\.ts)/g, '')
|
|
6
|
+
for (const item of files) {
|
|
7
|
+
const isTypeScript = item.endsWith('.ts')
|
|
8
|
+
const command = isTypeScript ? 'npx ts-node' : 'node'
|
|
9
|
+
const cmd = `${command} ${item} ${argsWithoutFiles}`
|
|
10
|
+
console.log('[alemonjs]', cmd)
|
|
11
|
+
const childProcess = spawn(cmd, { shell: true })
|
|
12
|
+
childProcess.stdout.on('data', data => {
|
|
13
|
+
process.stdout.write(data.toString())
|
|
14
|
+
})
|
|
15
|
+
childProcess.stderr.on('data', data => {
|
|
16
|
+
process.stderr.write(data.toString())
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
}
|
package/types/config/index.d.ts
CHANGED
|
@@ -34,15 +34,13 @@ export declare function getPluginHelp(AppName: string): any;
|
|
|
34
34
|
export declare function appsInit(): Promise<void>;
|
|
35
35
|
export declare function getMergedRegex(): RegExp;
|
|
36
36
|
export declare function getAppDir(): string;
|
|
37
|
+
export declare function setAppDir(val: string): void;
|
|
37
38
|
/**
|
|
38
39
|
* 初始化应用 mount = ture 则直接应用
|
|
39
40
|
* @param param0 { mount = false, address = '/application' }
|
|
40
41
|
* @returns
|
|
41
42
|
*/
|
|
42
|
-
export declare function loadInit(
|
|
43
|
-
mount?: boolean;
|
|
44
|
-
address?: string;
|
|
45
|
-
}): Promise<void>;
|
|
43
|
+
export declare function loadInit(): Promise<void>;
|
|
46
44
|
/**
|
|
47
45
|
* 指令匹配
|
|
48
46
|
* @param e
|
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ********
|
|
3
|
+
* 暴露
|
|
4
|
+
* ********
|
|
5
|
+
* 公共方法及
|
|
6
|
+
* 核心处理器
|
|
7
|
+
* *******
|
|
3
8
|
*/
|
|
4
9
|
export * from './plugin.js';
|
|
5
|
-
/**
|
|
6
|
-
* 应用
|
|
7
|
-
*/
|
|
8
10
|
export * from './apps.js';
|
|
9
|
-
/**
|
|
10
|
-
* 消息
|
|
11
|
-
*/
|
|
12
11
|
export * from './message.js';
|
|
13
|
-
/**
|
|
14
|
-
* 对话机
|
|
15
|
-
*/
|
|
16
12
|
export * from './dialogue.js';
|
|
17
|
-
/**
|
|
18
|
-
* 接口
|
|
19
|
-
*/
|
|
20
13
|
export * from './qrcode.js';
|
|
21
|
-
/**
|
|
22
|
-
* 模块加载
|
|
23
|
-
*/
|
|
24
14
|
export * from './dealmsg.js';
|
|
25
|
-
/**
|
|
26
|
-
* 浏览器
|
|
27
|
-
*/
|
|
28
15
|
export * from './puppeteer.js';
|
|
29
|
-
/**
|
|
30
|
-
* 截图
|
|
31
|
-
*/
|
|
32
16
|
export * from './screenshot.js';
|
|
33
|
-
/**
|
|
34
|
-
* 类型
|
|
35
|
-
*/
|
|
36
17
|
export * from './typings.js';
|
|
37
|
-
/**
|
|
38
|
-
* 二进制
|
|
39
|
-
*/
|
|
40
18
|
export * from './buffer.js';
|
package/types/define/index.d.ts
CHANGED
package/types/define/types.d.ts
CHANGED
|
@@ -6,7 +6,18 @@ import { LoginOptions, MysqlOptions, RedisOptions, ServerOptions } from '../defa
|
|
|
6
6
|
* ******
|
|
7
7
|
*/
|
|
8
8
|
export interface AlemonOptions {
|
|
9
|
+
/**
|
|
10
|
+
* 是否解析应用
|
|
11
|
+
*/
|
|
12
|
+
mount?: false;
|
|
13
|
+
/**
|
|
14
|
+
* 个人应用
|
|
15
|
+
*/
|
|
9
16
|
app?: {
|
|
17
|
+
/**
|
|
18
|
+
* 是否创建
|
|
19
|
+
*/
|
|
20
|
+
init?: boolean;
|
|
10
21
|
/**
|
|
11
22
|
* 应用名称
|
|
12
23
|
*/
|
|
@@ -81,6 +92,7 @@ export interface AlemonOptions {
|
|
|
81
92
|
login?: LoginOptions;
|
|
82
93
|
/**
|
|
83
94
|
* 附加运行等待时间
|
|
95
|
+
* defaukt app*1000
|
|
84
96
|
*/
|
|
85
97
|
waitingTime?: number;
|
|
86
98
|
/**
|
package/types/index.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|