node-karin 0.11.1 → 0.11.3

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.
@@ -24,7 +24,7 @@ export function AdapterConvertKarin(data) {
24
24
  elements.push(segment.video(i.data.url || i.data.file));
25
25
  break;
26
26
  case 'at':
27
- elements.push(segment.at(i.data.qq, i.data.qq));
27
+ elements.push(segment.at(i.data.qq, i.data.qq, i.data.name));
28
28
  break;
29
29
  case 'poke':
30
30
  elements.push(segment.poke(Number(i.data.id), Number(i.data.type)));
@@ -81,7 +81,7 @@ export function KarinConvertAdapter(data, bot) {
81
81
  elements.push({ type, data: { id: i.id } });
82
82
  break;
83
83
  case "at" /* OB11SegmentType.At */:
84
- elements.push({ type, data: { qq: String(i.uid || i.uin) } });
84
+ elements.push({ type, data: { qq: String(i.uid || i.uin), name: i.name } });
85
85
  break;
86
86
  case "reply" /* OB11SegmentType.Reply */:
87
87
  elements.push({ type, data: { id: i.message_id } });
@@ -192,7 +192,7 @@ class PluginLoader {
192
192
  const list = [];
193
193
  const info = await common.getNpmPlugins(true);
194
194
  for (const { plugin, path: _path, file, isMain } of info) {
195
- if (!isMain) {
195
+ if (isMain) {
196
196
  const root = path.join(process.cwd(), 'node_modules', plugin, _path);
197
197
  this.loadMain(root, file, true);
198
198
  continue;
@@ -337,7 +337,7 @@ class PluginLoader {
337
337
  logger.debug(`载入插件 [${plugin}]${_path ? `${common.getRelPath(_path)}` : ''}[${file}][${Class.name}]`);
338
338
  if (Class.rule.length) {
339
339
  for (const val of Class.rule) {
340
- list.push(() => {
340
+ const fnc = async () => {
341
341
  const log = val.log === false
342
342
  ? (id, log) => logger.debug('mark', id, log)
343
343
  : (id, log) => logger.bot('mark', id, log);
@@ -354,12 +354,13 @@ class PluginLoader {
354
354
  rank: val.priority || Class.priority || 10000,
355
355
  reg: val.reg instanceof RegExp ? val.reg : new RegExp(val.reg),
356
356
  }, Fn);
357
- });
357
+ };
358
+ list.push(fnc());
358
359
  }
359
360
  }
360
361
  if (Class.task.length) {
361
362
  for (const val of Class.task) {
362
- list.push(() => {
363
+ const fnc = async () => {
363
364
  if (!val.name)
364
365
  throw TypeError(`[${plugin}][${file}] 定时任务name错误`);
365
366
  if (!val.cron)
@@ -373,13 +374,12 @@ class PluginLoader {
373
374
  log,
374
375
  cron: val.cron,
375
376
  }, Fn);
376
- });
377
+ };
378
+ list.push(fnc());
377
379
  }
378
380
  }
379
381
  /** init */
380
- list.push(async () => {
381
- 'init' in Class && typeof Class.init === 'function' && await Class.init();
382
- });
382
+ list.push('init' in Class && typeof Class.init === 'function' ? Class.init() : Promise.resolve());
383
383
  return true;
384
384
  });
385
385
  await Promise.all(list);
@@ -461,7 +461,7 @@ class PluginLoader {
461
461
  perm: info.perm,
462
462
  rank: info.rank,
463
463
  reg: info.reg,
464
- type: 'function',
464
+ type: App ? 'class' : 'function',
465
465
  });
466
466
  return true;
467
467
  }
@@ -95,6 +95,7 @@ export interface AtSegment extends Segment {
95
95
  type: OB11SegmentType.At;
96
96
  data: {
97
97
  qq: string | 'all';
98
+ name?: string;
98
99
  };
99
100
  }
100
101
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "private": false,
5
5
  "description": "基于 Kritor 进行开发的nodejs机器人框架",
6
6
  "homepage": "https://github.com/KarinJS/Karin",