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.
Files changed (59) hide show
  1. package/bin/main.js +0 -9
  2. package/lib/config/index.js +1 -0
  3. package/lib/{alemon → core}/apps.js +2 -5
  4. package/lib/{alemon → core}/dealmsg.js +31 -49
  5. package/lib/{alemon → core}/index.js +6 -28
  6. package/lib/define/index.js +1 -1
  7. package/lib/define/main.js +39 -37
  8. package/lib/discord/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
  9. package/lib/index.js +1 -1
  10. package/lib/kook/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
  11. package/lib/ntqq/alemon/message/C2C_MESSAGE_CREATE.js +1 -1
  12. package/lib/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.js +1 -1
  13. package/lib/qq/alemon/message/AUDIO_ACTION.js +1 -1
  14. package/lib/qq/alemon/message/DIRECT_MESSAGE.js +1 -1
  15. package/lib/qq/alemon/message/FORUMS_EVENT.js +1 -1
  16. package/lib/qq/alemon/message/GUILDS.js +1 -1
  17. package/lib/qq/alemon/message/GUILD_MEMBERS.js +1 -1
  18. package/lib/qq/alemon/message/GUILD_MESSAGES.js +1 -1
  19. package/lib/qq/alemon/message/GUILD_MESSAGE_REACTIONS.js +1 -1
  20. package/lib/qq/alemon/message/INTERACTION.js +1 -1
  21. package/lib/qq/alemon/message/MESSAGE.js +1 -1
  22. package/lib/qq/alemon/message/MESSAGE_AUDIT.js +1 -1
  23. package/lib/qq/alemon/message/OPEN_FORUMS_EVENT.js +1 -1
  24. package/lib/qq/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
  25. package/lib/villa/alemon/message/GUILDS.js +1 -1
  26. package/lib/villa/alemon/message/GUILD_MEMBERS.js +1 -1
  27. package/lib/villa/alemon/message/GUILD_MESSAGE_REACTIONS.js +1 -1
  28. package/lib/villa/alemon/message/MESSAGES.js +1 -1
  29. package/lib/villa/alemon/message/MESSAGE_AUDIT.js +1 -1
  30. package/package.json +10 -2
  31. package/run.d.ts +1 -0
  32. package/run.js +19 -0
  33. package/types/config/index.d.ts +1 -0
  34. package/types/{alemon → core}/apps.d.ts +1 -1
  35. package/types/{alemon → core}/dealmsg.d.ts +2 -4
  36. package/types/{alemon → core}/index.d.ts +6 -28
  37. package/types/define/index.d.ts +1 -1
  38. package/types/define/types.d.ts +12 -0
  39. package/types/index.d.ts +1 -1
  40. package/types/qq/alemon/message/MESSAGE.d.ts +1 -1
  41. package/types/villa/alemon/message/e.d.ts +1 -1
  42. /package/lib/{alemon → core}/app.js +0 -0
  43. /package/lib/{alemon → core}/buffer.js +0 -0
  44. /package/lib/{alemon → core}/dialogue.js +0 -0
  45. /package/lib/{alemon → core}/message.js +0 -0
  46. /package/lib/{alemon → core}/plugin.js +0 -0
  47. /package/lib/{alemon → core}/puppeteer.js +0 -0
  48. /package/lib/{alemon → core}/qrcode.js +0 -0
  49. /package/lib/{alemon → core}/screenshot.js +0 -0
  50. /package/lib/{alemon → core}/typings.js +0 -0
  51. /package/types/{alemon → core}/app.d.ts +0 -0
  52. /package/types/{alemon → core}/buffer.d.ts +0 -0
  53. /package/types/{alemon → core}/dialogue.d.ts +0 -0
  54. /package/types/{alemon → core}/message.d.ts +0 -0
  55. /package/types/{alemon → core}/plugin.d.ts +0 -0
  56. /package/types/{alemon → core}/puppeteer.d.ts +0 -0
  57. /package/types/{alemon → core}/qrcode.d.ts +0 -0
  58. /package/types/{alemon → core}/screenshot.d.ts +0 -0
  59. /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
  })
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * 暴露
2
3
  * ********
3
4
  * 配置管理器
4
5
  * ********
@@ -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 { appsInit, setAppsHelp } from './dealmsg.js';
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: (instruct) => {
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
- * plugins插件集合
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, belong) {
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, 'plugins');
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] apps*${PluginsArr.length} `);
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(val = { mount: false, address: '/application' }) {
348
- const { mount, address } = val;
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.belong}][${data.AppName}][${data.fncName}][${true}]`);
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.belong}][${data.AppName}][${data.fncName}][${false}]\n[${err}]`);
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.belong}][${data.AppName}][${data.fncName}][${true}]`);
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.belong}][${data.AppName}][${data.fncName}][${false}]\n[${err}]`);
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.belong}][${data.AppName}][${data.fncName}][${false}]\n[${err}]`);
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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ********
3
- * 初始化
3
+ * 暴露
4
4
  * ******
5
5
  */
6
6
  export * from './api.js';
