koishi-plugin-bns-blacklist 1.0.1 → 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 +13 -14
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -184,8 +184,8 @@ ${itemsHtml}
184
184
  // ─── Data Scraping ─────────────────────────────────────────
185
185
  async function scrapeSheet(page, url) {
186
186
  await page.goto(url, { waitUntil: 'networkidle2', timeout: 60000 });
187
- // Wait for the sheet to render - look for the sheet container
188
- await page.waitForTimeout(5000);
187
+ // Wait for the sheet to render
188
+ await new Promise(r => setTimeout(r, 5000));
189
189
  // Try to extract data from Tencent Docs rendered cells
190
190
  // Approach: use the Tencent Docs internal data API via JS
191
191
  const data = await page.evaluate(() => {
@@ -375,7 +375,7 @@ function apply(ctx, config) {
375
375
  try {
376
376
  await page.setViewport({ width: 1500, height: 800 });
377
377
  await page.setContent(html, { waitUntil: 'networkidle2', timeout: 30000 });
378
- await page.waitForTimeout(2000);
378
+ await new Promise(r => setTimeout(r, 2000));
379
379
  // Get the card element's bounding box and screenshot it
380
380
  const card = await page.$('.cyber-card');
381
381
  if (card) {
@@ -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.1",
3
+ "version": "1.0.3",
4
4
  "description": "剑灵怀旧服副本黑名单查询 - 从腾讯文档实时拉取数据,输入角色名即可生成黑名单截图",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",