koishi-plugin-minecraft-notifier 1.9.0 → 1.10.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.
@@ -4,5 +4,4 @@ import { Config } from './index';
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 generateArticleUrl(version: string, isSnapshot: boolean): string;
8
7
  export declare function fetchArticleContent(ctx: Context, version: string, isSnapshot: boolean): Promise<string>;
@@ -0,0 +1 @@
1
+ export declare function generateArticleUrl(version: string, isSnapshot: boolean): string;
package/lib/index.cjs CHANGED
@@ -35,12 +35,39 @@ __export(index_exports, {
35
35
  name: () => name
36
36
  });
37
37
  module.exports = __toCommonJS(index_exports);
38
- var import_axios4 = __toESM(require("axios"), 1);
39
38
  var import_fs = __toESM(require("fs"), 1);
40
39
  var import_koishi = require("koishi");
41
40
  var import_node_fs2 = require("node:fs");
42
41
  var import_node_path2 = __toESM(require("node:path"), 1);
43
42
 
43
+ // src/helper/article-helper.ts
44
+ function generateArticleUrl(version, isSnapshot) {
45
+ const cleanVersion = version.replace(/\s/g, "-").toLowerCase();
46
+ const baseUrl = "https://www.minecraft.net/zh-hans/article";
47
+ if (isSnapshot) {
48
+ return generateSnapshotUrl(baseUrl, version, cleanVersion);
49
+ }
50
+ return `${baseUrl}/minecraft-java-edition-${cleanVersion.replaceAll(".", "-")}`;
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}`;
66
+ }
67
+
68
+ // src/version-checker.ts
69
+ var import_axios4 = __toESM(require("axios"), 1);
70
+
44
71
  // src/changelog-summarizer.ts
45
72
  var import_koishi_plugin_adapter_onebot = require("@pynickle/koishi-plugin-adapter-onebot");
46
73
  var import_autocorrect_node2 = require("autocorrect-node");
@@ -48,7 +75,7 @@ var import_axios3 = __toESM(require("axios"), 1);
48
75
  var cheerio2 = __toESM(require("cheerio"), 1);
49
76
  var import_turndown = __toESM(require("turndown"), 1);
50
77
 
51
- // src/onebot-helper.ts
78
+ // src/helper/onebot-helper.ts
52
79
  function createBotTextMsgNode(bot, content) {
53
80
  return {
54
81
  type: "node",
@@ -60,6 +87,44 @@ function createBotTextMsgNode(bot, content) {
60
87
  };
61
88
  }
62
89
 
90
+ // src/helper/web-helper.ts
91
+ var userAgents = [
92
+ // Chrome 桌面版本
93
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
94
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
95
+ "Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
96
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
97
+ "Mozilla/5.0 (Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
98
+ // Firefox 桌面版本
99
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0",
100
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/121.0",
101
+ "Mozilla/5.0 (X11; Linux i686; rv:109.0) Gecko/20100101 Firefox/121.0",
102
+ "Mozilla/5.0 (X11; Linux x86_64; rv:115.0) Gecko/20100101 Firefox/115.0",
103
+ // Safari 桌面和移动版本
104
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15",
105
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15",
106
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1",
107
+ "Mozilla/5.0 (iPad; CPU OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1",
108
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1",
109
+ // Edge 浏览器
110
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0",
111
+ "Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0",
112
+ // Android 移动设备
113
+ "Mozilla/5.0 (Linux; Android 13; SM-G998B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36",
114
+ "Mozilla/5.0 (Linux; Android 12; SM-A536B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36",
115
+ "Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Mobile Safari/537.36",
116
+ "Mozilla/5.0 (Linux; Android 13; moto g(50) 5G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36",
117
+ // 其他浏览器
118
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0",
119
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0",
120
+ "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
121
+ "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
122
+ ];
123
+ function getRandomUserAgent() {
124
+ const randomIndex = Math.floor(Math.random() * userAgents.length);
125
+ return userAgents[randomIndex];
126
+ }
127
+
63
128
  // src/translation-fetcher.ts
64
129
  var import_axios = __toESM(require("axios"), 1);
65
130
  var cheerio = __toESM(require("cheerio"), 1);
@@ -366,50 +431,12 @@ As the Minecraft Update Log JSON Summary Specialist, you must adhere to the abov
366
431
  `;
367
432
  }
368
433
 