@@ -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 { AvailableIntentsEventsEnum } from 'qq-guild-bot';
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
- let mount = false;
164
- if (Options?.app?.component || Options?.app?.module) {
165
- mount = true;
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
- const address = Options?.plugin?.directory ?? 'application';
168
- appDir = address;
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
- await loadInit({
187
- mount: mount,
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
- const app = createApp(Options?.app?.name ?? 'bot');
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 ?? 3000);
242
+ }, Options?.waitingTime ?? Object.keys(Options?.login ?? {}).length * 1000);
241
243
  return;
242
244
  }
@@ -1,4 +1,4 @@
1
- import { InstructionMatching } from '../../../alemon/index.js';
1
+ import { InstructionMatching } from '../../../core/index.js';
2
2
  import { segmentDiscord } from '../segment.js';
3
3
  import { getBotMsgByDiscord } from '../bot.js';
4
4
  import { postImage } from '../api.js';
package/lib/index.js CHANGED
@@ -7,7 +7,7 @@ if (process.argv.slice(2).includes('discord') &&
7
7
  * 核心处理&公共方法
8
8
  * *******************
9
9
  */
10
- export * from './alemon/index.js';
10
+ export * from './core/index.js';
11
11
  /**
12
12
  * *******************
13
13
  * 初始化
@@ -1,4 +1,4 @@
1
- import { InstructionMatching } from '../../../alemon/index.js';
1
+ import { InstructionMatching } from '../../../core/index.js';
2
2
  import { KOOKApiClient } from 'kook-ws';
3
3
  import { segmentKOOK } from '../segment.js';
4
4
  import { getBotMsgByKOOK } from '../bot.js';
@@ -1,4 +1,4 @@
1
- import { InstructionMatching } from '../../../alemon/index.js';
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 '../../../alemon/index.js';
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 } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { getBotMsgByQQ } from '../bot.js';
3
3
  /**
4
4
  * AUDIO_MICROPHONE 音频
@@ -1,4 +1,4 @@
1
- import { typeMessage, InstructionMatching } from '../../../alemon/index.js';
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 { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { getBotMsgByQQ } from '../bot.js';
3
3
  /**
4
4
  * ***********
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { getBotMsgByQQ } from '../bot.js';
3
3
  /**
4
4
  * GUILD 频道
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { getBotMsgByQQ } from '../bot.js';
3
3
  // 非依赖引用
4
4
  import { ClientAPIByQQ as Client } from 'qq-channel';
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { mergeMessages } from './MESSAGE.js';
3
3
  import { getBotMsgByQQ } from '../bot.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { getBotMsgByQQ } from '../bot.js';
3
3
  /**
4
4
  * DO
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { getBotMsgByQQ } from '../bot.js';
3
3
  /**
4
4
  * DO
@@ -1,4 +1,4 @@
1
- import { InstructionMatching } from '../../../alemon/index.js';
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';
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { getBotMsgByQQ } from '../bot.js';
3
3
  /**
4
4
  * DO
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { getBotMsgByQQ } from '../bot.js';
3
3
  /**
4
4
  * ***********
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { mergeMessages } from './MESSAGE.js';
3
3
  import { getBotMsgByQQ } from '../bot.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { segmentVilla } from '../segment.js';
3
3
  import { now_e } from './e.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { segmentVilla } from '../segment.js';
3
3
  import { now_e } from './e.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { segmentVilla } from '../segment.js';
3
3
  import { now_e } from './e.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { InstructionMatching } from '../../../alemon/index.js';
1
+ import { InstructionMatching } from '../../../core/index.js';
2
2
  import { Client } from 'mys-villa';
3
3
  import IMGS from 'image-size';
4
4
  import { segmentVilla } from '../segment.js';
@@ -1,4 +1,4 @@
1
- import { typeMessage } from '../../../alemon/index.js';
1
+ import { typeMessage } from '../../../core/index.js';
2
2
  import { segmentVilla } from '../segment.js';
3
3
  import { now_e } from './e.js';
4
4
  /**
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "1.0.11",
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
+ }
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * 暴露
2
3
  * ********
3
4
  * 配置管理器
4
5
  * ********
@@ -37,5 +37,5 @@ export declare function createApp(AppName: string): {
37
37
  * 挂起应用
38
38
  * @returns
39
39
  */
40
- mount: (instruct?: string) => void;
40
+ mount: () => void;
41
41
  };
@@ -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(val?: {
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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ********
3
- * 初始化
3
+ * 暴露
4
4
  * ******
5
5
  */
6
6
  export * from './api.js';
@@ -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
@@ -3,7 +3,7 @@
3
3
  * 核心处理&公共方法
4
4
  * *******************
5
5
  */
6
- export * from './alemon/index.js';
6
+ export * from './core/index.js';
7
7
  /**
8
8
  * *******************
9
9
  * 初始化
@@ -1,5 +1,5 @@
1
1
  import { IOpenAPI } from 'qq-guild-bot';
2
- import { AMessage } from '../../../alemon/index.js';
2
+ import { AMessage } from '../../../core/index.js';
3
3
  import { EventData } from '../types.js';
4
4
  declare global {
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
- import { CardType } from '../../../alemon/index.js';
2
+ import { CardType } from '../../../core/index.js';
3
3
  export declare const now_e: {
4
4
  /**
5
5
  * 卡片
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