alemonjs 1.0.43 → 1.0.45
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/configs.js +2 -1
- package/lib/core/dealmsg.js +2 -17
- package/lib/core/plugin.js +3 -3
- package/lib/define/main.js +3 -0
- package/package.json +1 -1
- package/types/core/configs.d.ts +4 -0
- package/types/core/plugin.d.ts +3 -3
- package/types/define/types.d.ts +4 -0
package/lib/core/configs.js
CHANGED
package/lib/core/dealmsg.js
CHANGED
|
@@ -73,6 +73,7 @@ async function synthesis(AppsObj, appname) {
|
|
|
73
73
|
plugins[appname] = [];
|
|
74
74
|
}
|
|
75
75
|
const shield = getAppProCoinfg('event');
|
|
76
|
+
const defaultCharacter = getAppProCoinfg('defaultCharacter');
|
|
76
77
|
for (const item in AppsObj) {
|
|
77
78
|
const keys = new AppsObj[item]();
|
|
78
79
|
if (shield.find(item => item == keys['event']))
|
|
@@ -102,7 +103,7 @@ async function synthesis(AppsObj, appname) {
|
|
|
102
103
|
}
|
|
103
104
|
CommandApp[itemX] = {
|
|
104
105
|
name: appname,
|
|
105
|
-
character: keys
|
|
106
|
+
character: keys?.startCharacter ?? defaultCharacter,
|
|
106
107
|
APP: AppsObj[item]
|
|
107
108
|
};
|
|
108
109
|
for await (const key of keys['rule']) {
|
|
@@ -284,22 +285,6 @@ export function getMergedRegex() {
|
|
|
284
285
|
export async function loadInit() {
|
|
285
286
|
await loadPlugins(join(process.cwd(), getAppProCoinfg('dir')));
|
|
286
287
|
}
|
|
287
|
-
/**
|
|
288
|
-
* 起始符转换器
|
|
289
|
-
* @param reg
|
|
290
|
-
* @returns
|
|
291
|
-
*/
|
|
292
|
-
function getStartSymbol(reg) {
|
|
293
|
-
const source = reg.source;
|
|
294
|
-
let startSymbol = '';
|
|
295
|
-
if (source.startsWith('#')) {
|
|
296
|
-
startSymbol = '#';
|
|
297
|
-
}
|
|
298
|
-
else if (source.startsWith('/')) {
|
|
299
|
-
startSymbol = '/';
|
|
300
|
-
}
|
|
301
|
-
return startSymbol;
|
|
302
|
-
}
|
|
303
288
|
/**
|
|
304
289
|
* 指令匹配
|
|
305
290
|
* @param e alemonjs message
|
package/lib/core/plugin.js
CHANGED
|
@@ -38,7 +38,7 @@ export class plugin {
|
|
|
38
38
|
/**
|
|
39
39
|
* 起始符特性
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
startCharacter;
|
|
42
42
|
/**
|
|
43
43
|
* @deprecated 已废弃,建议使用原生模块 node-schedule
|
|
44
44
|
*/
|
|
@@ -54,13 +54,13 @@ export class plugin {
|
|
|
54
54
|
* @param rule.doc 指令文档 doc
|
|
55
55
|
* @param rule.priority 优先级 数字越小优先级越高
|
|
56
56
|
*/
|
|
57
|
-
constructor({ name = 'app-name', event = 'MESSAGES', eventType = 'CREATE', priority = 9000,
|
|
57
|
+
constructor({ name = 'app-name', event = 'MESSAGES', eventType = 'CREATE', priority = 9000, startCharacter = '/', rule = [], task }) {
|
|
58
58
|
this.name = name;
|
|
59
59
|
this.event = event;
|
|
60
60
|
this.eventType = eventType;
|
|
61
61
|
this.priority = priority;
|
|
62
62
|
this.rule = rule;
|
|
63
|
-
this.
|
|
63
|
+
this.startCharacter = startCharacter;
|
|
64
64
|
this.task = {
|
|
65
65
|
name: task?.name ?? '',
|
|
66
66
|
fnc: task?.fnc ?? '',
|
package/lib/define/main.js
CHANGED
|
@@ -211,6 +211,9 @@ export async function defineAlemonConfig(Options) {
|
|
|
211
211
|
if (Options?.character) {
|
|
212
212
|
setAppProCoinfg('character', Options?.character);
|
|
213
213
|
}
|
|
214
|
+
if (Options?.defaultCharacter) {
|
|
215
|
+
setAppProCoinfg('defaultCharacter', Options?.defaultCharacter);
|
|
216
|
+
}
|
|
214
217
|
/**
|
|
215
218
|
* ************
|
|
216
219
|
* 扫描插件
|
package/package.json
CHANGED
package/types/core/configs.d.ts
CHANGED
package/types/core/plugin.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface PluginInitType {
|
|
|
19
19
|
name?: string;
|
|
20
20
|
dsc?: string;
|
|
21
21
|
rule?: PluginRuleType[];
|
|
22
|
-
|
|
22
|
+
startCharacter?: '/' | '#';
|
|
23
23
|
/**
|
|
24
24
|
* @deprecated 已废弃,建议使用原生模块 node-schedule
|
|
25
25
|
*/
|
|
@@ -86,7 +86,7 @@ export declare class plugin {
|
|
|
86
86
|
/**
|
|
87
87
|
* 起始符特性
|
|
88
88
|
*/
|
|
89
|
-
|
|
89
|
+
startCharacter?: '/' | '#';
|
|
90
90
|
/**
|
|
91
91
|
* @deprecated 已废弃,建议使用原生模块 node-schedule
|
|
92
92
|
*/
|
|
@@ -102,7 +102,7 @@ export declare class plugin {
|
|
|
102
102
|
* @param rule.doc 指令文档 doc
|
|
103
103
|
* @param rule.priority 优先级 数字越小优先级越高
|
|
104
104
|
*/
|
|
105
|
-
constructor({ name, event, eventType, priority,
|
|
105
|
+
constructor({ name, event, eventType, priority, startCharacter, rule, task }: PluginInitType);
|
|
106
106
|
/**
|
|
107
107
|
* @param content 内容
|
|
108
108
|
* @param img 图片buffer | 指定图片名
|