koishi-plugin-apple-rank 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. package/lib/index.js +47 -26
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -80,7 +80,7 @@ function formatRankItem(item) {
80
80
  __name(formatRankItem, "formatRankItem");
81
81
  function formatRankItemWithIcon(item) {
82
82
  const text = formatRankItem(item);
83
- return item.icon ? `${import_koishi.h.image(item.icon)}${text}` : text;
83
+ return item.icon ? [import_koishi.h.image(item.icon), text].join("") : text;
84
84
  }
85
85
  __name(formatRankItemWithIcon, "formatRankItemWithIcon");
86
86
  function formatUpdatedAt(updated) {
@@ -90,6 +90,14 @@ function formatUpdatedAt(updated) {
90
90
  return `更新时间:${date.toLocaleString("zh-CN", { timeZone: "Asia/Shanghai", hour12: false })}`;
91
91
  }
92
92
  __name(formatUpdatedAt, "formatUpdatedAt");
93
+ function formatFootnote() {
94
+ return "口径:Apple 公开榜单,只代表 iOS 排名,不代表全平台流水";
95
+ }
96
+ __name(formatFootnote, "formatFootnote");
97
+ function joinBlocks(blocks) {
98
+ return blocks.filter(Boolean).join("\n\n");
99
+ }
100
+ __name(joinBlocks, "joinBlocks");
93
101
  function parseFeedType(type = "grossing") {
94
102
  if (["grossing", "畅销", "畅销榜", "流水"].includes(type)) return "topgrossingapplications";
95
103
  if (["free", "免费", "免费榜"].includes(type)) return "topfreeapplications";
@@ -187,7 +195,11 @@ function apply(ctx, config) {
187
195
  const feed = await fetchRanks(feedType);
188
196
  const actualLimit = feed.actualLimit || feed.ranks.length;
189
197
  const lines = feed.ranks.slice(0, Math.min(limit, actualLimit)).map(formatRankItemWithIcon);
190
- return [`App Store ${config.country.toUpperCase()} ${feedLabels[feedType]} Top ${actualLimit}`, formatUpdatedAt(feed.updated), ...lines].join("\n");
198
+ return joinBlocks([
199
+ `App Store ${config.country.toUpperCase()} ${feedLabels[feedType]} Top ${actualLimit}`,
200
+ formatUpdatedAt(feed.updated),
201
+ lines.join("\n")
202
+ ]);
191
203
  });
192
204
  ctx.command("ios排名 <game:text>", "查询游戏在 iOS 畅销榜的排名").option("type", "-t <type:string> 榜单类型:畅销/免费/付费", { fallback: "畅销" }).action(async ({ options, session }, game) => {
193
205
  if (session && !shouldReplyOnce(`${session.sid}:ios排名:${options.type}:${game}`)) return;
@@ -197,21 +209,27 @@ function apply(ctx, config) {
197
209
  const { appId, item, detail, updated, actualLimit } = await findRank(game, feedType);
198
210
  if (!appId) return `没找到「${game}」对应的 App Store 应用`;
199
211
  if (!item) {
200
- return [
212
+ return joinBlocks([
201
213
  detail?.artworkUrl100 ? import_koishi.h.image(detail.artworkUrl100) : "",
202
214
  `「${detail?.trackName || game}」未进入 App Store ${config.country.toUpperCase()} ${feedLabels[feedType]} Top ${actualLimit}`,
203
- formatUpdatedAt(updated),
204
- "口径:Apple 公开榜单,只代表 iOS 排名,不代表全平台流水"
205
- ].filter(Boolean).join("\n");
215
+ [
216
+ formatUpdatedAt(updated),
217
+ detail?.artistName ? `开发者:${detail.artistName}` : "",
218
+ detail?.primaryGenreName ? `分类:${detail.genres?.join(" / ") || detail.primaryGenreName}` : ""
219
+ ].filter(Boolean).join("\n"),
220
+ formatFootnote()
221
+ ]);
206
222
  }
207
- return [
223
+ return joinBlocks([
208
224
  item.icon ? import_koishi.h.image(item.icon) : "",
209
- `${item.name} iOS ${feedLabels[feedType]}排名:第 ${item.rank} 名`,
210
- formatUpdatedAt(updated),
211
- `开发者:${item.artist}`,
212
- `分类:${item.category || "未知"}`,
213
- "口径:Apple 公开榜单,只代表 iOS 排名,不代表全平台流水"
214
- ].filter(Boolean).join("\n");
225
+ `${item.name} iOS ${feedLabels[feedType]}:第 ${item.rank} 名`,
226
+ [
227
+ formatUpdatedAt(updated),
228
+ `开发者:${item.artist}`,
229
+ `分类:${item.category || "未知"}`
230
+ ].join("\n"),
231
+ formatFootnote()
232
+ ]);
215
233
  });
216
234
  ctx.command("ios对比 <games:text>", "对比多个游戏的 iOS 畅销榜排名").action(async ({ session }, games) => {
217
235
  if (session && !shouldReplyOnce(`${session.sid}:ios对比:${games}`)) return;
@@ -226,22 +244,22 @@ function apply(ctx, config) {
226
244
  if (!appId) return `${game}:未找到应用`;
227
245
  const item = feed.ranks.find((item2) => item2.appId === appId);
228
246
  if (!item) {
229
- return [
247
+ return joinBlocks([
230
248
  detail?.artworkUrl100 ? import_koishi.h.image(detail.artworkUrl100) : "",
231
249
  `${detail?.trackName || game}:未进入畅销榜 Top ${actualLimit}`
232
- ].filter(Boolean).join("\n");
250
+ ]);
233
251
  }
234
- return [
252
+ return joinBlocks([
235
253
  item.icon ? import_koishi.h.image(item.icon) : "",
236
254
  `${item.name}:第 ${item.rank} 名`
237
- ].filter(Boolean).join("\n");
255
+ ]);
238
256
  });
239
- return [
257
+ return joinBlocks([
240
258
  `App Store ${config.country.toUpperCase()} 畅销榜对比`,
241
259
  formatUpdatedAt(feed.updated),
242
- ...results,
243
- "口径:Apple 公开榜单,只代表 iOS 排名,不代表全平台流水"
244
- ].join("\n");
260
+ results.join("\n\n"),
261
+ formatFootnote()
262
+ ]);
245
263
  });
246
264
  ctx.command("ios搜索 <keyword:text>", "搜索 App Store 应用").action(async ({ session }, keyword) => {
247
265
  if (session && !shouldReplyOnce(`${session.sid}:ios搜索:${keyword}`)) return;
@@ -251,12 +269,15 @@ function apply(ctx, config) {
251
269
  return results.map((result, index) => {
252
270
  const genres = result.genres?.join(" / ") || result.primaryGenreName;
253
271
  const icon = result.artworkUrl100 ? `${import_koishi.h.image(result.artworkUrl100)}` : "";
254
- return [
272
+ return joinBlocks([
255
273
  icon,
256
- `${index + 1}. ${result.trackName} (${result.trackId})`,
257
- `开发者:${result.artistName}`,
258
- `分类:${genres}`
259
- ].filter(Boolean).join("\n");
274
+ `${index + 1}. ${result.trackName}`,
275
+ [
276
+ `App ID:${result.trackId}`,
277
+ `开发者:${result.artistName}`,
278
+ `分类:${genres}`
279
+ ].join("\n")
280
+ ]);
260
281
  }).join("\n\n");
261
282
  });
262
283
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-apple-rank",
3
3
  "description": "给二游痴看流水用的,数据来自苹果的rss",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [