diff options
-rwxr-xr-x | config/version.txt | 2 | ||||
-rw-r--r-- | modules/colorlib.js | 78 | ||||
-rwxr-xr-x | modules/embed.js | 13 | ||||
-rwxr-xr-x | package-lock.json | 128 | ||||
-rwxr-xr-x | package.json | 1 | ||||
-rwxr-xr-x | update/ponies/index.js | 9 | ||||
-rwxr-xr-x | update/ponies/parse.js | 64 |
7 files changed, 267 insertions, 28 deletions
diff --git a/config/version.txt b/config/version.txt index dc12480..0bc39ca 100755 --- a/config/version.txt +++ b/config/version.txt @@ -1 +1 @@ -2.2.60
\ No newline at end of file +2.2.63
\ No newline at end of file diff --git a/modules/colorlib.js b/modules/colorlib.js new file mode 100644 index 0000000..ec99d00 --- /dev/null +++ b/modules/colorlib.js @@ -0,0 +1,78 @@ +/* + * MIT License + * + * Copyright (c) 2022- Minteck + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +/** + * 0 = black + * 1 = white + * 2 = gray + * 3 = red + * 4 = orange + * 5 = yellow + * 6 = green + * 7 = blue + * 8 = purple + * 9 = pink + * 10 = brown + */ + +const Color = require('color'); + +module.exports = (hex, debug) => { + const color = Color(hex); + + const h = color.hsl().color[0]; + const s = color.hsl().color[1]; + const l = color.hsl().color[2]; + + if (s < 20) { // Consider it's grayscale + if (l >= 75) { + return debug ? "white" : 1; // white + } else if (l >= 15) { + return debug ? "gray" : 2; // gray + } else { + return debug ? "black" : 0; // black + } + } else { // Consider it's a color + if (h <= 10 || h > 340) { + return debug ? "red" : 3; // red + } else if (h > 10 && h <= 40) { + if (l > 65) { + return debug ? "orange" : 4; // orange + } else { + return debug ? "brown" : 10; // brown + } + } else if (h > 40 && h <= 67) { + return debug ? "yellow" : 5; // yellow + } else if (h > 67 && h <= 158) { + return debug ? "green" : 6; // green + } else if (h > 158 && h <= 253) { + return debug ? "blue" : 7; // blue + } else if (h > 253 && h <= 289) { + return debug ? "purple" : 8; // purple + } else if (h > 289 && h <= 340) { + return debug ? "pink" : 9; // pink + } + } +}
\ No newline at end of file diff --git a/modules/embed.js b/modules/embed.js index 9766055..cb49fdf 100755 --- a/modules/embed.js +++ b/modules/embed.js @@ -172,6 +172,10 @@ module.exports = (page, id, gid, isPublic, user, member, guild) => { break; } + if (d.kind.includes("\n")) { + kind = d.kind; + } + names = [...new Set(d.names.filter(e => e.trim().toLowerCase() !== page.toLowerCase()))]; let naming = "-"; @@ -211,9 +215,16 @@ module.exports = (page, id, gid, isPublic, user, member, guild) => { } } + let sex = ""; + if (d.sex.includes("\n") || d.sex.includes("&")) { + sex = d.sex; + } else { + sex = d.sex === "F" ? "♀ " + l("Female", "Fille", id, gid) : "♂ " + l("Male", "Garçon", id, gid); + } + let fields = [ { name: l("Nicknames", "Surnoms", id, gid), value: naming, inline: true }, - { name: l("Sex", "Sexe", id, gid), value: d.sex === "F" ? "♀ " + l("Female", "Fille", id, gid) : "♂ " + l("Male", "Garçon", id, gid), inline: true }, + { name: l("Sex", "Sexe", id, gid), value: sex, inline: true }, { name: l("Kind", "Type", id, gid), value: customEmoji(getKindIcon(page), member, guild) + " " + kind, inline: true }, { name: l("Generation", "Génération", id, gid), value: getGeneration(page, id, gid, member, guild), inline: true }, ]; diff --git a/package-lock.json b/package-lock.json index 0947bef..9361a88 100755 --- a/package-lock.json +++ b/package-lock.json @@ -4,10 +4,12 @@ "requires": true, "packages": { "": { + "name": "Ponyfind", "dependencies": { "@discordjs/builders": "^0.11.0", "@discordjs/rest": "^0.2.0-canary.0", "axios": "^0.24.0", + "color": "^4.2.1", "discord-api-types": "^0.26.1", "discord.js": "^13.5.0", "fastest-levenshtein": "^1.0.12", @@ -234,6 +236,43 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, + "node_modules/color": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.1.tgz", + "integrity": "sha512-MFJr0uY4RvTQUKvPq7dh9grVOTYSFeXja2mBXioCGjnjJoXrAp9jJ1NQTDR73c9nwBSAQiNKloKl5zq9WB9UPw==", + "dependencies": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + }, + "engines": { + "node": ">=12.5.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/color-string": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.0.tgz", + "integrity": "sha512-9Mrz2AQLefkH1UvASKj6v6hj/7eWgjnT/cVsR8CumieLoT+g900exWeNogqtweI8dxloXN9BDQTYro1oWu/5CQ==", + "dependencies": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, "node_modules/colors": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", @@ -380,9 +419,9 @@ "integrity": "sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow==" }, "node_modules/follow-redirects": { - "version": "1.14.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz", - "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==", + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", "funding": [ { "type": "individual", @@ -470,6 +509,11 @@ "npm": ">=1.3.7" } }, + "node_modules/is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, "node_modules/is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -539,14 +583,22 @@ } }, "node_modules/node-fetch": { - "version": "2.6.6", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz", - "integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==", + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", "dependencies": { "whatwg-url": "^5.0.0" }, "engines": { "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } } }, "node_modules/node-version-compare": { @@ -668,6 +720,14 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=", + "dependencies": { + "is-arrayish": "^0.3.1" + } + }, "node_modules/sshpk": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", @@ -1018,6 +1078,37 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, + "color": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.1.tgz", + "integrity": "sha512-MFJr0uY4RvTQUKvPq7dh9grVOTYSFeXja2mBXioCGjnjJoXrAp9jJ1NQTDR73c9nwBSAQiNKloKl5zq9WB9UPw==", + "requires": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "color-string": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.0.tgz", + "integrity": "sha512-9Mrz2AQLefkH1UvASKj6v6hj/7eWgjnT/cVsR8CumieLoT+g900exWeNogqtweI8dxloXN9BDQTYro1oWu/5CQ==", + "requires": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, "colors": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", @@ -1132,9 +1223,9 @@ "integrity": "sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow==" }, "follow-redirects": { - "version": "1.14.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz", - "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==" + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==" }, "forever-agent": { "version": "0.6.1", @@ -1188,6 +1279,11 @@ "sshpk": "^1.7.0" } }, + "is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -1248,9 +1344,9 @@ } }, "node-fetch": { - "version": "2.6.6", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz", - "integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==", + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", "requires": { "whatwg-url": "^5.0.0" } @@ -1344,6 +1440,14 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=", + "requires": { + "is-arrayish": "^0.3.1" + } + }, "sshpk": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", diff --git a/package.json b/package.json index a18c5e1..6b22e6a 100755 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "@discordjs/builders": "^0.11.0", "@discordjs/rest": "^0.2.0-canary.0", "axios": "^0.24.0", + "color": "^4.2.1", "discord-api-types": "^0.26.1", "discord.js": "^13.5.0", "fastest-levenshtein": "^1.0.12", diff --git a/update/ponies/index.js b/update/ponies/index.js index 0cc6af8..632796d 100755 --- a/update/ponies/index.js +++ b/update/ponies/index.js @@ -23,8 +23,7 @@ * */ -require('child_process').spawnSync("node", ["update/listgen.js"], {cwd: __dirname + "/..", stdio: "inherit"}) -require('child_process').spawnSync("node", ["update/pages.js"], {cwd: __dirname + "/..", stdio: "inherit"}) -require('child_process').spawnSync("node", ["update/infobox.js"], {cwd: __dirname + "/..", stdio: "inherit"}) -require('child_process').spawnSync("node", ["update/parse.js"], {cwd: __dirname + "/..", stdio: "inherit"}) -require('child_process').spawnSync("node", ["update/dict.js"], {cwd: __dirname + "/..", stdio: "inherit"})
\ No newline at end of file +require('child_process').spawnSync("node", ["update/ponies/pages.js"], {cwd: __dirname + "/../..", stdio: "inherit"}) +require('child_process').spawnSync("node", ["update/ponies/infobox.js"], {cwd: __dirname + "/../..", stdio: "inherit"}) +require('child_process').spawnSync("node", ["update/ponies/parse.js"], {cwd: __dirname + "/../..", stdio: "inherit"}) +require('child_process').spawnSync("node", ["update/ponies/dict.js"], {cwd: __dirname + "/../..", stdio: "inherit"})
\ No newline at end of file diff --git a/update/ponies/parse.js b/update/ponies/parse.js index 71ce007..c4cc1d4 100755 --- a/update/ponies/parse.js +++ b/update/ponies/parse.js @@ -25,10 +25,11 @@ const fs = require('fs');
const axios = require('axios');
+const colorlib = require('../../modules/colorlib');
console.log("Parsing infobox data...");
-let ponies = {};
+global.ponies = {};
(async () => {
for (let title in JSON.parse(fs.readFileSync("./data/boxes.json").toString())) {
@@ -40,6 +41,11 @@ let ponies = {}; extract_fr: "",
generation: -1,
color: "000000",
+ search: {
+ mane: [],
+ coat: [],
+ eyes: []
+ },
image: "https://example.com",
kind: "Pony",
sex: "Unknown",
@@ -62,14 +68,54 @@ let ponies = {}; }
if (typeof box.kind !== "undefined") {
- kp = box.kind.replace(/<!--[\s\S]*?-->/g, "").replace(/[^a-zA-Z0-9-_ ]/gm, "").split(" ")[0];
- data.kind = kp.substring(kp.replace(/([A-Z])([a-z0-9]*)$/g, "").length);
+ box.kind = box.kind.replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "\n");
+
+ if (box.kind.includes("\n")) {
+ data.kind = box.kind.replace(/[\[\]]/gm, "").replace(/<(.*)>/gm, "").replace(/([a-zA-Z0-9 \-_,.'"]*)_([a-zA-Z0-9 \-_,.'"]*)/gm, "$2").replace(/^(.*)\|(.*)$/gm, "$2");
+ } else {
+ kp = box.kind.replace(/<!--[\s\S]*?-->/g, "").replace(/[^a-zA-Z0-9-_ ]/gm, "").split(" ")[0];
+ data.kind = kp.substring(kp.replace(/([A-Z])([a-z0-9]*)$/g, "").length);
+ }
+ }
+
+ if (typeof box.sex !== "undefined") {
+ box.sex = box.sex.replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "\n");
+
+ if (box.sex.includes("\n") || box.sex.includes("&")) {
+ data.sex = box.sex.replace(/<!--[\s\S]*?-->/g, "").trim();
+ } else {
+ data.sex = box.sex.replace(/<!--[\s\S]*?-->/g, "").trim().startsWith("F") ? "F" : "M";
+ }
}
- if (typeof box.sex !== "undefined") data.sex = box.sex.replace(/<!--[\s\S]*?-->/g, "").trim().startsWith("F") ? "F" : "M";
if (typeof box._extract !== "undefined") {
data.extract = box._extract;
}
- if (typeof box.coat !== "undefined") data.color = box.coat.replace(/<!--[\s\S]*?-->/g, "").trim().replace(/\[([a-z.\/ \nA-Z0-9:]*)\/(.{6})\/ (.*)\]/gm, "$2").replace(/{{perbang\|([0-9A-Fa-f].{5})(.*)/g, "$1");
+ if (typeof box.coat !== "undefined") data.color = box.coat.trim().replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "|").split("|").map((i) => { return i.replace(/<!--[\s\S]*?-->/g, "").trim().replace(/\[([a-z.\/ \nA-Z0-9:]*)\/(.{6})\/ (.*)\]/gm, "$2").replace(/{{perbang\|([0-9A-Fa-f].{5})(.*)/g, "$1").replace(/\[(.*)\/(.*)\/ (.*)\]/g, "$2"); })[0];
+
+ try {
+ if (typeof box.coat !== "undefined") data.search.coat = box.coat.trim().replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "|").split("|").map((i) => {
+ try {
+ return colorlib("#" + i.replace(/<!--[\s\S]*?-->/g, "").trim().replace(/\[([a-z.\/ \nA-Z0-9:]*)\/(.{6})\/ (.*)\]/gm, "$2").replace(/{{perbang\|([0-9A-Fa-f].{5})(.*)/g, "$1").replace(/\[(.*)\/(.*)\/ (.*)\]/g, "$2"));
+ } catch (e) {}
+ }).filter(i => typeof i !== "number");
+ } catch (e) {}
+
+ try {
+ if (typeof box.eyes !== "undefined") data.search.eyes = box.eyes.trim().replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "|").split("|").map((i) => {
+ try {
+ return colorlib("#" + i.replace(/<!--[\s\S]*?-->/g, "").trim().replace(/\[([a-z.\/ \nA-Z0-9:]*)\/(.{6})\/ (.*)\]/gm, "$2").replace(/{{perbang\|([0-9A-Fa-f].{5})(.*)/g, "$1").replace(/\[(.*)\/(.*)\/ (.*)\]/g, "$2"));
+ } catch (e) {}
+ }).filter(i => typeof i !== "number");
+ } catch (e) {}
+
+ try {
+ if (typeof box.mane !== "undefined") data.search.mane = box.mane.trim().replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "|").split("|").map((i) => {
+ try {
+ return colorlib("#" + i.replace(/<!--[\s\S]*?-->/g, "").trim().replace(/\[([a-z.\/ \nA-Z0-9:]*)\/(.{6})\/ (.*)\]/gm, "$2").replace(/{{perbang\|([0-9A-Fa-f].{5})(.*)/g, "$1").replace(/\[(.*)\/(.*)\/ (.*)\]/g, "$2"));
+ } catch (e) {}
+ }).filter(i => typeof i !== "number");
+ } catch (e) {}
+
try {
if (typeof box.main !== "undefined") data.image = (await axios.head("https://mlp.fandom.com/Special:FilePath/" + encodeURI(box.main.replace(/<!--[\s\S]*?-->/g, "").trim()).replaceAll("?", "%3F").replaceAll("&", "%26"))).request.res.responseUrl;
} catch (e) {
@@ -130,11 +176,11 @@ let ponies = {}; box.residence/*.replace(/\[\[(.*)_(.*)\]\]|\[\[(.*)\|(.*)\]\]|\[\[(.*)\]\]/gm, "$2$4$5")*/.replace(/<!--[\s\S]*?-->/g, "").trim().replace(/\|/gm, "_").replace(/<( ||(|| )\/)( ||(|| )\/)(b|B)(r|R)( ||(|| )\/)( ||(|| )\/)>/gm, "|").replace(/( \|| \| | \| )/gm, "|").split("|").forEach((e) => {
residences.push(e.trim().replace(/[\[\]]/gm, "").replace(/<(.*)>/gm, "").replace(/([a-zA-Z0-9 \-_,.'"]*)_([a-zA-Z0-9 \-_,.'"]*)/gm, "$2"));
})
- data.residence = residences.replaceAll("Locations#", "");
+ data.residence = residences.map((i) => { return i.replaceAll("Locations#", "") });
}
if ((typeof box.name2 !== "undefined" || typeof box.name3 !== "undefined" || typeof box.name4 !== "undefined" || typeof box.name5 !== "undefined" || typeof box.coat !== "undefined" || typeof box.occupation !== "undefined" || typeof box.residence !== "undefined") && typeof box.sex !== "undefined") ponies[title] = data;
- }
-})()
-fs.writeFileSync("./data/data.json", JSON.stringify(ponies, null, 4));
\ No newline at end of file + fs.writeFileSync("./data/data.json", JSON.stringify(ponies, null, 4));
+ }
+})()
\ No newline at end of file |