koishi-plugin-minecraft-notifier 1.10.3 → 1.11.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/changelog-summarizer.d.ts +2 -2
- package/lib/helper/article-helper.d.ts +1 -1
- package/lib/index.cjs +61 -167
- package/lib/prompt-const.d.ts +1 -1
- package/lib/translation-fetcher.d.ts +1 -1
- package/lib/version-checker.d.ts +1 -1
- package/lib/xaml-generator.d.ts +1 -1
- package/package.json +8 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '@pynickle/koishi-plugin-adapter-onebot';
|
|
2
|
-
import { Context } from 'koishi';
|
|
3
2
|
import { Config } from './index';
|
|
3
|
+
import { Context } from 'koishi';
|
|
4
4
|
export declare const minecraftSummaryTypeMap: Record<string, string>;
|
|
5
5
|
export declare function checkNewVersionArticle(ctx: Context, cfg: Config): Promise<void>;
|
|
6
6
|
export declare function processNewVersionArticle(ctx: Context, cfg: Config, version: string, isSnapshot: boolean): Promise<boolean>;
|
|
7
|
-
export declare function fetchArticleContent(ctx: Context, version: string
|
|
7
|
+
export declare function fetchArticleContent(ctx: Context, version: string): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function generateArticleUrl(version: string
|
|
1
|
+
export declare function generateArticleUrl(version: string): string;
|
package/lib/index.cjs
CHANGED
|
@@ -35,45 +35,20 @@ __export(index_exports, {
|
|
|
35
35
|
name: () => name
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(index_exports);
|
|
38
|
-
var import_fs = __toESM(require("fs"), 1);
|
|
39
|
-
var import_koishi = require("koishi");
|
|
40
|
-
var import_node_fs2 = require("node:fs");
|
|
41
|
-
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
42
38
|
|
|
43
39
|
// src/helper/article-helper.ts
|
|
44
|
-
function generateArticleUrl(version
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
function generateArticleUrl(version) {
|
|
41
|
+
const baseUrl = "https://www.minecraft.net/en-us/article";
|
|
42
|
+
const normalizedVersion = version.trim().toLowerCase().replace(/\s+/g, "");
|
|
43
|
+
const urlVersion = normalizedVersion.replaceAll(".", "-");
|
|
44
|
+
if (normalizedVersion.includes("-snapshot-")) {
|
|
45
|
+
return `${baseUrl}/minecraft-${urlVersion}`;
|
|
49
46
|
}
|
|
50
|
-
return `${baseUrl}/minecraft-java-edition-${
|
|
51
|
-
}
|
|
52
|
-
function generateSnapshotUrl(baseUrl, version, cleanVersion) {
|
|
53
|
-
if (version.includes("rc")) {
|
|
54
|
-
return buildReleaseUrl(baseUrl, version, "release-candidate");
|
|
55
|
-
}
|
|
56
|
-
if (version.includes("pre")) {
|
|
57
|
-
return buildReleaseUrl(baseUrl, version, "pre-release");
|
|
58
|
-
}
|
|
59
|
-
return `${baseUrl}/minecraft-snapshot-${cleanVersion}`;
|
|
60
|
-
}
|
|
61
|
-
function buildReleaseUrl(baseUrl, version, releaseType) {
|
|
62
|
-
const [mainVersion] = version.split("-");
|
|
63
|
-
const buildNumber = version.slice(-1);
|
|
64
|
-
const formattedVersion = mainVersion.replaceAll(".", "-");
|
|
65
|
-
return `${baseUrl}/minecraft-${formattedVersion}-${releaseType}-${buildNumber}`;
|
|
47
|
+
return `${baseUrl}/minecraft-java-edition-${urlVersion}`;
|
|
66
48
|
}
|
|
67
49
|
|
|
68
|
-
// src/version-checker.ts
|
|
69
|
-
var import_axios4 = __toESM(require("axios"), 1);
|
|
70
|
-
|
|
71
50
|
// src/changelog-summarizer.ts
|
|
72
51
|
var import_koishi_plugin_adapter_onebot = require("@pynickle/koishi-plugin-adapter-onebot");
|
|
73
|
-
var import_autocorrect_node2 = require("autocorrect-node");
|
|
74
|
-
var import_axios3 = __toESM(require("axios"), 1);
|
|
75
|
-
var cheerio2 = __toESM(require("cheerio"), 1);
|
|
76
|
-
var import_turndown = __toESM(require("turndown"), 1);
|
|
77
52
|
|
|
78
53
|
// src/helper/onebot-helper.ts
|
|
79
54
|
function createBotTextMsgNode(bot, content) {
|
|
@@ -136,14 +111,10 @@ async function fetchGitCodeTranslations(ctx, owner, repo, path3, token, branch =
|
|
|
136
111
|
headers: { Authorization: `Bearer ${token}` }
|
|
137
112
|
});
|
|
138
113
|
if (!response.data?.content) {
|
|
139
|
-
ctx.logger("translation-extractor").warn(
|
|
140
|
-
"GitCode file has no content"
|
|
141
|
-
);
|
|
114
|
+
ctx.logger("translation-extractor").warn("GitCode file has no content");
|
|
142
115
|
return [];
|
|
143
116
|
}
|
|
144
|
-
const content = Buffer.from(response.data.content, "base64").toString(
|
|
145
|
-
"utf-8"
|
|
146
|
-
);
|
|
117
|
+
const content = Buffer.from(response.data.content, "base64").toString("utf-8");
|
|
147
118
|
return parseTranslationContent(content);
|
|
148
119
|
} catch (error) {
|
|
149
120
|
ctx.logger("translation-extractor").warn(
|
|
@@ -236,10 +207,7 @@ async function fetchWikiTranslations(ctx) {
|
|
|
236
207
|
});
|
|
237
208
|
return translations;
|
|
238
209
|
} catch (error) {
|
|
239
|
-
ctx.logger("translation-extractor").warn(
|
|
240
|
-
"Failed to fetch Wiki translations:",
|
|
241
|
-
error
|
|
242
|
-
);
|
|
210
|
+
ctx.logger("translation-extractor").warn("Failed to fetch Wiki translations:", error);
|
|
243
211
|
return [];
|
|
244
212
|
}
|
|
245
213
|
}
|
|
@@ -274,10 +242,7 @@ async function extractTranslations(ctx, cfg, searchStr) {
|
|
|
274
242
|
}
|
|
275
243
|
return matches.map(({ english, chinese }) => `${english}: ${chinese}`).join("\n");
|
|
276
244
|
} catch (error) {
|
|
277
|
-
ctx.logger("translation-extractor").warn(
|
|
278
|
-
"Failed to extract translations:",
|
|
279
|
-
error
|
|
280
|
-
);
|
|
245
|
+
ctx.logger("translation-extractor").warn("Failed to extract translations:", error);
|
|
281
246
|
return "";
|
|
282
247
|
}
|
|
283
248
|
}
|
|
@@ -431,11 +396,6 @@ As the Minecraft Update Log JSON Summary Specialist, you must adhere to the abov
|
|
|
431
396
|
`;
|
|
432
397
|
}
|
|
433
398
|
|
|
434
|
-
// src/xaml-generator.ts
|
|
435
|
-
var import_autocorrect_node = require("autocorrect-node");
|
|
436
|
-
var import_node_fs = require("node:fs");
|
|
437
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
438
|
-
|
|
439
399
|
// src/helper/git-platform-helper.ts
|
|
440
400
|
var import_axios2 = __toESM(require("axios"), 1);
|
|
441
401
|
var PLATFORM_CONFIG = {
|
|
@@ -449,15 +409,7 @@ var PLATFORM_CONFIG = {
|
|
|
449
409
|
}
|
|
450
410
|
};
|
|
451
411
|
async function upsertFileToGitPlatform(ctx, platform, params) {
|
|
452
|
-
const {
|
|
453
|
-
owner,
|
|
454
|
-
repo,
|
|
455
|
-
path: path3,
|
|
456
|
-
content,
|
|
457
|
-
message,
|
|
458
|
-
token,
|
|
459
|
-
branch = "master"
|
|
460
|
-
} = params;
|
|
412
|
+
const { owner, repo, path: path3, content, message, token, branch = "master" } = params;
|
|
461
413
|
const config = PLATFORM_CONFIG[platform];
|
|
462
414
|
const loggerName = `${platform}-uploader`;
|
|
463
415
|
const base64Content = Buffer.from(content, "utf-8").toString("base64");
|
|
@@ -546,6 +498,9 @@ function escapeForXaml(text) {
|
|
|
546
498
|
}
|
|
547
499
|
|
|
548
500
|
// src/xaml-generator.ts
|
|
501
|
+
var import_autocorrect_node = require("autocorrect-node");
|
|
502
|
+
var import_node_fs = require("node:fs");
|
|
503
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
549
504
|
function generateXaml(summary, version) {
|
|
550
505
|
const orderedCategories = [
|
|
551
506
|
"new_features",
|
|
@@ -671,12 +626,7 @@ ${categoriesXaml}
|
|
|
671
626
|
}
|
|
672
627
|
async function exportXaml(ctx, cfg, summary, version) {
|
|
673
628
|
const xaml = generateXaml(summary, version);
|
|
674
|
-
const xamlPath = import_node_path.default.join(
|
|
675
|
-
ctx.baseDir,
|
|
676
|
-
"data",
|
|
677
|
-
"minecraft-notifier",
|
|
678
|
-
"xaml"
|
|
679
|
-
);
|
|
629
|
+
const xamlPath = import_node_path.default.join(ctx.baseDir, "data", "minecraft-notifier", "xaml");
|
|
680
630
|
const xamlName = `${version}.xaml`;
|
|
681
631
|
let fullXamlPath = import_node_path.default.join(xamlPath, xamlName);
|
|
682
632
|
let fullHomePagePath = import_node_path.default.join(xamlPath, "PCL.HomePage.xaml");
|
|
@@ -694,14 +644,9 @@ async function exportXaml(ctx, cfg, summary, version) {
|
|
|
694
644
|
"master"
|
|
695
645
|
).then((result) => {
|
|
696
646
|
if (result.success) {
|
|
697
|
-
ctx.logger("minecraft-notifier").info(
|
|
698
|
-
"Upsert successful of gitee."
|
|
699
|
-
);
|
|
647
|
+
ctx.logger("minecraft-notifier").info("Upsert successful of gitee.");
|
|
700
648
|
} else {
|
|
701
|
-
ctx.logger("minecraft-notifier").warn(
|
|
702
|
-
"Upsert failed of gitee:",
|
|
703
|
-
result.error
|
|
704
|
-
);
|
|
649
|
+
ctx.logger("minecraft-notifier").warn("Upsert failed of gitee:", result.error);
|
|
705
650
|
}
|
|
706
651
|
});
|
|
707
652
|
await upsertFileToGitee(
|
|
@@ -727,14 +672,9 @@ async function exportXaml(ctx, cfg, summary, version) {
|
|
|
727
672
|
"master"
|
|
728
673
|
).then((result) => {
|
|
729
674
|
if (result.success) {
|
|
730
|
-
ctx.logger("minecraft-notifier").info(
|
|
731
|
-
"Upsert successful of gitcode."
|
|
732
|
-
);
|
|
675
|
+
ctx.logger("minecraft-notifier").info("Upsert successful of gitcode.");
|
|
733
676
|
} else {
|
|
734
|
-
ctx.logger("minecraft-notifier").warn(
|
|
735
|
-
"Upsert failed of gitcode:",
|
|
736
|
-
result.error
|
|
737
|
-
);
|
|
677
|
+
ctx.logger("minecraft-notifier").warn("Upsert failed of gitcode:", result.error);
|
|
738
678
|
}
|
|
739
679
|
});
|
|
740
680
|
await upsertFileToGitCode(
|
|
@@ -752,6 +692,10 @@ async function exportXaml(ctx, cfg, summary, version) {
|
|
|
752
692
|
}
|
|
753
693
|
|
|
754
694
|
// src/changelog-summarizer.ts
|
|
695
|
+
var import_autocorrect_node2 = require("autocorrect-node");
|
|
696
|
+
var import_axios3 = __toESM(require("axios"), 1);
|
|
697
|
+
var cheerio2 = __toESM(require("cheerio"), 1);
|
|
698
|
+
var import_turndown = __toESM(require("turndown"), 1);
|
|
755
699
|
var minecraftSummaryTypeMap = {
|
|
756
700
|
new_features: "\u2728 \u65B0\u7279\u6027",
|
|
757
701
|
improvements: "\u{1F527} \u6539\u8FDB\u4E0E\u4F18\u5316",
|
|
@@ -794,12 +738,7 @@ async function checkVersionUpdate(ctx, cfg, articleRecord, notifierRecord, versi
|
|
|
794
738
|
[versionKey]: newVersion,
|
|
795
739
|
latestVersion: newVersion
|
|
796
740
|
});
|
|
797
|
-
const success = await processNewVersionArticle(
|
|
798
|
-
ctx,
|
|
799
|
-
cfg,
|
|
800
|
-
newVersion,
|
|
801
|
-
isSnapshot
|
|
802
|
-
);
|
|
741
|
+
const success = await processNewVersionArticle(ctx, cfg, newVersion, isSnapshot);
|
|
803
742
|
if (success) {
|
|
804
743
|
await updateArticleRecord(ctx, {
|
|
805
744
|
[tryTimeKey]: 0
|
|
@@ -821,19 +760,15 @@ async function checkVersionUpdate(ctx, cfg, articleRecord, notifierRecord, versi
|
|
|
821
760
|
return false;
|
|
822
761
|
}
|
|
823
762
|
async function updateArticleRecord(ctx, updates) {
|
|
824
|
-
await ctx.database.upsert("minecraft_article_version", [
|
|
825
|
-
{ id: 1, ...updates }
|
|
826
|
-
]);
|
|
763
|
+
await ctx.database.upsert("minecraft_article_version", [{ id: 1, ...updates }]);
|
|
827
764
|
}
|
|
828
765
|
async function processNewVersionArticle(ctx, cfg, version, isSnapshot) {
|
|
829
766
|
ctx.logger("minecraft-notifier").info(
|
|
830
767
|
`Processing new ${isSnapshot ? "snapshot" : "release"} version: ${version}`
|
|
831
768
|
);
|
|
832
|
-
const content = await fetchArticleContent(ctx, version
|
|
769
|
+
const content = await fetchArticleContent(ctx, version);
|
|
833
770
|
if (!content) {
|
|
834
|
-
ctx.logger("minecraft-notifier").warn(
|
|
835
|
-
`No content found for version ${version}`
|
|
836
|
-
);
|
|
771
|
+
ctx.logger("minecraft-notifier").warn(`No content found for version ${version}`);
|
|
837
772
|
return;
|
|
838
773
|
}
|
|
839
774
|
ctx.logger("minecraft-notifier").info(
|
|
@@ -855,11 +790,7 @@ ${updateContent}
|
|
|
855
790
|
messages: [
|
|
856
791
|
{
|
|
857
792
|
role: "system",
|
|
858
|
-
content: await getSustemPrompt(
|
|
859
|
-
ctx,
|
|
860
|
-
cfg,
|
|
861
|
-
updateContent.toLowerCase()
|
|
862
|
-
)
|
|
793
|
+
content: await getSustemPrompt(ctx, cfg, updateContent.toLowerCase())
|
|
863
794
|
},
|
|
864
795
|
{
|
|
865
796
|
role: "user",
|
|
@@ -927,11 +858,7 @@ ${updateContent}
|
|
|
927
858
|
}
|
|
928
859
|
}
|
|
929
860
|
},
|
|
930
|
-
required: [
|
|
931
|
-
"subcategory",
|
|
932
|
-
"emoji",
|
|
933
|
-
"items"
|
|
934
|
-
],
|
|
861
|
+
required: ["subcategory", "emoji", "items"],
|
|
935
862
|
additionalProperties: false
|
|
936
863
|
}
|
|
937
864
|
}
|
|
@@ -956,10 +883,7 @@ ${updateContent}
|
|
|
956
883
|
}
|
|
957
884
|
});
|
|
958
885
|
} catch (e) {
|
|
959
|
-
ctx.logger("minecraft-notifier").error(
|
|
960
|
-
"Summarization API error:",
|
|
961
|
-
e.response?.data
|
|
962
|
-
);
|
|
886
|
+
ctx.logger("minecraft-notifier").error("Summarization API error:", e.response?.data);
|
|
963
887
|
return false;
|
|
964
888
|
}
|
|
965
889
|
const content = response.data.choices[0].message.content;
|
|
@@ -967,9 +891,7 @@ ${updateContent}
|
|
|
967
891
|
ctx.logger("minecraft-notifier").info(
|
|
968
892
|
`Summarization completed for version ${version}. Preparing to send notifications...`
|
|
969
893
|
);
|
|
970
|
-
const messages = [
|
|
971
|
-
createBotTextMsgNode(ctx.bots[0], `=== ${version} \u66F4\u65B0\u603B\u7ED3 ===`)
|
|
972
|
-
];
|
|
894
|
+
const messages = [createBotTextMsgNode(ctx.bots[0], `=== ${version} \u66F4\u65B0\u603B\u7ED3 ===`)];
|
|
973
895
|
const orderedCategories = Object.keys(minecraftSummaryTypeMap);
|
|
974
896
|
for (const category of orderedCategories) {
|
|
975
897
|
const catData = summary[category];
|
|
@@ -979,23 +901,16 @@ ${updateContent}
|
|
|
979
901
|
const categoryTitle = `\u3010${minecraftSummaryTypeMap[category]}\u3011`;
|
|
980
902
|
if (general.length > 0) {
|
|
981
903
|
const generalList = general.map((msg) => `- ${(0, import_autocorrect_node2.format)(msg)}`).join("\n");
|
|
982
|
-
messages.push(
|
|
983
|
-
|
|
984
|
-
ctx.bots[0],
|
|
985
|
-
`${categoryTitle}
|
|
986
|
-
${generalList}`
|
|
987
|
-
)
|
|
988
|
-
);
|
|
904
|
+
messages.push(createBotTextMsgNode(ctx.bots[0], `${categoryTitle}
|
|
905
|
+
${generalList}`));
|
|
989
906
|
} else if (subcategories.length > 0) {
|
|
990
907
|
messages.push(createBotTextMsgNode(ctx.bots[0], categoryTitle));
|
|
991
908
|
}
|
|
992
909
|
for (const sub of subcategories) {
|
|
993
910
|
const subHeader = `${sub.emoji} ${sub.subcategory}`;
|
|
994
911
|
const subList = sub.items.map((msg) => `- ${(0, import_autocorrect_node2.format)(msg)}`).join("\n");
|
|
995
|
-
messages.push(
|
|
996
|
-
|
|
997
|
-
${subList}`)
|
|
998
|
-
);
|
|
912
|
+
messages.push(createBotTextMsgNode(ctx.bots[0], `${subHeader}
|
|
913
|
+
${subList}`));
|
|
999
914
|
}
|
|
1000
915
|
}
|
|
1001
916
|
for (const groupId of cfg.notifyChannel) {
|
|
@@ -1005,14 +920,12 @@ ${subList}`)
|
|
|
1005
920
|
`Notifications sent for version ${version}. Generating XAML...`
|
|
1006
921
|
);
|
|
1007
922
|
await exportXaml(ctx, cfg, summary, version);
|
|
1008
|
-
ctx.logger("minecraft-notifier").info(
|
|
1009
|
-
`XAML generation completed for version ${version}.`
|
|
1010
|
-
);
|
|
923
|
+
ctx.logger("minecraft-notifier").info(`XAML generation completed for version ${version}.`);
|
|
1011
924
|
return true;
|
|
1012
925
|
}
|
|
1013
926
|
var turndownService = new import_turndown.default({});
|
|
1014
|
-
async function fetchArticleContent(ctx, version
|
|
1015
|
-
const url = generateArticleUrl(version
|
|
927
|
+
async function fetchArticleContent(ctx, version) {
|
|
928
|
+
const url = generateArticleUrl(version);
|
|
1016
929
|
try {
|
|
1017
930
|
const response = await import_axios3.default.get(url, {
|
|
1018
931
|
timeout: 1e4,
|
|
@@ -1043,6 +956,7 @@ async function fetchArticleContent(ctx, version, isSnapshot) {
|
|
|
1043
956
|
}
|
|
1044
957
|
|
|
1045
958
|
// src/version-checker.ts
|
|
959
|
+
var import_axios4 = __toESM(require("axios"), 1);
|
|
1046
960
|
var loadData = async (ctx) => {
|
|
1047
961
|
const record = (await ctx.database.get("minecraft_notifier", 1))[0];
|
|
1048
962
|
if (record) {
|
|
@@ -1080,9 +994,7 @@ var getLatestVersions = async () => {
|
|
|
1080
994
|
} catch (error) {
|
|
1081
995
|
retries++;
|
|
1082
996
|
if (retries <= 3) {
|
|
1083
|
-
await new Promise(
|
|
1084
|
-
(resolve) => setTimeout(resolve, Math.pow(2, retries) * 1e3)
|
|
1085
|
-
);
|
|
997
|
+
await new Promise((resolve) => setTimeout(resolve, Math.pow(2, retries) * 1e3));
|
|
1086
998
|
}
|
|
1087
999
|
}
|
|
1088
1000
|
}
|
|
@@ -1090,19 +1002,13 @@ var getLatestVersions = async () => {
|
|
|
1090
1002
|
var notifyReleaseVersion = async (ctx, cfg, version) => {
|
|
1091
1003
|
const bot = ctx.bots[0];
|
|
1092
1004
|
for (const channel of cfg.notifyChannel) {
|
|
1093
|
-
await bot.sendMessage(
|
|
1094
|
-
channel,
|
|
1095
|
-
`\u{1F4E2} Minecraft \u65B0\u6B63\u5F0F\u7248\u53D1\u5E03\u4E86\uFF1A${version}`
|
|
1096
|
-
);
|
|
1005
|
+
await bot.sendMessage(channel, `\u{1F4E2} Minecraft \u65B0\u6B63\u5F0F\u7248\u53D1\u5E03\u4E86\uFF1A${version}`);
|
|
1097
1006
|
}
|
|
1098
1007
|
};
|
|
1099
1008
|
var notifySnapshotVersion = async (ctx, cfg, version) => {
|
|
1100
1009
|
const bot = ctx.bots[0];
|
|
1101
1010
|
for (const channel of cfg.notifyChannel) {
|
|
1102
|
-
await bot.sendMessage(
|
|
1103
|
-
channel,
|
|
1104
|
-
`\u{1F389} Minecraft \u65B0\u5FEB\u7167\u7248\u53D1\u5E03\u4E86\uFF1A${version}`
|
|
1105
|
-
);
|
|
1011
|
+
await bot.sendMessage(channel, `\u{1F389} Minecraft \u65B0\u5FEB\u7167\u7248\u53D1\u5E03\u4E86\uFF1A${version}`);
|
|
1106
1012
|
}
|
|
1107
1013
|
};
|
|
1108
1014
|
var checkMinecraftVersion = async (ctx, cfg) => {
|
|
@@ -1114,21 +1020,22 @@ var checkMinecraftVersion = async (ctx, cfg) => {
|
|
|
1114
1020
|
await notifyReleaseVersion(ctx, cfg, latest.release);
|
|
1115
1021
|
updatedData.lastRelease = latest.release;
|
|
1116
1022
|
}
|
|
1117
|
-
if (versionData.lastSnapshot !== latest.snapshot &&
|
|
1023
|
+
if (versionData.lastSnapshot !== latest.snapshot && latest.release != latest.snapshot) {
|
|
1118
1024
|
await notifySnapshotVersion(ctx, cfg, latest.snapshot);
|
|
1119
1025
|
updatedData.lastSnapshot = latest.snapshot;
|
|
1120
1026
|
}
|
|
1121
1027
|
await saveData(ctx, updatedData);
|
|
1122
1028
|
await checkNewVersionArticle(ctx, cfg);
|
|
1123
1029
|
} catch (error) {
|
|
1124
|
-
ctx.logger("minecraft-notifier").error(
|
|
1125
|
-
"Error checking Minecraft versions:",
|
|
1126
|
-
error
|
|
1127
|
-
);
|
|
1030
|
+
ctx.logger("minecraft-notifier").error("Error checking Minecraft versions:", error);
|
|
1128
1031
|
}
|
|
1129
1032
|
};
|
|
1130
1033
|
|
|
1131
1034
|
// src/index.ts
|
|
1035
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
1036
|
+
var import_koishi = require("koishi");
|
|
1037
|
+
var import_node_fs2 = require("node:fs");
|
|
1038
|
+
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
1132
1039
|
var name = "minecraft-notifier";
|
|
1133
1040
|
var inject = ["database", "server"];
|
|
1134
1041
|
var Config = import_koishi.Schema.object({
|
|
@@ -1178,21 +1085,13 @@ function apply(ctx, cfg) {
|
|
|
1178
1085
|
},
|
|
1179
1086
|
{ primary: "id" }
|
|
1180
1087
|
);
|
|
1181
|
-
const xamlPath = import_node_path2.default.join(
|
|
1182
|
-
ctx.baseDir,
|
|
1183
|
-
"data",
|
|
1184
|
-
"minecraft-notifier",
|
|
1185
|
-
"xaml"
|
|
1186
|
-
);
|
|
1088
|
+
const xamlPath = import_node_path2.default.join(ctx.baseDir, "data", "minecraft-notifier", "xaml");
|
|
1187
1089
|
if (!import_fs.default.existsSync(xamlPath)) {
|
|
1188
1090
|
import_fs.default.mkdirSync(xamlPath, { recursive: true });
|
|
1189
1091
|
}
|
|
1190
1092
|
ctx.server.get("/Custom.xaml", async (koaCtx) => {
|
|
1191
1093
|
koaCtx.set("Content-Type", "application/xml; charset=utf-8");
|
|
1192
|
-
koaCtx.set(
|
|
1193
|
-
"Content-Disposition",
|
|
1194
|
-
'inline; filename="PCL.HomePage.xaml"'
|
|
1195
|
-
);
|
|
1094
|
+
koaCtx.set("Content-Disposition", 'inline; filename="PCL.HomePage.xaml"');
|
|
1196
1095
|
let fullHomePagePath = import_node_path2.default.join(xamlPath, "PCL.HomePage.xaml");
|
|
1197
1096
|
koaCtx.response.body = await import_node_fs2.promises.readFile(fullHomePagePath);
|
|
1198
1097
|
});
|
|
@@ -1210,25 +1109,20 @@ function apply(ctx, cfg) {
|
|
|
1210
1109
|
ctx.command("mc.trigger", "\u624B\u52A8\u89E6\u53D1\u68C0\u67E5 Minecraft \u7248\u672C\u66F4\u65B0", {
|
|
1211
1110
|
authority: 4
|
|
1212
1111
|
}).action(async () => await checkMinecraftVersion(ctx, cfg));
|
|
1213
|
-
ctx.setInterval(
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
if (!record) {
|
|
1221
|
-
return "\u274C \u5F53\u524D\u6682\u65E0\u5DF2\u8BB0\u5F55\u7684\u7248\u672C\u4FE1\u606F\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002";
|
|
1222
|
-
}
|
|
1223
|
-
return `\u{1F4E2} \u5F53\u524D\u5DF2\u8BB0\u5F55\u7684\u6700\u65B0 Minecraft \u7248\u672C\u4FE1\u606F\uFF1A
|
|
1112
|
+
ctx.setInterval(async () => await checkMinecraftVersion(ctx, cfg), 6e4 * cfg.checkInterval);
|
|
1113
|
+
ctx.command("mc.version", "\u67E5\u8BE2\u5F53\u524D\u5DF2\u8BB0\u5F55\u7684 Minecraft \u7248\u672C\u4FE1\u606F").action(async () => {
|
|
1114
|
+
const record = (await ctx.database.get("minecraft_notifier", 1))[0];
|
|
1115
|
+
if (!record) {
|
|
1116
|
+
return "\u274C \u5F53\u524D\u6682\u65E0\u5DF2\u8BB0\u5F55\u7684\u7248\u672C\u4FE1\u606F\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002";
|
|
1117
|
+
}
|
|
1118
|
+
return `\u{1F4E2} \u5F53\u524D\u5DF2\u8BB0\u5F55\u7684\u6700\u65B0 Minecraft \u7248\u672C\u4FE1\u606F\uFF1A
|
|
1224
1119
|
|
|
1225
1120
|
\u{1F4E2} \u6B63\u5F0F\u7248\uFF1A${record.lastRelease}
|
|
1226
|
-
\u{1F31F} \u6B63\u5F0F\u7248\u66F4\u65B0\u65E5\u5FD7\uFF1A${generateArticleUrl(record.lastRelease
|
|
1121
|
+
\u{1F31F} \u6B63\u5F0F\u7248\u66F4\u65B0\u65E5\u5FD7\uFF1A${generateArticleUrl(record.lastRelease)}
|
|
1227
1122
|
|
|
1228
1123
|
\u{1F389} \u5FEB\u7167\u7248\uFF1A${record.lastSnapshot}
|
|
1229
|
-
\u{1F9EA} \u5FEB\u7167\u7248\u66F4\u65B0\u65E5\u5FD7\uFF1A${generateArticleUrl(record.lastSnapshot
|
|
1230
|
-
|
|
1231
|
-
);
|
|
1124
|
+
\u{1F9EA} \u5FEB\u7167\u7248\u66F4\u65B0\u65E5\u5FD7\uFF1A${generateArticleUrl(record.lastSnapshot)}`;
|
|
1125
|
+
});
|
|
1232
1126
|
}
|
|
1233
1127
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1234
1128
|
0 && (module.exports = {
|
package/lib/prompt-const.d.ts
CHANGED
package/lib/version-checker.d.ts
CHANGED
package/lib/xaml-generator.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-minecraft-notifier",
|
|
3
3
|
"description": "A Minecraft new version notification plugin, also featuring a PCL homepage.",
|
|
4
|
-
"
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/pynickle/koishi-plugin-minecraft-notifier"
|
|
7
|
+
},
|
|
8
|
+
"version": "1.11.0",
|
|
5
9
|
"main": "lib/index.cjs",
|
|
6
10
|
"typings": "lib/index.d.ts",
|
|
7
11
|
"type": "module",
|
|
@@ -30,14 +34,14 @@
|
|
|
30
34
|
"@semantic-release/changelog": "^6.0.3",
|
|
31
35
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
32
36
|
"@semantic-release/git": "^10.0.1",
|
|
33
|
-
"@semantic-release/npm": "^13.1.
|
|
37
|
+
"@semantic-release/npm": "^13.1.3",
|
|
34
38
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
35
39
|
"@types/turndown": "^5.0.6",
|
|
36
40
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
37
41
|
"esbuild": "^0.27.1",
|
|
38
42
|
"esbuild-plugin-yaml": "^0.0.1",
|
|
39
|
-
"oxfmt": "^0.
|
|
40
|
-
"oxlint": "^1.
|
|
43
|
+
"oxfmt": "^0.18.0",
|
|
44
|
+
"oxlint": "^1.33.0",
|
|
41
45
|
"semantic-release": "^25.0.2",
|
|
42
46
|
"typescript": "^5.9.3"
|
|
43
47
|
},
|