koishi-plugin-minecraft-notifier 1.10.0 → 1.10.2
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/helper/xaml-helper.d.ts +1 -0
- package/lib/index.cjs +17 -10
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function escapeForXaml(text: string): string;
|
package/lib/index.cjs
CHANGED
|
@@ -540,6 +540,11 @@ async function upsertFileToGitCode(ctx, owner, repo, path3, content, message, to
|
|
|
540
540
|
});
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
+
// src/helper/xaml-helper.ts
|
|
544
|
+
function escapeForXaml(text) {
|
|
545
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/\\/g, "\\\\");
|
|
546
|
+
}
|
|
547
|
+
|
|
543
548
|
// src/xaml-generator.ts
|
|
544
549
|
function generateXaml(summary, version) {
|
|
545
550
|
const orderedCategories = [
|
|
@@ -564,7 +569,7 @@ function generateXaml(summary, version) {
|
|
|
564
569
|
<TextBlock
|
|
565
570
|
Margin="${margin}"
|
|
566
571
|
Foreground="{DynamicResource ColorBrush1}"
|
|
567
|
-
Text="- ${(0, import_autocorrect_node.format)(msg)}" />`;
|
|
572
|
+
Text="- ${escapeForXaml((0, import_autocorrect_node.format)(msg))}" />`;
|
|
568
573
|
}
|
|
569
574
|
for (let j = 0; j < subcategories.length; j++) {
|
|
570
575
|
const sub = subcategories[j];
|
|
@@ -573,7 +578,7 @@ function generateXaml(summary, version) {
|
|
|
573
578
|
Margin="0,0,0,4"
|
|
574
579
|
FontSize="14"
|
|
575
580
|
Foreground="{DynamicResource ColorBrush3}"
|
|
576
|
-
Text="${sub.emoji} ${sub.subcategory}" />`;
|
|
581
|
+
Text="${sub.emoji} ${escapeForXaml((0, import_autocorrect_node.format)(sub.subcategory))}" />`;
|
|
577
582
|
for (let k = 0; k < sub.items.length; k++) {
|
|
578
583
|
const msg = sub.items[k];
|
|
579
584
|
const margin = k === sub.items.length - 1 && j === subcategories.length - 1 ? "" : 'Margin="0,0,0,2"';
|
|
@@ -581,7 +586,7 @@ function generateXaml(summary, version) {
|
|
|
581
586
|
<TextBlock
|
|
582
587
|
${margin}
|
|
583
588
|
Foreground="{DynamicResource ColorBrush1}"
|
|
584
|
-
Text=" - ${(0, import_autocorrect_node.format)(msg)}" />`;
|
|
589
|
+
Text=" - ${escapeForXaml((0, import_autocorrect_node.format)(msg))}" />`;
|
|
585
590
|
}
|
|
586
591
|
if (j < subcategories.length - 1) {
|
|
587
592
|
contentXaml += `
|
|
@@ -592,7 +597,7 @@ function generateXaml(summary, version) {
|
|
|
592
597
|
categoriesXaml += `
|
|
593
598
|
<!-- ${categoryTitle}\u5361\u7247 -->
|
|
594
599
|
<local:MyCard
|
|
595
|
-
Title="${categoryTitle}"
|
|
600
|
+
Title="${escapeForXaml((0, import_autocorrect_node.format)(categoryTitle))}"
|
|
596
601
|
Margin="0,5,0,10"
|
|
597
602
|
CanSwap="True"
|
|
598
603
|
IsSwapped="${["new_features", "improvements", "balancing"].includes(category) ? "False" : "True"}"
|
|
@@ -785,6 +790,10 @@ async function checkVersionUpdate(ctx, cfg, articleRecord, notifierRecord, versi
|
|
|
785
790
|
}
|
|
786
791
|
const currentTryTime = articleRecord[tryTimeKey];
|
|
787
792
|
const newVersion = notifierRecord[versionKey];
|
|
793
|
+
await updateArticleRecord(ctx, {
|
|
794
|
+
[versionKey]: newVersion,
|
|
795
|
+
latestVersion: newVersion
|
|
796
|
+
});
|
|
788
797
|
const success = await processNewVersionArticle(
|
|
789
798
|
ctx,
|
|
790
799
|
cfg,
|
|
@@ -793,21 +802,19 @@ async function checkVersionUpdate(ctx, cfg, articleRecord, notifierRecord, versi
|
|
|
793
802
|
);
|
|
794
803
|
if (success) {
|
|
795
804
|
await updateArticleRecord(ctx, {
|
|
796
|
-
[
|
|
797
|
-
[tryTimeKey]: 0,
|
|
798
|
-
latestVersion: newVersion
|
|
805
|
+
[tryTimeKey]: 0
|
|
799
806
|
});
|
|
800
807
|
return true;
|
|
801
808
|
}
|
|
802
809
|
const newTryTime = currentTryTime + 1;
|
|
803
810
|
if (newTryTime >= 5) {
|
|
804
811
|
await updateArticleRecord(ctx, {
|
|
805
|
-
[
|
|
806
|
-
[tryTimeKey]: 0,
|
|
807
|
-
latestVersion: newVersion
|
|
812
|
+
[tryTimeKey]: 0
|
|
808
813
|
});
|
|
809
814
|
} else {
|
|
810
815
|
await updateArticleRecord(ctx, {
|
|
816
|
+
[versionKey]: articleRecord[versionKey],
|
|
817
|
+
latestVersion: articleRecord[versionKey],
|
|
811
818
|
[tryTimeKey]: newTryTime
|
|
812
819
|
});
|
|
813
820
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-minecraft-notifier",
|
|
3
3
|
"description": "A Minecraft new version notification plugin, also featuring a PCL homepage.",
|
|
4
|
-
"version": "1.10.
|
|
4
|
+
"version": "1.10.2",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"type": "module",
|