koishi-plugin-ggcevo 1.1.13 → 1.1.15

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.d.ts CHANGED
@@ -21,6 +21,7 @@ export interface Config {
21
21
  handleInactiveUnbindDays: number;
22
22
  /** 活动兑换管理员名字, 填写后兑换成功及兑换列表会提示向该管理员登记; 不填则不提醒 */
23
23
  exchangeAdminName: string;
24
+ debugEnabled: boolean;
24
25
  }
25
26
  export declare const Config: Schema<Config>;
26
27
  export declare const inject: {
package/lib/index.js CHANGED
@@ -60,11 +60,14 @@ var Config = import_koishi.Schema.intersect([
60
60
  import_koishi.Schema.object({
61
61
  handleInactiveUnbindEnabled: import_koishi.Schema.boolean().description("是否启用句柄长时间未使用自动解绑").default(false),
62
62
  handleInactiveUnbindDays: import_koishi.Schema.number().description("句柄超过该天数未使用将自动解绑(仅对非当前使用的句柄生效)").default(90).min(1)
63
- }).description("句柄自动解绑")
63
+ }).description("句柄自动解绑"),
64
+ import_koishi.Schema.object({
65
+ debugEnabled: import_koishi.Schema.boolean().description("是否启用调试模式(启用后, ggcevo 所有指令的触发/参数/执行结果/错误信息会输出到 Koishi 日志)").default(false)
66
+ }).description("调试模式")
64
67
  ]);
65
68
  var inject = {
66
69
  required: ["database"],
67
- optional: ["puppeteer"]
70
+ optional: ["puppeteer", "assets"]
68
71
  };
69
72
  var ItemConfig = {
70
73
  1: "金币",
@@ -105,6 +108,25 @@ var ExchangeConfig = {
105
108
  23: { name: "赎罪券", quality: "t0", type: "道具", cost: 2 }
106
109
  };
107
110
  function apply(ctx, config) {
111
+ const debug = /* @__PURE__ */ __name((...args) => {
112
+ if (config.debugEnabled) {
113
+ ctx.logger.info("[ggcevo:debug]", ...args);
114
+ }
115
+ }, "debug");
116
+ const isGgcEvoCommand = /* @__PURE__ */ __name((name2) => name2 === "ggcevo" || name2.startsWith("ggcevo/"), "isGgcEvoCommand");
117
+ if (config.debugEnabled) {
118
+ ctx.on("command/before-execute", (argv) => {
119
+ const { command, session, args, options } = argv;
120
+ if (!isGgcEvoCommand(command.name)) return;
121
+ const optionStr = Object.keys(options).length ? ` | 选项: ${JSON.stringify(options)}` : "";
122
+ debug(`指令触发: ${command.name} | 用户: ${session.userId} | 平台: ${session.platform} | 参数: ${JSON.stringify(args)}${optionStr}`);
123
+ });
124
+ ctx.on("command-error", (argv, error) => {
125
+ const { command, session } = argv;
126
+ if (!isGgcEvoCommand(command.name)) return;
127
+ debug(`指令出错: ${command.name} | 用户: ${session.userId} | 错误: ${error?.message ?? error}`);
128
+ });
129
+ }
108
130
  ctx.model.extend("sc2arcade_player", {
109
131
  id: "unsigned",
110
132
  userId: "string",
@@ -976,6 +998,18 @@ ${rewardLines.join("\n")}` : "";
976
998
  await page.setViewport({ width: 640, height: 800, deviceScaleFactor: 1 });
977
999
  await page.setContent(html, { waitUntil: "networkidle0" });
978
1000
  const img = await page.screenshot({ type: "jpeg", quality: 85, fullPage: true });
1001
+ if (ctx.assets) {
1002
+ try {
1003
+ const dataUrl = `data:image/jpeg;base64,${img.toString("base64")}`;
1004
+ const transformed = await ctx.assets.transform(String(import_koishi.h.image(dataUrl, { file: "ggcevo-menu.jpg" })));
1005
+ const url = import_koishi.h.parse(transformed)[0]?.attrs.src;
1006
+ if (typeof url === "string" && url) {
1007
+ return import_koishi.h.image(url);
1008
+ }
1009
+ } catch (e) {
1010
+ ctx.logger.warn(`菜单图 assets 上传失败,回退为直接发送: ${e}`);
1011
+ }
1012
+ }
979
1013
  return import_koishi.h.image(img, "image/jpeg");
980
1014
  } finally {
981
1015
  await page.close();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ggcevo",
3
3
  "description": "GGCEVO 综合插件:星际争霸2游戏句柄绑定 + 签到/抽奖/兑换/背包/活动系统等虚拟物品玩法",
4
- "version": "1.1.13",
4
+ "version": "1.1.15",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -26,14 +26,16 @@
26
26
  "database"
27
27
  ],
28
28
  "optional": [
29
- "puppeteer"
29
+ "puppeteer",
30
+ "assets"
30
31
  ]
31
32
  }
32
33
  },
33
34
  "peerDependencies": {
34
35
  "koishi": "^4.18.7",
35
36
  "koishi-plugin-puppeteer": "^3.9.0",
36
- "@shangxueink/puppeteer-without-canvas": "^3.0.7"
37
+ "@shangxueink/puppeteer-without-canvas": "^3.0.7",
38
+ "koishi-plugin-assets-qqbot-part-file": "^0.1.2"
37
39
  },
38
40
  "peerDependenciesMeta": {
39
41
  "koishi-plugin-puppeteer": {
@@ -41,6 +43,9 @@
41
43
  },
42
44
  "@shangxueink/puppeteer-without-canvas": {
43
45
  "optional": true
46
+ },
47
+ "koishi-plugin-assets-qqbot-part-file": {
48
+ "optional": true
44
49
  }
45
50
  }
46
51
  }
package/readme.md CHANGED
@@ -174,6 +174,15 @@ npm install koishi-plugin-ggcevo
174
174
 
175
175
  ## 更新日志
176
176
 
177
+ ### v1.1.15
178
+
179
+ - **新增调试模式**:新增配置项 `debugEnabled`(默认关闭)。启用后,ggcevo 所有指令的触发(命令名、用户、平台、参数、选项)与出错(命令名、用户、错误信息)信息会输出到 Koishi 日志,便于排查问题
180
+
181
+ ### v1.1.14
182
+
183
+ - **支持 assets 服务发送菜单图**:`咕咕之战`/`菜单` 渲染后若存在 `assets` 服务(如 `koishi-plugin-assets-qqbot-part-file`,通过 QQ 官方 `upload_prepare` 分片上传获取公网 URL),则优先转公网 URL 发送,避免 QQ 官方机器人直接发 Buffer 时受素材上传限制;未配置或上传失败时自动回退为直接发送。仅在启用该 assets 插件时生效,其他环境行为不变
184
+ - **声明可选依赖**:`koishi-plugin-assets-qqbot-part-file`(^0.1.2)作为可选 peer 依赖
185
+
177
186
  ### v1.1.13
178
187
 
179
188
  - **指令菜单图标改为中文单字徽章**:`咕咕之战`/`菜单` 的图标由 emoji 改为彩色圆角徽章+白色单字(签/抽/换/包/信/兑/活/领/补/用/挖/探、绑/句/切/查/解/图/封),避免服务器缺少 emoji 字体时图标渲染为问号,任何环境下均可正常显示