koishi-plugin-w-ygo 0.0.3 → 0.0.4

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/apis.d.ts CHANGED
@@ -93,7 +93,7 @@ export declare namespace API {
93
93
  deckTypes: string[];
94
94
  };
95
95
  type MdmCards = MdmCard[];
96
- const momobako: (query: {
96
+ const cardImage: (template: string, query: {
97
97
  id: number;
98
98
  }) => string;
99
99
  }
package/lib/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export interface Config {
4
4
  retry: number;
5
5
  mdmDefault: boolean;
6
6
  showExpiredPacks: boolean;
7
+ cardImageUrl: string;
7
8
  }
8
9
  export declare const Config: Schema<Config>;
9
10
  export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -43,7 +43,7 @@ var API;
43
43
  return "禁止";
44
44
  }
45
45
  }, "showMdmBanStatus");
46
- API2.momobako = /* @__PURE__ */ __name((query) => `https://cdn.233.momobako.com/ygopro/pics/${query.id}.jpg`, "momobako");
46
+ API2.cardImage = /* @__PURE__ */ __name((template, query) => template.replaceAll("{id}", String(query.id)), "cardImage");
47
47
  })(API || (API = {}));
48
48
 
49
49
  // src/index.tsx
@@ -52,7 +52,8 @@ var name = "w-ygo";
52
52
  var Config = import_koishi.Schema.object({
53
53
  retry: import_koishi.Schema.number().default(3).description("API 请求失败时的重试次数"),
54
54
  mdmDefault: import_koishi.Schema.boolean().default(false).description("是否默认启用 Master Duel Meta 信息"),
55
- showExpiredPacks: import_koishi.Schema.boolean().default(false).description("是否显示过期的 MD 卡包")
55
+ showExpiredPacks: import_koishi.Schema.boolean().default(false).description("是否显示过期的 MD 卡包"),
56
+ cardImageUrl: import_koishi.Schema.string().default("https://cdn.233.momobako.com/ygoimg/sc/{id}.webp").description("卡图 URL 模板,使用 {id} 表示卡片密码")
56
57
  });
57
58
  function apply(ctx, config) {
58
59
  const get = /* @__PURE__ */ __name(async (url, { retry = config.retry } = {}) => {
@@ -93,16 +94,16 @@ function apply(ctx, config) {
93
94
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
94
95
  "[MD 卡包] ",
95
96
  mdmcard.obtain.map((it) => {
96
- const expired = !!it.source.expires && new Date(it.source.expires) < /* @__PURE__ */ new Date();
97
+ const expired = it.source.expires && new Date(it.source.expires) < /* @__PURE__ */ new Date();
97
98
  return { ...it, expired };
98
- }).filter((it) => !it.expired || config.showExpiredPacks).sort((i1, i2) => +i1.expired - +i2.expired).map((obtain) => `${obtain.source.name}${obtain.expired ? " (过期)" : ""}`).join(", ") || "无"
99
+ }).filter((it) => !it.expired || config.showExpiredPacks).sort((it) => +it.expired).map((obtain) => `${obtain.source.name}${obtain.expired ? " (过期)" : ""}`).join(", ") || "无"
99
100
  ] })
100
101
  ] });
101
102
  }
102
103
  }
103
104
  session.send(/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("message", { forward: true, children: [
104
105
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("message", { children: [
105
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: API.momobako({ id: card.id }), alt: card.en_name }),
106
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: API.cardImage(config.cardImageUrl, { id: card.id }), alt: card.en_name }),
106
107
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
107
108
  "[MD 卡名] ",
108
109
  card.md_name || "无"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-w-ygo",
3
3
  "description": "WillBot: YuGiOh function",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -15,14 +15,14 @@
15
15
  "plugin"
16
16
  ],
17
17
  "peerDependencies": {
18
- "koishi": "^4.18.7"
18
+ "koishi": "^4.18.10"
19
19
  },
20
20
  "dependencies": {
21
21
  "@satorijs/element": "^3.1.8"
22
22
  },
23
23
  "scripts": {
24
- "build": "yarn workspace willbot build w-ygo",
25
- "bump": "yarn workspace willbot bump w-ygo",
26
- "pub": "yarn workspace willbot pub w-ygo"
24
+ "build": "yarn run -T build w-ygo",
25
+ "bump": "yarn run -T bump w-ygo",
26
+ "pub": "yarn run -T pub w-ygo"
27
27
  }
28
28
  }
package/readme.md CHANGED
@@ -3,3 +3,6 @@
3
3
  [![npm](https://img.shields.io/npm/v/koishi-plugin-w-ygo?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-w-ygo)
4
4
 
5
5
  WillBot: YuGiOh function
6
+
7
+ 卡图默认使用百鸽提供的简体中文卡图,也可以通过 `cardImageUrl` 配置含 `{id}` 占位符的 URL 模板。
8
+ 如需使用 YGOPRODeck 的英文卡图,可以配置为 `https://images.ygoprodeck.com/images/cards/{id}.jpg`。