koishi-plugin-warframe 1.0.0 → 1.1.0
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/index.d.ts +7 -5
- package/lib/index.js +284 -54
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -5,9 +5,12 @@ import { Element, Argv, Context, Schema } from 'koishi';
|
|
|
5
5
|
export const fetchAsyncText: (url: string, method?: string) => Promise<string | null>;
|
|
6
6
|
export const fetchAsyncData: <T>(url: string, method?: string) => Promise<T | null>;
|
|
7
7
|
export const fullWidthToHalfWidth: (str: string) => string;
|
|
8
|
-
export const
|
|
8
|
+
export const listToDict: <T>(dict: T[], predict: (obj: T) => string[]) => {
|
|
9
9
|
[key: string]: T;
|
|
10
10
|
};
|
|
11
|
+
export const listToDictSpec: <TObj, TValue>(dict: TObj[], predict: (obj: TObj) => string[], value: (obj: TObj) => TValue) => {
|
|
12
|
+
[key: string]: TValue;
|
|
13
|
+
};
|
|
11
14
|
export const dictToKeyDict: <T>(dict: {
|
|
12
15
|
[key: string]: T;
|
|
13
16
|
}, predict: (obj: T) => string[]) => {
|
|
@@ -49,14 +52,13 @@ export const getHtmlImageBase64: (puppe: Puppeteer, html: string, type?: "png" |
|
|
|
49
52
|
export const OutputImage: (imgBase64: string) => Element;
|
|
50
53
|
export const ItemOrderOutput: (item: ItemShort, orders: OrderWithUser[]) => Element;
|
|
51
54
|
export const RivenOrderOutput: (item: RivenItem, orders: RivenOrder[]) => Element;
|
|
52
|
-
let
|
|
53
|
-
export { globalRivenAttributeList };
|
|
55
|
+
export let globalRivenAttributeDict: Record<string, RivenAttribute>;
|
|
54
56
|
export const wmOnReady: () => Promise<void>;
|
|
55
|
-
export const getItemOrders: (
|
|
57
|
+
export const getItemOrders: (input: string) => Promise<{
|
|
56
58
|
item: ItemShort;
|
|
57
59
|
orders: OrderWithUser[];
|
|
58
60
|
}>;
|
|
59
|
-
export const generateItemOrderOutput: (puppe: Puppeteer, item: ItemShort, orders: OrderWithUser[]) => Promise<import("koishi").Element>;
|
|
61
|
+
export const generateItemOrderOutput: (puppe: Puppeteer, item: ItemShort, orders: OrderWithUser[]) => Promise<string | import("koishi").Element>;
|
|
60
62
|
export const getRivenOrders: (input: string) => Promise<{
|
|
61
63
|
item: RivenItem;
|
|
62
64
|
orders: RivenOrder[];
|
package/lib/index.js
CHANGED
|
@@ -79,6 +79,18 @@ var fullWidthToHalfWidth = /* @__PURE__ */ __name((str) => {
|
|
|
79
79
|
return String.fromCharCode(char.charCodeAt(0) - 65248);
|
|
80
80
|
}).replace(/\u3000/g, " ");
|
|
81
81
|
}, "fullWidthToHalfWidth");
|
|
82
|
+
var listToDict = /* @__PURE__ */ __name((dict, predict) => {
|
|
83
|
+
const result = {};
|
|
84
|
+
for (const obj of dict) {
|
|
85
|
+
const keys = predict(obj);
|
|
86
|
+
for (const key of keys) {
|
|
87
|
+
if (typeof key === "string" && key.length > 0) {
|
|
88
|
+
result[key] = obj;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}, "listToDict");
|
|
82
94
|
var dictToKeyDict = /* @__PURE__ */ __name((dict, predict) => {
|
|
83
95
|
const result = {};
|
|
84
96
|
for (const obj in dict) {
|
|
@@ -294,7 +306,6 @@ var ItemOrderOutput = /* @__PURE__ */ __name((item, orders) => {
|
|
|
294
306
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: `
|
|
295
307
|
th {
|
|
296
308
|
align-items: center;
|
|
297
|
-
width:33%;
|
|
298
309
|
font-size: 1.8rem;
|
|
299
310
|
}
|
|
300
311
|
|
|
@@ -317,14 +328,18 @@ var ItemOrderOutput = /* @__PURE__ */ __name((item, orders) => {
|
|
|
317
328
|
] }),
|
|
318
329
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { style: "width:100%;", children: [
|
|
319
330
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
320
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "玩家名" }),
|
|
321
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "状态" }),
|
|
322
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "价格" })
|
|
331
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { style: "width:40%;", children: "玩家名" }),
|
|
332
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { style: "width:30%;", children: "状态" }),
|
|
333
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { style: "width:10%;", children: "价格" }),
|
|
334
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { style: "width:10%;", children: "数量" }),
|
|
335
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { style: "width:10%;", children: "好评" })
|
|
323
336
|
] }),
|
|
324
337
|
orders.map((order) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
325
338
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: order.user.ingameName }),
|
|
326
339
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: order.user.status }),
|
|
327
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: order.platinum })
|
|
340
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: order.platinum }),
|
|
341
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: order.quantity }),
|
|
342
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: order.user.reputation })
|
|
328
343
|
] }))
|
|
329
344
|
] })
|
|
330
345
|
] });
|
|
@@ -480,9 +495,7 @@ var RivenOrderComponent = /* @__PURE__ */ __name((item, order) => {
|
|
|
480
495
|
] });
|
|
481
496
|
}, "RivenOrderComponent");
|
|
482
497
|
var RivenAttributeComponent = /* @__PURE__ */ __name((attr, index) => {
|
|
483
|
-
const attrInfo =
|
|
484
|
-
(e) => e.slug == attr.url_name
|
|
485
|
-
);
|
|
498
|
+
const attrInfo = globalRivenAttributeDict[attr.url_name];
|
|
486
499
|
const attrName = attrInfo.i18n["zh-hans"].name;
|
|
487
500
|
const attrValuePrefix = attrInfo.unit === "multiply" ? "x" : "";
|
|
488
501
|
const unitSuffixMap = {
|
|
@@ -526,31 +539,59 @@ var RivenAttributeComponent = /* @__PURE__ */ __name((attr, index) => {
|
|
|
526
539
|
var globalItemList = [];
|
|
527
540
|
var globalRivenItemList = [];
|
|
528
541
|
var globalRivenAttributeList = [];
|
|
542
|
+
var globalItemDict = {};
|
|
543
|
+
var globalRivenItemDict = {};
|
|
544
|
+
var globalRivenAttributeDict = {};
|
|
545
|
+
var globalItemNameToIDDict = {};
|
|
529
546
|
var wmOnReady = /* @__PURE__ */ __name(async () => {
|
|
530
547
|
const data = await getWFMItemList();
|
|
531
548
|
if (!data) {
|
|
532
549
|
throw new Error("Failed to fetch items from Warframe Market API.");
|
|
533
550
|
}
|
|
534
|
-
globalItemList = data.data;
|
|
535
551
|
const rivenData = await getWFMRivenItemList();
|
|
536
552
|
if (!rivenData) {
|
|
537
553
|
throw new Error("Failed to fetch riven items from Warframe Market API.");
|
|
538
554
|
}
|
|
539
|
-
globalRivenItemList = rivenData.data;
|
|
540
555
|
const rivenAttributeData = await getWFMRivenAttributeList();
|
|
541
556
|
if (!rivenAttributeData) {
|
|
542
557
|
throw new Error(
|
|
543
558
|
"Failed to fetch riven attributes from Warframe Market API."
|
|
544
559
|
);
|
|
545
560
|
}
|
|
561
|
+
globalItemList = data.data;
|
|
562
|
+
globalRivenItemList = rivenData.data;
|
|
546
563
|
globalRivenAttributeList = rivenAttributeData.data;
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
(item) => compareENOrderName(itemName, item.i18n["en"].name)
|
|
564
|
+
globalItemDict = listToDict(data.data, (i) => [i.slug]);
|
|
565
|
+
globalRivenItemDict = listToDict(rivenData.data, (i) => [i.slug]);
|
|
566
|
+
globalRivenAttributeDict = listToDict(
|
|
567
|
+
rivenAttributeData.data,
|
|
568
|
+
(a) => [a.slug]
|
|
553
569
|
);
|
|
570
|
+
globalItemNameToIDDict = ((list) => {
|
|
571
|
+
const result = {};
|
|
572
|
+
for (const item of list) {
|
|
573
|
+
if (item.i18n["zh-hans"]?.name) {
|
|
574
|
+
result[normalizeOrderName(item.i18n["zh-hans"].name)] = item.slug;
|
|
575
|
+
}
|
|
576
|
+
if (item.i18n["en"]?.name) {
|
|
577
|
+
result[normalizeOrderName(item.i18n["en"].name)] = item.slug;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return result;
|
|
581
|
+
})(globalItemList);
|
|
582
|
+
}, "wmOnReady");
|
|
583
|
+
var getItemOrders = /* @__PURE__ */ __name(async (input) => {
|
|
584
|
+
if (!input) return null;
|
|
585
|
+
input = normalizeOrderName(input);
|
|
586
|
+
const isFullLevel = /^满级|满级$/.test(input);
|
|
587
|
+
if (isFullLevel) {
|
|
588
|
+
if (input.match(/^满级/)) {
|
|
589
|
+
input = input.slice(2, input.length);
|
|
590
|
+
} else if (input.match(/满级$/)) {
|
|
591
|
+
input = input.slice(0, input.length - 2);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
const targetItem = inputToItem(input);
|
|
554
595
|
if (!targetItem) {
|
|
555
596
|
return null;
|
|
556
597
|
}
|
|
@@ -560,7 +601,7 @@ var getItemOrders = /* @__PURE__ */ __name(async (itemName) => {
|
|
|
560
601
|
return null;
|
|
561
602
|
}
|
|
562
603
|
const result = data.data.filter(
|
|
563
|
-
(order) => order.user.status === "ingame" && order.visible && order.type === "sell"
|
|
604
|
+
(order) => order.user.status === "ingame" && order.visible && order.type === "sell" && (!isFullLevel || order.rank == targetItem.maxRank)
|
|
564
605
|
).sort((a, b) => toTimeStamp(b.updatedAt) - toTimeStamp(a.updatedAt)).sort((a, b) => a.platinum - b.platinum).slice(0, 5);
|
|
565
606
|
return {
|
|
566
607
|
item: targetItem,
|
|
@@ -570,7 +611,12 @@ var getItemOrders = /* @__PURE__ */ __name(async (itemName) => {
|
|
|
570
611
|
var generateItemOrderOutput = /* @__PURE__ */ __name(async (puppe, item, orders) => {
|
|
571
612
|
const element = ItemOrderOutput(item, orders);
|
|
572
613
|
const imgBase64 = await getHtmlImageBase64(puppe, element.toString());
|
|
573
|
-
|
|
614
|
+
if (!orders.length) {
|
|
615
|
+
return OutputImage(imgBase64);
|
|
616
|
+
}
|
|
617
|
+
const firstOrder = orders[0];
|
|
618
|
+
const comment = `/w ${firstOrder.user.ingameName} Hi! I want to buy: "${item.i18n["en"].name}${!item.maxRank || item.maxRank === 0 ? "" : ` (rank ${firstOrder.rank})`}" for ${firstOrder.platinum} platinum. (warframe.market)`;
|
|
619
|
+
return OutputImage(imgBase64) + comment;
|
|
574
620
|
}, "generateItemOrderOutput");
|
|
575
621
|
var getRivenOrders = /* @__PURE__ */ __name(async (input) => {
|
|
576
622
|
const targetItem = globalRivenItemList.find(
|
|
@@ -596,45 +642,229 @@ var generateRivenOrderOutput = /* @__PURE__ */ __name(async (puppe, item, orders
|
|
|
596
642
|
const imgBase64 = await getHtmlImageBase64(puppe, element.toString());
|
|
597
643
|
return OutputImage(imgBase64);
|
|
598
644
|
}, "generateRivenOrderOutput");
|
|
599
|
-
var
|
|
600
|
-
|
|
601
|
-
|
|
645
|
+
var warframeAlias = {
|
|
646
|
+
Volt: ["电", "电男", "伏特"],
|
|
647
|
+
Trinity: ["奶妈", "奶"],
|
|
648
|
+
Rhino: ["犀牛", "牛", "铁甲犀牛"],
|
|
649
|
+
Mag: ["磁妹", "磁力"],
|
|
650
|
+
Loki: ["洛基"],
|
|
651
|
+
Excalibur: ["咖喱棒", "圣剑", "咖喱"],
|
|
652
|
+
Ember: ["火鸡"],
|
|
653
|
+
Ash: ["灰烬", "灰烬之刃"],
|
|
654
|
+
Nyx: ["脑溢血"],
|
|
655
|
+
Frost: ["冰男", "冰雪寒霜", "冰队", "冰"],
|
|
656
|
+
Saryn: ["毒妈", "毒"],
|
|
657
|
+
Banshee: ["女妖", "女高音"],
|
|
658
|
+
Vauban: ["工程"],
|
|
659
|
+
Nova: ["诺娃", "加速", "加速娃"],
|
|
660
|
+
Nekros: ["摸尸", "摸"],
|
|
661
|
+
Valkyr: ["瓦尔基里", "瓦喵", "瓦"],
|
|
662
|
+
Oberon: ["奶爸", "龙王", "奥伯龙"],
|
|
663
|
+
Zephyr: ["鸟姐", "鸟"],
|
|
664
|
+
Hydroid: ["水男"],
|
|
665
|
+
Mirage: ["小丑", "丑"],
|
|
666
|
+
Limbo: ["小明", "李明博", "明"],
|
|
667
|
+
Mesa: ["女枪"],
|
|
668
|
+
Chroma: ["龙甲", "龙"],
|
|
669
|
+
Equinox: ["阴阳", "双子"],
|
|
670
|
+
Atlas: ["土石魔像", "土"],
|
|
671
|
+
Wukong: ["猴子", "齐天大圣", "悟空", "猴"],
|
|
672
|
+
Ivara: ["弓妹", "弓"],
|
|
673
|
+
Nezha: ["哪吒", "三太子"],
|
|
674
|
+
Inaros: ["沙"],
|
|
675
|
+
Titania: ["蝶妹"],
|
|
676
|
+
Nidus: ["蛆甲", "蛆"],
|
|
677
|
+
Octavia: ["DJ", "音乐"],
|
|
678
|
+
Harrow: ["主教"],
|
|
679
|
+
Gara: ["玻璃"],
|
|
680
|
+
Khora: ["猫"],
|
|
681
|
+
Revenant: ["夜灵"],
|
|
682
|
+
Garuda: ["血妈", "血"],
|
|
683
|
+
Baruuk: ["武僧"],
|
|
684
|
+
Hildryn: ["母牛"],
|
|
685
|
+
Wisp: ["花"],
|
|
686
|
+
Gauss: ["高斯"],
|
|
687
|
+
Grendel: ["肥宅"],
|
|
688
|
+
Protea: ["茶", "茶妹"],
|
|
689
|
+
Xaku: ["骨"],
|
|
690
|
+
Lavos: ["炼金", "药水", "药水哥", "蛇"],
|
|
691
|
+
Sevagoth: ["鬼", "鲨鱼"],
|
|
692
|
+
Yareli: ["水妹"],
|
|
693
|
+
Caliban: ["卡利班"],
|
|
694
|
+
Gyre: ["电妹"],
|
|
695
|
+
Styanax: ["斯巴达"],
|
|
696
|
+
Voruna: ["狼", "狼妹"],
|
|
697
|
+
Citrine: ["水晶", "宝石"],
|
|
698
|
+
Kullervo: ["刀哥"],
|
|
699
|
+
Dagath: ["马", "赛马娘", "马娘"],
|
|
700
|
+
Qorvex: ["暖气片"],
|
|
701
|
+
Dante: ["但丁"],
|
|
702
|
+
Jade: ["翡翠", "天使"],
|
|
703
|
+
Koumei: [],
|
|
704
|
+
"Cyte-09": ["Cyte09", "老九", "9", "九"],
|
|
705
|
+
Temple: ["吉他"],
|
|
706
|
+
Nokko: ["蘑菇"]
|
|
707
|
+
};
|
|
708
|
+
var warframeAliasDict = ((aliasObject) => {
|
|
709
|
+
const transformedObject = {};
|
|
710
|
+
for (const [key, aliases] of Object.entries(aliasObject)) {
|
|
711
|
+
for (const alias of aliases) {
|
|
712
|
+
if (typeof alias === "string" && alias.length > 0) {
|
|
713
|
+
transformedObject[alias] = key;
|
|
714
|
+
const warframeNameWithSuffix = `${alias}甲`;
|
|
715
|
+
transformedObject[warframeNameWithSuffix] = key;
|
|
716
|
+
}
|
|
717
|
+
transformedObject[key] = key;
|
|
718
|
+
}
|
|
602
719
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
720
|
+
return transformedObject;
|
|
721
|
+
})(warframeAlias);
|
|
722
|
+
var setSuffix = "一套";
|
|
723
|
+
var bpSuffix = "蓝图";
|
|
724
|
+
var primeSuffix = "prime";
|
|
725
|
+
var warframePartSuffix = ["系统", "头部神经光元", "机体"];
|
|
726
|
+
var weaponPartSuffix = [
|
|
727
|
+
"枪管",
|
|
728
|
+
"枪托",
|
|
729
|
+
"枪机",
|
|
730
|
+
"弓弦",
|
|
731
|
+
"上弓臂",
|
|
732
|
+
"下弓臂",
|
|
733
|
+
"刀刃",
|
|
734
|
+
"握柄",
|
|
735
|
+
"拳套",
|
|
736
|
+
"圆盘",
|
|
737
|
+
"连接器"
|
|
738
|
+
];
|
|
739
|
+
var removeNameSuffix = /* @__PURE__ */ __name((input) => {
|
|
740
|
+
if (input.endsWith(bpSuffix)) {
|
|
741
|
+
input = input.replace(new RegExp(`${bpSuffix}$`), "");
|
|
616
742
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
743
|
+
if (input.endsWith(setSuffix)) {
|
|
744
|
+
input = input.replace(new RegExp(`${setSuffix}$`), "");
|
|
745
|
+
}
|
|
746
|
+
if (input.endsWith(bpSuffix)) {
|
|
747
|
+
input = input.replace(new RegExp(`${bpSuffix}$`), "");
|
|
748
|
+
}
|
|
749
|
+
const suffix = warframePartSuffix.find((value) => input.endsWith(value)) ?? weaponPartSuffix.find((value) => input.endsWith(value)) ?? "";
|
|
750
|
+
if (suffix) {
|
|
751
|
+
const pure = input.replace(new RegExp(`${suffix}$`), "");
|
|
752
|
+
return {
|
|
753
|
+
pure,
|
|
754
|
+
suffix
|
|
755
|
+
};
|
|
756
|
+
} else {
|
|
757
|
+
return {
|
|
758
|
+
pure: input,
|
|
759
|
+
suffix
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
}, "removeNameSuffix");
|
|
763
|
+
var shortHandProcess = /* @__PURE__ */ __name((input) => {
|
|
764
|
+
const { pure: inputNoSuffix, suffix } = removeNameSuffix(input);
|
|
765
|
+
if (inputNoSuffix == input) {
|
|
766
|
+
const fixSet = input + setSuffix;
|
|
767
|
+
const fixSetRes = globalItemNameToIDDict[fixSet];
|
|
768
|
+
if (fixSetRes) return globalItemDict[fixSetRes];
|
|
769
|
+
const fixPrime = input.endsWith(primeSuffix) ? input : input.endsWith("p") ? input.slice(0, input.length - 1) + primeSuffix : input + primeSuffix;
|
|
770
|
+
const fixPrimeRes = globalItemNameToIDDict[fixPrime];
|
|
771
|
+
if (fixPrimeRes) return globalItemDict[fixPrimeRes];
|
|
772
|
+
const fixPrimeSet = fixPrime + setSuffix;
|
|
773
|
+
const fixPrimeSetRes = globalItemNameToIDDict[fixPrimeSet];
|
|
774
|
+
if (fixPrimeSetRes) return globalItemDict[fixPrimeSetRes];
|
|
775
|
+
const fixBP = input + bpSuffix;
|
|
776
|
+
const fixBPRes = globalItemNameToIDDict[fixBP];
|
|
777
|
+
if (fixBPRes) return globalItemDict[fixBPRes];
|
|
778
|
+
const fixPrimeBP = fixPrime + bpSuffix;
|
|
779
|
+
const fixPrimeBPRes = globalItemNameToIDDict[fixPrimeBP];
|
|
780
|
+
if (fixPrimeBPRes) return globalItemDict[fixPrimeBPRes];
|
|
781
|
+
} else {
|
|
782
|
+
const fixBP = inputNoSuffix + suffix + bpSuffix;
|
|
783
|
+
const fixBPRes = globalItemNameToIDDict[fixBP];
|
|
784
|
+
if (fixBPRes) return globalItemDict[fixBPRes];
|
|
785
|
+
const fixPrime = inputNoSuffix.endsWith(primeSuffix) ? inputNoSuffix : inputNoSuffix.endsWith("p") ? inputNoSuffix.slice(0, inputNoSuffix.length - 1) + primeSuffix : inputNoSuffix + primeSuffix;
|
|
786
|
+
const fixPrimeRes = globalItemNameToIDDict[fixPrime + suffix];
|
|
787
|
+
if (fixPrimeRes) return globalItemDict[fixPrimeRes];
|
|
788
|
+
const fixPrimeBP = fixPrime + suffix + bpSuffix;
|
|
789
|
+
const fixPrimeBPRes = globalItemNameToIDDict[fixPrimeBP];
|
|
790
|
+
if (fixPrimeBPRes) return globalItemDict[fixPrimeBPRes];
|
|
791
|
+
}
|
|
792
|
+
}, "shortHandProcess");
|
|
793
|
+
var inputToItem = /* @__PURE__ */ __name((input) => {
|
|
794
|
+
const slug = globalItemNameToIDDict[normalizeOrderName(input)];
|
|
795
|
+
if (slug) return globalItemDict[slug];
|
|
796
|
+
const normalShortHandRes = shortHandProcess(input);
|
|
797
|
+
if (normalShortHandRes) return normalShortHandRes;
|
|
798
|
+
const { pure: inputNoSuffix, suffix } = removeNameSuffix(input);
|
|
799
|
+
const aliasHasEndP = inputNoSuffix.endsWith(primeSuffix) ? inputNoSuffix.replace(new RegExp(`${primeSuffix}$`), "") : inputNoSuffix;
|
|
800
|
+
const mappedAliasHasEndP = warframeAliasDict[aliasHasEndP];
|
|
801
|
+
if (mappedAliasHasEndP) {
|
|
802
|
+
const aliasHasEndPRes = shortHandProcess(
|
|
803
|
+
normalizeOrderName(mappedAliasHasEndP) + primeSuffix + suffix
|
|
804
|
+
);
|
|
805
|
+
if (aliasHasEndPRes) return aliasHasEndPRes;
|
|
806
|
+
}
|
|
807
|
+
if (inputNoSuffix.endsWith("p")) {
|
|
808
|
+
const aliasNoEndP = inputNoSuffix.replace(/p$/, "");
|
|
809
|
+
const mappedAliasNoEndP = warframeAliasDict[aliasNoEndP];
|
|
810
|
+
if (mappedAliasNoEndP) {
|
|
811
|
+
const aliasNoEndPRes = shortHandProcess(
|
|
812
|
+
normalizeOrderName(mappedAliasNoEndP) + primeSuffix + suffix
|
|
813
|
+
);
|
|
814
|
+
if (aliasNoEndPRes) return aliasNoEndPRes;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
const compareCNOrderName = /* @__PURE__ */ __name((input2, standard) => {
|
|
818
|
+
if (!input2 || !standard || typeof input2 !== "string" || typeof standard !== "string") {
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
const normalizedInput = normalizeOrderName(input2);
|
|
822
|
+
const normalizedStandard = normalizeOrderName(standard);
|
|
823
|
+
if (!normalizedInput || !normalizedStandard) return false;
|
|
824
|
+
const normalizedStandardNoSet = normalizedStandard.replace(/一套/g, "");
|
|
825
|
+
const normalizedStandardNoSetSimplifiedPrime = normalizedStandardNoSet.replace(/prime/g, "p");
|
|
826
|
+
const normalizedStandardNoBlueprint = normalizedStandard.replace(
|
|
827
|
+
/蓝图/g,
|
|
828
|
+
""
|
|
829
|
+
);
|
|
830
|
+
const normalizedStandardNoBlueprintSimplifiedPrime = normalizedStandardNoBlueprint.replace(/prime/g, "p");
|
|
831
|
+
const normalizedStandardNoNeu = normalizedStandardNoBlueprintSimplifiedPrime.replace(
|
|
832
|
+
/头部神经光元/g,
|
|
833
|
+
"头"
|
|
834
|
+
);
|
|
835
|
+
return normalizedInput === normalizedStandard || normalizedInput === normalizedStandardNoSet || normalizedInput === normalizedStandardNoSetSimplifiedPrime || normalizedInput === normalizedStandardNoBlueprintSimplifiedPrime || normalizedInput === normalizedStandardNoNeu;
|
|
836
|
+
}, "compareCNOrderName");
|
|
837
|
+
const compareENOrderName = /* @__PURE__ */ __name((input2, standard) => {
|
|
838
|
+
if (!input2 || !standard || typeof input2 !== "string" || typeof standard !== "string") {
|
|
839
|
+
return false;
|
|
840
|
+
}
|
|
841
|
+
const endWithSet = standard.toLowerCase().endsWith(" set");
|
|
842
|
+
const standardNoSet = endWithSet ? standard.slice(0, -4) : standard;
|
|
843
|
+
const endWithBlueprint = standard.toLocaleLowerCase().endsWith("blueprint");
|
|
844
|
+
const standardNoBlueprint = endWithBlueprint ? standard.slice(0, -10) : standard;
|
|
845
|
+
const standardSimplifiedPrime = standardNoSet.replace(/ Prime/g, "p");
|
|
846
|
+
const standardNoBlueprintSimplifiedPrime = standardNoBlueprint.replace(
|
|
847
|
+
/ Prime/g,
|
|
848
|
+
"p"
|
|
849
|
+
);
|
|
850
|
+
const normalizedInput = normalizeOrderName(input2);
|
|
851
|
+
const normalizedStandard = normalizeOrderName(standard);
|
|
852
|
+
if (!normalizedInput || !normalizedStandard) return false;
|
|
853
|
+
const normalizedStandardNoSet = normalizeOrderName(standardNoSet);
|
|
854
|
+
const normalizedStandardSimplifiedPrime = normalizeOrderName(
|
|
855
|
+
standardSimplifiedPrime
|
|
856
|
+
);
|
|
857
|
+
const normalizedStandardNoBlueprint = normalizeOrderName(
|
|
858
|
+
standardNoBlueprintSimplifiedPrime
|
|
859
|
+
);
|
|
860
|
+
return normalizedInput === normalizedStandard || normalizedInput === normalizedStandardNoSet || normalizedInput === normalizedStandardSimplifiedPrime || normalizedInput === normalizedStandardNoBlueprint;
|
|
861
|
+
}, "compareENOrderName");
|
|
862
|
+
return globalItemList.find(
|
|
863
|
+
(item) => compareCNOrderName(input, item.i18n["zh-hans"].name)
|
|
864
|
+
) ?? globalItemList.find(
|
|
865
|
+
(item) => compareENOrderName(input, item.i18n["en"].name)
|
|
635
866
|
);
|
|
636
|
-
|
|
637
|
-
}, "compareENOrderName");
|
|
867
|
+
}, "inputToItem");
|
|
638
868
|
var compareRivenItemName = /* @__PURE__ */ __name((input, standard) => {
|
|
639
869
|
if (!input || !standard || typeof input !== "string" || typeof standard !== "string") {
|
|
640
870
|
return false;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-warframe",
|
|
3
3
|
"description": "WFMToolkit",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "yakumo build",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@koishijs/client": "^5.30.11",
|
|
52
52
|
"@koishijs/plugin-help": "^2.4.6",
|
|
53
53
|
"@satorijs/element": "^3.1.8",
|
|
54
|
-
"@types/node": "^
|
|
54
|
+
"@types/node": "^25.0.3",
|
|
55
55
|
"dtsc": "^3.1.0",
|
|
56
56
|
"esbuild": "^0.27.1",
|
|
57
57
|
"koishi": "^4.18.9",
|