koishi-plugin-rocom 1.0.9 → 1.0.11

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.
@@ -306,6 +306,42 @@ class EggService {
306
306
  match_info_label: this.formatMatchSummary(probability, matchCount),
307
307
  };
308
308
  }
309
+ formatEggSearchCard(item) {
310
+ const eggGroups = Array.isArray(item?.egg_groups)
311
+ ? item.egg_groups
312
+ .map((group) => group?.official_name || group?.display_name || `蛋组${group?.group_id}`)
313
+ .filter(Boolean)
314
+ : [];
315
+ const heightRange = Array.isArray(item?.height_range_m) ? item.height_range_m : [];
316
+ const weightRange = Array.isArray(item?.weight_range_kg) ? item.weight_range_kg : [];
317
+ const typeLabel = Array.isArray(item?.unit_type) && item.unit_type.length
318
+ ? item.unit_type.join(' / ')
319
+ : '未知';
320
+ return {
321
+ id: item?.id || '-',
322
+ name: item?.name || '未知精灵',
323
+ icon: item?.pet_icon_url || petIconUrl(item?.id),
324
+ image: item?.pet_img_url || petImageUrl(item?.id),
325
+ type_label: typeLabel,
326
+ egg_group_ids: Array.isArray(item?.egg_groups)
327
+ ? item.egg_groups.map((group) => Number(group?.group_id)).filter((value) => Number.isFinite(value))
328
+ : [],
329
+ egg_groups_label: eggGroups.length ? eggGroups.join(' / ') : '暂无蛋组数据',
330
+ height_min: num(heightRange[0]),
331
+ height_max: num(heightRange[1]),
332
+ height_label: fmtRange(num(heightRange[0]), num(heightRange[1]), 'm'),
333
+ weight_min: num(weightRange[0]),
334
+ weight_max: num(weightRange[1]),
335
+ weight_label: fmtRange(num(weightRange[0]), num(weightRange[1]), 'kg'),
336
+ probability: null,
337
+ match_count: null,
338
+ match_info_label: '',
339
+ };
340
+ }
341
+ formatEggSearchTextLine(item) {
342
+ const card = this.formatEggSearchCard(item);
343
+ return `${card.name} (#${card.id}) — ${card.height_label} / ${card.weight_label} · ${card.egg_groups_label}`;
344
+ }
309
345
  mergeCardsByName(perfect, ranged) {
310
346
  const perfectMap = new Map();
311
347
  const rangedMap = new Map();
@@ -482,6 +518,26 @@ class EggService {
482
518
  }
483
519
  return lines.join('\n');
484
520
  }
521
+ buildEggSearchText(heightMeters, weight, results, heightDisplay) {
522
+ const cond = [];
523
+ if (heightMeters != null)
524
+ cond.push(`身高=${heightDisplay || `${formatNumber(heightMeters)}m`}`);
525
+ if (weight != null)
526
+ cond.push(`体重=${weight}kg`);
527
+ const condStr = cond.join(' + ') || '当前条件';
528
+ const items = Array.isArray(results?.items) ? results.items : [];
529
+ if (!items.length)
530
+ return `❌ 未找到符合 ${condStr} 的精灵。`;
531
+ const total = results?.total ?? items.length;
532
+ const lines = [`✅ 符合 ${condStr} 的精灵(共 ${total} 只):`];
533
+ items.slice(0, 10).forEach((item, index) => {
534
+ lines.push(` ${index + 1}. ${this.formatEggSearchTextLine(item)}`);
535
+ });
536
+ if (results?.has_more) {
537
+ lines.push(` ... 还有更多结果,可尝试更精确的尺寸或等待后续分页支持。`);
538
+ }
539
+ return lines.join('\n');
540
+ }
485
541
  buildSearchText(pet) {
486
542
  const egs = this.getEggGroups(pet);
487
543
  const compat = this.getCompatiblePets(pet);
@@ -669,6 +725,26 @@ class EggService {
669
725
  copyright: 'Koishi & WeGame 洛克王国插件',
670
726
  };
671
727
  }
728
+ buildEggSearchData(heightMeters, weight, results, heightDisplay) {
729
+ const conditions = [];
730
+ if (heightMeters != null)
731
+ conditions.push(`身高 ${heightDisplay || `${formatNumber(heightMeters)} m`}`);
732
+ if (weight != null)
733
+ conditions.push(`体重 ${weight} kg`);
734
+ const cards = (Array.isArray(results?.items) ? results.items : []).map((item) => this.formatEggSearchCard(item));
735
+ const pageNo = num(results?.page_no);
736
+ const totalPages = num(results?.total_pages);
737
+ const pageLabel = pageNo && totalPages ? ` · 第 ${pageNo}/${totalPages} 页` : '';
738
+ return {
739
+ query_label: `${conditions.join(' / ') || '孵蛋反查'}${pageLabel}`,
740
+ perfect_matches: cards,
741
+ range_matches: [],
742
+ total_count: results?.total ?? cards.length,
743
+ has_results: cards.length > 0,
744
+ commandHint: '洛克查蛋 <精灵名> | 洛克查蛋 0.18m 1.5kg | 洛克配种 <父体> <母体>',
745
+ copyright: 'Koishi & WeGame 洛克王国插件',
746
+ };
747
+ }
672
748
  buildEggDetails(breeding) {
673
749
  if (!breeding)
674
750
  return { has_data: false };
package/lib/index.d.ts CHANGED
@@ -13,7 +13,9 @@ export interface Config {
13
13
  merchantSubscriptionEnabled: boolean;
14
14
  merchantSubscriptionItems: string[];
15
15
  merchantPrivateSubscriptionEnabled: boolean;
16
+ merchantCheckMode: 'interval' | 'times';
16
17
  merchantCheckInterval: number;
18
+ merchantCheckTimes: string[];
17
19
  homeSubscriptionEnabled: boolean;
18
20
  homeSubscriptionIntervalMinutes: number;
19
21
  imageCompressionEnabled: boolean;