koishi-plugin-starfx-bot 0.26.6 → 0.26.8

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.js CHANGED
@@ -63,7 +63,7 @@ var package_default = {
63
63
  contributors: [
64
64
  "StarFreedomX <starfreedomx@outlook.com>"
65
65
  ],
66
- version: "0.26.5",
66
+ version: "0.26.7",
67
67
  main: "lib/index.js",
68
68
  typings: "lib/index.d.ts",
69
69
  files: [
@@ -99,7 +99,7 @@ var package_default = {
99
99
  koishi: "^4.18.7"
100
100
  },
101
101
  dependencies: {
102
- axios: "^1.9.0",
102
+ axios: "^1.15.0",
103
103
  "chart.js": "^4.5.1",
104
104
  "chartjs-adapter-dayjs-3": "^1.2.3",
105
105
  cheerio: "^1.0.0",
@@ -630,7 +630,7 @@ async function getImageSrc(session, param, option) {
630
630
  __name(getImageSrc, "getImageSrc");
631
631
  async function getImageFromUrl(ctx, url) {
632
632
  if (!url) throw new Error("URL must be provided");
633
- const sharp = ctx.QhzySharp.Sharp;
633
+ const sharp = getSharpConstructor(ctx);
634
634
  try {
635
635
  let input;
636
636
  if (/^https?:\/\//i.test(url)) {
@@ -856,6 +856,16 @@ function ready(session, cfg, param, readyMap) {
856
856
  return returnMessage;
857
857
  }
858
858
  __name(ready, "ready");
859
+ function getSharpConstructor(ctx) {
860
+ const raw = ctx.QhzySharp?.Sharp;
861
+ if (!raw) throw new Error("Sharp Service 尚未就绪");
862
+ const sharpConstructor = typeof raw === "function" ? raw : raw.default;
863
+ if (typeof sharpConstructor !== "function") {
864
+ throw new Error("无法获取 Sharp 构造函数,请尝试重启 Koishi 或检查 w-node 状态");
865
+ }
866
+ return sharpConstructor;
867
+ }
868
+ __name(getSharpConstructor, "getSharpConstructor");
859
869
 
860
870
  // src/plugins/drawHead.ts
861
871
  async function handleBanGDreamConfig(options) {
@@ -997,7 +1007,7 @@ async function drawLock(ctx, baseImage) {
997
1007
  console.error(error.message);
998
1008
  }
999
1009
  }
1000
- const sharp = ctx.QhzySharp.Sharp;
1010
+ const sharp = getSharpConstructor(ctx);
1001
1011
  const imageMetadata = await image.metadata();
1002
1012
  const lockUrl = `${baseDir}/data/starfx-bot/assets/lock.png`;
1003
1013
  const size1 = Math.min(imageMetadata.width, imageMetadata.height);
@@ -1021,7 +1031,7 @@ async function drawSold(ctx, baseImage) {
1021
1031
  console.error(error.message);
1022
1032
  }
1023
1033
  }
1024
- const sharp = ctx.QhzySharp.Sharp;
1034
+ const sharp = getSharpConstructor(ctx);
1025
1035
  const imageMetadata = await image.metadata();
1026
1036
  const size1 = Math.min(imageMetadata.width, imageMetadata.height);
1027
1037
  image.resize({ width: size1, height: size1, fit: "cover" });
@@ -1082,7 +1092,7 @@ async function drawBanGDream(ctx, avatar, inputOptions) {
1082
1092
  import_node_path3.default.join(assetsDir, "bangborder", `${options.border}.png`)
1083
1093
  )
1084
1094
  ]);
1085
- const sharp = ctx.QhzySharp.Sharp;
1095
+ const sharp = getSharpConstructor(ctx);
1086
1096
  let image = avatarSharp.resize(500 * zoom, 500 * zoom, { fit: "cover" });
1087
1097
  const borderImage = await sharp(borderBuffer).resize(500 * zoom, 500 * zoom, { fit: "cover" }).toBuffer();
1088
1098
  const colorImage = await sharp(colorBuffer).resize(130 * zoom, 130 * zoom, { fit: "cover" }).toBuffer();
package/lib/utils.d.ts CHANGED
@@ -108,4 +108,8 @@ export declare function safeQuote(str: string, useQuote: boolean): string;
108
108
  export declare function writeMap<K, V>(map: Map<K, V>, dest: string): void;
109
109
  export declare function readMap<K, V>(url: string): Map<K, V>;
110
110
  export declare function ready(session: Session, cfg: Config, param: string, readyMap: Map<string, string[]>): string;
111
+ /**
112
+ * 安全地从上下文中获取 Sharp 构造函数
113
+ */
114
+ export declare function getSharpConstructor(ctx: Context): any;
111
115
  export {};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "contributors": [
5
5
  "StarFreedomX <starfreedomx@outlook.com>"
6
6
  ],
7
- "version": "0.26.6",
7
+ "version": "0.26.8",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
10
10
  "files": [
@@ -40,7 +40,7 @@
40
40
  "koishi": "^4.18.7"
41
41
  },
42
42
  "dependencies": {
43
- "axios": "^1.9.0",
43
+ "axios": "^1.15.0",
44
44
  "chart.js": "^4.5.1",
45
45
  "chartjs-adapter-dayjs-3": "^1.2.3",
46
46
  "cheerio": "^1.0.0",
package/readme.md CHANGED
@@ -127,3 +127,5 @@ StarFreedomX机器人的小功能,自用
127
127
  | `0.24.2` | 修复检测逻辑 |
128
128
  | `0.25.0` | 优化功能控制模块 |
129
129
  | `0.25.1` | 修正功能控制模块功能名相关bug |
130
+ | `0.26.6` | 修正roll扔骰子的判断错误 |
131
+ | `0.26.8` | 修复sharp库传回参数改为对象的错误 |