koishi-plugin-minecraft-notifier 1.7.0 → 1.8.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.cjs CHANGED
@@ -815,113 +815,112 @@ Input:
815
815
  ${updateContent}
816
816
  `;
817
817
  let response;
818
- try {
819
- response = await import_axios3.default.post(
820
- url,
818
+ const requestData = {
819
+ model: cfg.model,
820
+ temperature: 0.8,
821
+ messages: [
821
822
  {
822
- model: cfg.model,
823
- temperature: 0.8,
824
- tools: [{ type: "web_search_preview" }],
825
- messages: [
826
- {
827
- role: "system",
828
- content: await getSustemPrompt(
829
- ctx,
830
- cfg,
831
- updateContent.toLowerCase()
832
- )
823
+ role: "system",
824
+ content: await getSustemPrompt(
825
+ ctx,
826
+ cfg,
827
+ updateContent.toLowerCase()
828
+ )
829
+ },
830
+ {
831
+ role: "user",
832
+ content: userPrompt
833
+ }
834
+ ],
835
+ response_format: {
836
+ type: "json_schema",
837
+ json_schema: {
838
+ name: "minecraft_update_summary",
839
+ strict: true,
840
+ schema: {
841
+ type: "object",
842
+ properties: {
843
+ new_features: {
844
+ $ref: "#/definitions/categoryGroup"
845
+ },
846
+ improvements: {
847
+ $ref: "#/definitions/categoryGroup"
848
+ },
849
+ balancing: {
850
+ $ref: "#/definitions/categoryGroup"
851
+ },
852
+ bug_fixes: {
853
+ $ref: "#/definitions/categoryGroup"
854
+ },
855
+ technical_changes: {
856
+ $ref: "#/definitions/categoryGroup"
857
+ }
833
858
  },
834
- {
835
- role: "user",
836
- content: userPrompt
837
- }
838
- ],
839
- web_search: true,
840
- response_format: {
841
- type: "json_schema",
842
- json_schema: {
843
- name: "minecraft_update_summary",
844
- strict: true,
845
- schema: {
859
+ required: [
860
+ "new_features",
861
+ "improvements",
862
+ "balancing",
863
+ "bug_fixes",
864
+ "technical_changes"
865
+ ],
866
+ additionalProperties: false,
867
+ definitions: {
868
+ categoryGroup: {
846
869
  type: "object",
847
870
  properties: {
848
- new_features: {
849
- $ref: "#/definitions/categoryGroup"
871
+ general: {
872
+ type: "array",
873
+ description: "\u5C5E\u4E8E\u8BE5\u5927\u7C7B\u4F46\u672A\u7EC6\u5206\u7684\u5C0F\u9879",
874
+ items: { type: "string" }
850
875
  },
851
- improvements: {
852
- $ref: "#/definitions/categoryGroup"
853
- },
854
- balancing: {
855
- $ref: "#/definitions/categoryGroup"
856
- },
857
- bug_fixes: {
858
- $ref: "#/definitions/categoryGroup"
859
- },
860
- technical_changes: {
861
- $ref: "#/definitions/categoryGroup"
862
- }
863
- },
864
- required: [
865
- "new_features",
866
- "improvements",
867
- "balancing",
868
- "bug_fixes",
869
- "technical_changes"
870
- ],
871
- additionalProperties: false,
872
- definitions: {
873
- categoryGroup: {
874
- type: "object",
875
- properties: {
876
- general: {
877
- type: "array",
878
- description: "\u5C5E\u4E8E\u8BE5\u5927\u7C7B\u4F46\u672A\u7EC6\u5206\u7684\u5C0F\u9879",
879
- items: { type: "string" }
880
- },
881
- subcategories: {
882
- type: "array",
883
- description: "\u8BE5\u5927\u7C7B\u4E0B\u7684\u7EC6\u5206\u7C7B\uFF08\u5E26 emoji\uFF09",
876
+ subcategories: {
877
+ type: "array",
878
+ description: "\u8BE5\u5927\u7C7B\u4E0B\u7684\u7EC6\u5206\u7C7B\uFF08\u5E26 emoji\uFF09",
879
+ items: {
880
+ type: "object",
881
+ properties: {
882
+ subcategory: {
883
+ type: "string"
884
+ },
885
+ emoji: {
886
+ type: "string",
887
+ description: "\u5C0F\u7C7B\u524D\u7684 emoji \u56FE\u6807"
888
+ },
884
889
  items: {
885
- type: "object",
886
- properties: {
887
- subcategory: {
888
- type: "string"
889
- },
890
- emoji: {
891
- type: "string",
892
- description: "\u5C0F\u7C7B\u524D\u7684 emoji \u56FE\u6807"
893
- },
894
- items: {
895
- type: "array",
896
- items: {
897
- type: "string"
898
- }
899
- }
900
- },
901
- required: [
902
- "subcategory",
903
- "emoji",
904
- "items"
905
- ],
906
- additionalProperties: false
890
+ type: "array",
891
+ items: {
892
+ type: "string"
893
+ }
907
894
  }
908
- }
909
- },
910
- required: ["general", "subcategories"],
911
- additionalProperties: false
895
+ },
896
+ required: [
897
+ "subcategory",
898
+ "emoji",
899
+ "items"
900
+ ],
901
+ additionalProperties: false
902
+ }
912
903
  }
913
- }
904
+ },
905
+ required: ["general", "subcategories"],
906
+ additionalProperties: false
914
907
  }
915
908
  }
916
909
  }
917
- },
918
- {
919
- headers: {
920
- "Content-Type": "application/json",
921
- Authorization: `Bearer ${cfg.apiKey}`
922
- }
923
910
  }
924
- );
911
+ }
912
+ };
913
+ if (cfg.enableWebSearch) {
914
+ requestData["web_search"] = true;
915
+ requestData["tools"] = [{ type: "web_search_preview" }];
916
+ }
917
+ try {
918
+ response = await import_axios3.default.post(url, requestData, {
919
+ headers: {
920
+ "Content-Type": "application/json",
921
+ Authorization: `Bearer ${cfg.apiKey}`
922
+ }
923
+ });
925
924
  } catch (e) {
926
925
  ctx.logger("minecraft-notifier").error(
927
926
  "Summarization API error:",
@@ -1034,6 +1033,7 @@ var Config = import_koishi.Schema.object({
1034
1033
  checkInterval: import_koishi.Schema.number().default(3).description("\u5728\u7EBF\u72B6\u6001\u68C0\u67E5\u95F4\u9694\uFF08\u5206\u949F\uFF09"),
1035
1034
  baseApiUrl: import_koishi.Schema.string().default("https://api.openai.com/v1").description("AI \u63A5\u53E3\u7684\u57FA\u7840 URL"),
1036
1035
  model: import_koishi.Schema.string().default("gpt-5").description("\u4F7F\u7528\u7684 AI \u6A21\u578B"),
1036
+ enableWebSearch: import_koishi.Schema.boolean().default(true).description("\u662F\u5426\u542F\u7528\u7F51\u7EDC\u641C\u7D22\u529F\u80FD"),
1037
1037
  apiKey: import_koishi.Schema.string().role("secret").default("").description("AI \u63A5\u53E3\u7684 API \u5BC6\u94A5").required(),
1038
1038
  notifyChannel: import_koishi.Schema.array(String).default([]).description("\u7528\u4E8E\u63A5\u6536\u66F4\u65B0\u901A\u77E5\u7684\u9891\u9053 ID \u5217\u8868"),
1039
1039
  giteeApiToken: import_koishi.Schema.string().role("secret").default("").description("Gitee API \u8BBF\u95EE\u4EE4\u724C\uFF0C\u7528\u4E8E\u4E0A\u4F20 XAML \u6587\u4EF6"),
@@ -1138,16 +1138,11 @@ function apply(ctx, cfg) {
1138
1138
  const articleRecord = (await ctx.database.get("minecraft_article_version", 1))[0];
1139
1139
  koaCtx.response.body = articleRecord.latestVersion;
1140
1140
  });
1141
- ctx.command("mc.trigger", "\u624B\u52A8\u89E6\u53D1 AI \u66F4\u65B0\u65E5\u5FD7\u603B\u7ED3\u751F\u6210").action(
1142
- async () => {
1143
- await checkNewVersionArticle(ctx, cfg);
1144
- }
1145
- );
1146
- ctx.command("mc.trigger.gitcode", "\u624B\u52A8\u89E6\u53D1 AI \u66F4\u65B0\u65E5\u5FD7\u603B\u7ED3\u751F\u6210").action(
1147
- async () => {
1148
- return await getSustemPrompt(ctx, cfg, "jab attack");
1149
- }
1150
- );
1141
+ ctx.command("mc.trigger", "\u624B\u52A8\u89E6\u53D1 AI \u66F4\u65B0\u65E5\u5FD7\u603B\u7ED3\u751F\u6210", {
1142
+ authority: 4
1143
+ }).action(async () => {
1144
+ await checkNewVersionArticle(ctx, cfg);
1145
+ });
1151
1146
  ctx.setInterval(async () => {
1152
1147
  try {
1153
1148
  await loadData();
package/lib/index.d.ts CHANGED
@@ -32,6 +32,7 @@ export interface Config {
32
32
  checkInterval: number;
33
33
  baseApiUrl: string;
34
34
  model: string;
35
+ enableWebSearch: boolean;
35
36
  apiKey: string;
36
37
  notifyChannel: string[];
37
38
  giteeApiToken?: string;
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.7.0",
4
+ "version": "1.8.0",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",