369
- // src/web_helper.ts
370
- var userAgents = [
371
- // Chrome 桌面版本
372
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
373
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
374
- "Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
375
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
376
- "Mozilla/5.0 (Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
377
- // Firefox 桌面版本
378
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0",
379
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/121.0",
380
- "Mozilla/5.0 (X11; Linux i686; rv:109.0) Gecko/20100101 Firefox/121.0",
381
- "Mozilla/5.0 (X11; Linux x86_64; rv:115.0) Gecko/20100101 Firefox/115.0",
382
- // Safari 桌面和移动版本
383
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15",
384
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15",
385
- "Mozilla/5.0 (iPhone; CPU iPhone OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1",
386
- "Mozilla/5.0 (iPad; CPU OS 17_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1",
387
- "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1",
388
- // Edge 浏览器
389
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0",
390
- "Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0",
391
- // Android 移动设备
392
- "Mozilla/5.0 (Linux; Android 13; SM-G998B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36",
393
- "Mozilla/5.0 (Linux; Android 12; SM-A536B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36",
394
- "Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Mobile Safari/537.36",
395
- "Mozilla/5.0 (Linux; Android 13; moto g(50) 5G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36",
396
- // 其他浏览器
397
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0",
398
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0",
399
- "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
400
- "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
401
- ];
402
- function getRandomUserAgent() {
403
- const randomIndex = Math.floor(Math.random() * userAgents.length);
404
- return userAgents[randomIndex];
405
- }
406
-
407
434
  // src/xaml-generator.ts
408
435
  var import_autocorrect_node = require("autocorrect-node");
409
436
  var import_node_fs = require("node:fs");
410
437
  var import_node_path = __toESM(require("node:path"), 1);
411
438
 
412
- // src/git-platform-helper.ts
439
+ // src/helper/git-platform-helper.ts
413
440
  var import_axios2 = __toESM(require("axios"), 1);
