alemonjs 1.0.34 → 1.0.35
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/core/apps.js +10 -1
- package/lib/core/dealmsg.js +4 -16
- package/package.json +1 -1
- package/types/core/apps.d.ts +2 -3
package/lib/core/apps.js
CHANGED
|
@@ -44,7 +44,16 @@ export function createApp(AppName) {
|
|
|
44
44
|
/**
|
|
45
45
|
* 设置扩展参
|
|
46
46
|
*/
|
|
47
|
-
setArg:
|
|
47
|
+
setArg: (fnc) => {
|
|
48
|
+
try {
|
|
49
|
+
setAppArg(AppName, fnc);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
console.error('[AlemonJS]扩展参设置成功', err);
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
48
57
|
/**
|
|
49
58
|
* 重定义消息
|
|
50
59
|
* @param fnc 回调函数
|
package/lib/core/dealmsg.js
CHANGED
|
@@ -311,7 +311,7 @@ export async function InstructionMatching(e) {
|
|
|
311
311
|
if (typeof AppFnc == 'function')
|
|
312
312
|
e = await AppFnc(e);
|
|
313
313
|
if (typeof AppArg == 'function')
|
|
314
|
-
ARGCACHE[
|
|
314
|
+
ARGCACHE[item] = await AppArg(e);
|
|
315
315
|
const app = new APP(e);
|
|
316
316
|
// 设置this.e
|
|
317
317
|
app.e = e;
|
|
@@ -367,14 +367,8 @@ export async function InstructionMatching(e) {
|
|
|
367
367
|
continue;
|
|
368
368
|
}
|
|
369
369
|
try {
|
|
370
|
-
const getArg = (e) => {
|
|
371
|
-
if (!ARGCACHE[data.APP]) {
|
|
372
|
-
return [e];
|
|
373
|
-
}
|
|
374
|
-
return [e, ...ARGCACHE[data.APP]];
|
|
375
|
-
};
|
|
376
370
|
const app = APPCACHE[data.APP];
|
|
377
|
-
const res = await app[data.fncName](...
|
|
371
|
+
const res = await app[data.fncName](...[e, ...(ARGCACHE[data.APP] ?? [])])
|
|
378
372
|
.then(info(data))
|
|
379
373
|
.catch(logErr(data));
|
|
380
374
|
if (typeof res != 'boolean') {
|
|
@@ -411,7 +405,7 @@ export async function typeMessage(e) {
|
|
|
411
405
|
if (typeof AppFnc == 'function')
|
|
412
406
|
e = await AppFnc(e);
|
|
413
407
|
if (typeof AppArg == 'function')
|
|
414
|
-
ARGCACHE[
|
|
408
|
+
ARGCACHE[item] = await AppArg(e);
|
|
415
409
|
const app = new APP(e);
|
|
416
410
|
app.e = e;
|
|
417
411
|
APPCACHE[item] = app;
|
|
@@ -426,14 +420,8 @@ export async function typeMessage(e) {
|
|
|
426
420
|
if (e.eventType != data.eventType)
|
|
427
421
|
continue;
|
|
428
422
|
try {
|
|
429
|
-
const getArg = (e) => {
|
|
430
|
-
if (!ARGCACHE[data.APP]) {
|
|
431
|
-
return [e];
|
|
432
|
-
}
|
|
433
|
-
return [e, ...ARGCACHE[data.APP]];
|
|
434
|
-
};
|
|
435
423
|
const app = APPCACHE[data.APP];
|
|
436
|
-
const res = await app[data.fncName](...
|
|
424
|
+
const res = await app[data.fncName](...[e, ...(ARGCACHE[data.APP] ?? [])]);
|
|
437
425
|
if (typeof res != 'boolean') {
|
|
438
426
|
e.reply(res).catch(err => {
|
|
439
427
|
console.log('重发错误', err);
|
package/package.json
CHANGED
package/types/core/apps.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { setAppArg } from './message.js';
|
|
2
1
|
/**
|
|
3
2
|
* 得到执行路径
|
|
4
3
|
* @param url import.meta.url
|
|
@@ -20,7 +19,7 @@ export declare function createApps(url: string): {
|
|
|
20
19
|
/**
|
|
21
20
|
* 设置扩展参
|
|
22
21
|
*/
|
|
23
|
-
setArg:
|
|
22
|
+
setArg: (fnc: (...args: any[]) => any[] | Promise<any[]>) => boolean;
|
|
24
23
|
/**
|
|
25
24
|
* 重定义消息
|
|
26
25
|
* @param fnc 回调函数
|
|
@@ -46,7 +45,7 @@ export declare function createApp(AppName: string): {
|
|
|
46
45
|
/**
|
|
47
46
|
* 设置扩展参
|
|
48
47
|
*/
|
|
49
|
-
setArg:
|
|
48
|
+
setArg: (fnc: (...args: any[]) => any[] | Promise<any[]>) => boolean;
|
|
50
49
|
/**
|
|
51
50
|
* 重定义消息
|
|
52
51
|
* @param fnc 回调函数
|