koishi-plugin-bns-blacklist 1.0.2 → 1.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 +10 -11
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -388,26 +388,25 @@ function apply(ctx, config) {
388
388
  }
389
389
  }
390
390
  // ─── Register Commands ────────────────────────────────
391
- // /黑名单 <角色名> - 查询黑名单
392
- ctx.command('黑名单 <keyword:text>', '查询剑灵怀旧服副本黑名单')
391
+ // /黑名单 [角色名] - 查询黑名单(不输入角色名则显示全部)
392
+ ctx.command('黑名单 [keyword:text]', '查询剑灵怀旧服副本黑名单')
393
393
  .action(async ({ session }, keyword) => {
394
- if (!keyword || !keyword.trim()) {
395
- return `请输入要查询的角色名,例如:/黑名单 九天揽月\n\n当前缓存共 ${blacklistCache.length} 条记录,最后刷新:${new Date(lastRefresh).toLocaleString()}\n可使用 /刷新黑名单 手动刷新数据`;
396
- }
397
- const matches = searchCache(keyword);
394
+ const isSearch = keyword && keyword.trim();
395
+ const matches = isSearch ? searchCache(keyword) : blacklistCache;
398
396
  if (matches.length === 0) {
399
- return (0, koishi_1.h)('message', [
400
- `未找到与 "${keyword}" 相关的黑名单记录。\n可能与以下因素有关:\n① 角色名有误\n② 该玩家尚未被收录\n③ 数据可能过旧,可使用 /刷新黑名单 手动刷新`
401
- ]);
397
+ if (isSearch) {
398
+ return `未找到与 "${keyword}" 相关的黑名单记录。可输入 /黑名单 查看全部 ${blacklistCache.length} 条记录。`;
399
+ }
400
+ return '黑名单暂无数据,请先使用 /刷新黑名单 拉取数据。';
402
401
  }
403
402
  try {
404
- const html = buildFullHtml(matches, keyword, blacklistCache.length);
403
+ const queryLabel = isSearch ? `Query: ${keyword}` : 'Full List';
404
+ const html = buildFullHtml(matches, queryLabel, blacklistCache.length);
405
405
  const png = await renderToPng(html);
406
406
  return koishi_1.h.image(png, 'image/png');
407
407
  }
408
408
  catch (e) {
409
409
  ctx.logger('bns-blacklist').error('Render failed:', e);
410
- // Fallback to text output
411
410
  const textLines = matches.map((r, i) => `${i + 1}. ${r.name} [${r.class}] ${r.server} - ${r.violation}\n ${r.description}\n 副本:${r.dungeon} | 日期:${r.date}`);
412
411
  return textLines.join('\n\n');
413
412
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-bns-blacklist",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "剑灵怀旧服副本黑名单查询 - 从腾讯文档实时拉取数据,输入角色名即可生成黑名单截图",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",