414
441
  var PLATFORM_CONFIG = {
415
442
  ["gitee" /* GITEE */]: {
@@ -976,29 +1003,6 @@ ${subList}`)
976
1003
  );
977
1004
  return true;
978
1005
  }
979
- function generateArticleUrl(version, isSnapshot) {
980
- const cleanVersion = version.replace(/\s/g, "-").toLowerCase();
981
- const baseUrl = "https://www.minecraft.net/zh-hans/article";
982
- if (isSnapshot) {
983
- return generateSnapshotUrl(baseUrl, version, cleanVersion);
984
- }
985
- return `${baseUrl}/minecraft-java-edition-${cleanVersion.replaceAll(".", "-")}`;
986
- }
987
- function generateSnapshotUrl(baseUrl, version, cleanVersion) {
988
- if (version.includes("rc")) {
989
- return buildReleaseUrl(baseUrl, version, "release-candidate");
990
- }
991
- if (version.includes("pre")) {
992
- return buildReleaseUrl(baseUrl, version, "pre-release");
993
- }
994
- return `${baseUrl}/minecraft-snapshot-${cleanVersion}`;
995
- }
996
- function buildReleaseUrl(baseUrl, version, releaseType) {
997
- const [mainVersion] = version.split("-");
998
- const buildNumber = version.slice(-1);
999
- const formattedVersion = mainVersion.replaceAll(".", "-");
1000
- return `${baseUrl}/minecraft-${formattedVersion}-${releaseType}-${buildNumber}`;
1001
- }
1002
1006
  var turndownService = new import_turndown.default({});
1003
1007
  async function fetchArticleContent(ctx, version, isSnapshot) {
1004
1008
  const url = generateArticleUrl(version, isSnapshot);
@@ -1009,10 +1013,15 @@ async function fetchArticleContent(ctx, version, isSnapshot) {
1009
1013
  "User-Agent": getRandomUserAgent()
1010
1014
  }
1011
1015
  });
1012
- const html = response.data;
1013
- const $ = cheerio2.load(html);
1014
- const content = $("div.article-text").html().trim();
1015
- return turndownService.turndown(content.trim());
1016
+ if (response.status === 200) {
1017
+ const html = response.data;
1018
+ const $ = cheerio2.load(html);
1019
+ const content = $("div.article-text").html().trim();
1020
+ return turndownService.turndown(content.trim());
1021
+ }
1022
+ ctx.logger("minecraft-notifier").warn(
1023
+ `Wrong response status (${response.status}) when fetching article: ${url}`
1024
+ );
1016
1025
  } catch (error) {
1017
1026
  if (error.response && error.response.status === 404) {
1018
1027
  ctx.logger("minecraft-notifier").warn(`Article not found: ${url}`);
@@ -1026,6 +1035,92 @@ async function fetchArticleContent(ctx, version, isSnapshot) {
1026
1035
  }
1027
1036
  }
1028
1037
 
1038
+ // src/version-checker.ts
1039
+ var loadData = async (ctx) => {
1040
+ const record = (await ctx.database.get("minecraft_notifier", 1))[0];
1041
+ if (record) {
1042
+ return {
1043
+ lastRelease: record.lastRelease,
1044
+ lastSnapshot: record.lastSnapshot
1045
+ };
1046
+ }
1047
+ return { lastRelease: "", lastSnapshot: "" };
1048
+ };
1049
+ var saveData = async (ctx, data) => {
1050
+ await ctx.database.upsert("minecraft_notifier", [
1051
+ {
1052
+ id: 1,
1053
+ lastRelease: data.lastRelease,
1054
+ lastSnapshot: data.lastSnapshot
1055
+ }
1056
+ ]);
1057
+ };
1058
+ var getLatestVersions = async () => {
1059
+ let retries = 0;
1060
+ while (retries <= 3) {
1061
+ try {
1062
+ const response = await import_axios4.default.get(
1063
+ "https://launchermeta.mojang.com/mc/game/version_manifest.json",
1064
+ {
1065
+ timeout: 1e4
1066
+ }
1067
+ );
1068
+ const data = response.data;
1069
+ return {
1070
+ release: data.latest.release,
1071
+ snapshot: data.latest.snapshot
1072
+ };
1073
+ } catch (error) {
1074
+ retries++;
1075
+ if (retries <= 3) {
1076
+ await new Promise(
1077
+ (resolve) => setTimeout(resolve, Math.pow(2, retries) * 1e3)
1078
+ );
1079
+ }
1080
+ }
1081
+ }
1082
+ };
1083
+ var notifyReleaseVersion = async (ctx, cfg, version) => {
1084
+ const bot = ctx.bots[0];
1085
+ for (const channel of cfg.notifyChannel) {
1086
+ await bot.sendMessage(
1087
+ channel,
1088
+ `\u{1F4E2} Minecraft \u65B0\u6B63\u5F0F\u7248\u53D1\u5E03\u4E86\uFF1A${version}`
1089
+ );
1090
+ }
1091
+ };
1092
+ var notifySnapshotVersion = async (ctx, cfg, version) => {
1093
+ const bot = ctx.bots[0];
1094
+ for (const channel of cfg.notifyChannel) {
1095
+ await bot.sendMessage(
1096
+ channel,
1097
+ `\u{1F389} Minecraft \u65B0\u5FEB\u7167\u7248\u53D1\u5E03\u4E86\uFF1A${version}`
1098
+ );
1099
+ }
1100
+ };
1101
+ var checkMinecraftVersion = async (ctx, cfg) => {
1102
+ try {
1103
+ const versionData = await loadData(ctx);
1104
+ const latest = await getLatestVersions();
1105
+ let updatedData = { ...versionData };
1106
+ if (versionData.lastRelease !== latest.release) {
1107
+ await notifyReleaseVersion(ctx, cfg, latest.release);
1108
+ updatedData.lastRelease = latest.release;
1109
+ }
1110
+ if (versionData.lastSnapshot !== latest.snapshot && versionData.lastRelease != latest.snapshot) {
1111
+ await notifySnapshotVersion(ctx, cfg, latest.snapshot);
1112
+ updatedData.lastSnapshot = latest.snapshot;
1113
+ }
1114
+ await saveData(ctx, updatedData);
1115
+ await checkNewVersionArticle(ctx, cfg);
1116
+ } catch (error) {
1117
+ ctx.logger("minecraft-notifier").error(
1118
+ "Error checking Minecraft versions:",
1119
+ error
1120
+ );
1121
+ }
1122
+ };
1123
+
1029
1124
  // src/index.ts
1030
1125
  var name = "minecraft-notifier";
1031
1126
  var inject = ["database", "server"];
@@ -1076,45 +1171,6 @@ function apply(ctx, cfg) {
1076
1171
  },
1077
1172
  { primary: "id" }
1078
1173
  );
1079
- let lastRelease = "";
1080
- let lastSnapshot = "";
1081
- const loadData = async () => {
1082
- const record = (await ctx.database.get("minecraft_notifier", 1))[0];
1083
- if (record) {
1084
- lastRelease = record.lastRelease;
1085
- lastSnapshot = record.lastSnapshot;
1086
- }
1087
- };
1088
- const saveData = async () => {
1089
- await ctx.database.upsert("minecraft_notifier", [
1090
- { id: 1, lastRelease, lastSnapshot }
1091
- ]);
1092
- };
1093
- const getLatestVersions = async () => {
1094
- let retries = 0;
1095
- while (retries <= 3) {
1096
- try {
1097
- const response = await import_axios4.default.get(
1098
- "https://launchermeta.mojang.com/mc/game/version_manifest.json",
1099
- {
1100
- timeout: 1e4
1101
- }
1102
- );
1103
- const data = response.data;
1104
- return {
1105
- release: data.latest.release,
1106
- snapshot: data.latest.snapshot
1107
- };
1108
- } catch (error) {
1109
- retries++;
1110
- if (retries <= 3) {
1111
- await new Promise(
1112
- (resolve) => setTimeout(resolve, Math.pow(2, retries) * 1e3)
1113
- );
1114
- }
1115
- }
1116
- }
1117
- };
1118
1174
  const xamlPath = import_node_path2.default.join(
1119
1175
  ctx.baseDir,
1120
1176
  "data",
@@ -1144,43 +1200,28 @@ function apply(ctx, cfg) {
1144
1200
  Title: "Minecraft \u66F4\u65B0\u6458\u8981"
1145
1201
  });
1146
1202
  });
1147
- ctx.command("mc.trigger", "\u624B\u52A8\u89E6\u53D1 AI \u66F4\u65B0\u65E5\u5FD7\u603B\u7ED3\u751F\u6210", {
1203
+ ctx.command("mc.trigger", "\u624B\u52A8\u89E6\u53D1\u68C0\u67E5 Minecraft \u7248\u672C\u66F4\u65B0", {
1148
1204
  authority: 4
1149
- }).action(async () => {
1150
- await checkNewVersionArticle(ctx, cfg);
1151
- });
1152
- ctx.setInterval(async () => {
1153
- try {
1154
- await loadData();
1155
- const latest = await getLatestVersions();
1156
- const bot = ctx.bots[0];
1157
- if (lastRelease !== latest.release) {
1158
- for (const channel of cfg.notifyChannel) {
1159
- await bot.sendMessage(
1160
- channel,
1161
- `Minecraft \u65B0\u6B63\u5F0F\u7248\u53D1\u5E03\u4E86\uFF1A${latest.release}`
1162
- );
1163
- }
1164
- lastRelease = latest.release;
1165
- }
1166
- if (lastSnapshot !== latest.snapshot && lastRelease != latest.snapshot) {
1167
- for (const channel of cfg.notifyChannel) {
1168
- await bot.sendMessage(
1169
- channel,
1170
- `Minecraft \u65B0\u5FEB\u7167\u7248\u53D1\u5E03\u4E86\uFF1A${latest.snapshot}`
1171
- );
1172
- }
1173
- lastSnapshot = latest.snapshot;
1205
+ }).action(async () => await checkMinecraftVersion(ctx, cfg));
1206
+ ctx.setInterval(
1207
+ async () => await checkMinecraftVersion(ctx, cfg),
1208
+ 6e4 * cfg.checkInterval
1209
+ );
1210
+ ctx.command("mc.version", "\u67E5\u8BE2\u5F53\u524D\u5DF2\u8BB0\u5F55\u7684 Minecraft \u7248\u672C\u4FE1\u606F").action(
1211
+ async () => {
1212
+ const record = (await ctx.database.get("minecraft_notifier", 1))[0];
1213
+ if (!record) {
1214
+ return "\u274C \u5F53\u524D\u6682\u65E0\u5DF2\u8BB0\u5F55\u7684\u7248\u672C\u4FE1\u606F\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002";
1174
1215
  }
1175
- await saveData();
1176
- await checkNewVersionArticle(ctx, cfg);
1177
- } catch (error) {
1178
- ctx.logger("minecraft-notifier").error(
1179
- "\u68C0\u67E5 Minecraft \u7248\u672C\u65F6\u51FA\u9519\uFF1A",
1180
- error
1181
- );
1216
+ return `\u{1F4E2} \u5F53\u524D\u5DF2\u8BB0\u5F55\u7684\u6700\u65B0 Minecraft \u7248\u672C\u4FE1\u606F\uFF1A
1217
+
1218
+ \u{1F4E2} \u6B63\u5F0F\u7248\uFF1A${record.lastRelease}
1219
+ \u{1F31F} \u6B63\u5F0F\u7248\u66F4\u65B0\u65E5\u5FD7\uFF1A${generateArticleUrl(record.lastRelease, false)}
1220
+
1221
+ \u{1F389} \u5FEB\u7167\u7248\uFF1A${record.lastSnapshot}
1222
+ \u{1F9EA} \u5FEB\u7167\u7248\u66F4\u65B0\u65E5\u5FD7\uFF1A${generateArticleUrl(record.lastSnapshot, true)}`;
1182
1223
  }
1183
- }, 6e4 * cfg.checkInterval);
1224
+ );
1184
1225
  }
1185
1226
  // Annotate the CommonJS export names for ESM import in node:
1186
1227
  0 && (module.exports = {
package/lib/index.d.ts CHANGED
@@ -43,6 +43,4 @@ export interface Config {
43
43
  gitcodeRepo?: string;
44
44
  }
45
45
  export declare const Config: Schema<Config>;
46
- export declare function apply(ctx: Context, cfg: Config & {
47
- articleTracker: any;
48
- }): void;
46
+ export declare function apply(ctx: Context, cfg: Config): void;
@@ -0,0 +1,3 @@
1
+ import { Context } from 'koishi';
2
+ import { Config } from './index';
3
+ export declare const checkMinecraftVersion: (ctx: Context, cfg: Config) => Promise<void>;
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.9.0",
4
+ "version": "1.10.0",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",
File without changes