koishi-plugin-bns-blacklist 1.0.2 → 1.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/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { Context, Schema } from 'koishi';
2
- interface PuppeteerService {
3
- page(): Promise<any>;
4
- browser: any;
5
- }
6
2
  declare module 'koishi' {
7
3
  interface Context {
8
- puppeteer: PuppeteerService;
4
+ puppeteer: {
5
+ page(): Promise<any>;
6
+ browser: any;
7
+ };
9
8
  }
10
9
  }
11
10
  export declare const name = "bns-blacklist";
11
+ export declare const inject: string[];
12
12
  export interface Config {
13
13
  sheetUrl: string;
14
14
  cachePath: string;
@@ -16,4 +16,3 @@ export interface Config {
16
16
  }
17
17
  export declare const Config: Schema<Config>;
18
18
  export declare function apply(ctx: Context, config: Config): void;
19
- export {};
package/lib/index.js CHANGED
@@ -33,12 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Config = exports.name = void 0;
36
+ exports.Config = exports.inject = exports.name = void 0;
37
37
  exports.apply = apply;
38
38
  const koishi_1 = require("koishi");
39
39
  const fs = __importStar(require("fs"));
40
40
  const path = __importStar(require("path"));
41
41
  exports.name = 'bns-blacklist';
42
+ exports.inject = ['puppeteer'];
42
43
  exports.Config = koishi_1.Schema.object({
43
44
  sheetUrl: koishi_1.Schema.string()
44
45
  .default('https://docs.qq.com/sheet/DZXRuRmtTS21mWU9V?tab=BB08J2')
@@ -388,26 +389,25 @@ function apply(ctx, config) {
388
389
  }
389
390
  }
390
391
  // ─── Register Commands ────────────────────────────────
391
- // /黑名单 <角色名> - 查询黑名单
392
- ctx.command('黑名单 <keyword:text>', '查询剑灵怀旧服副本黑名单')
392
+ // /黑名单 [角色名] - 查询黑名单(不输入角色名则显示全部)
393
+ ctx.command('黑名单 [keyword:text]', '查询剑灵怀旧服副本黑名单')
393
394
  .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);
395
+ const isSearch = keyword && keyword.trim();
396
+ const matches = isSearch ? searchCache(keyword) : blacklistCache;
398
397
  if (matches.length === 0) {
399
- return (0, koishi_1.h)('message', [
400
- `未找到与 "${keyword}" 相关的黑名单记录。\n可能与以下因素有关:\n① 角色名有误\n② 该玩家尚未被收录\n③ 数据可能过旧,可使用 /刷新黑名单 手动刷新`
401
- ]);
398
+ if (isSearch) {
399
+ return `未找到与 "${keyword}" 相关的黑名单记录。可输入 /黑名单 查看全部 ${blacklistCache.length} 条记录。`;
400
+ }
401
+ return '黑名单暂无数据,请先使用 /刷新黑名单 拉取数据。';
402
402
  }
403
403
  try {
404
- const html = buildFullHtml(matches, keyword, blacklistCache.length);
404
+ const queryLabel = isSearch ? `Query: ${keyword}` : 'Full List';
405
+ const html = buildFullHtml(matches, queryLabel, blacklistCache.length);
405
406
  const png = await renderToPng(html);
406
407
  return koishi_1.h.image(png, 'image/png');
407
408
  }
408
409
  catch (e) {
409
410
  ctx.logger('bns-blacklist').error('Render failed:', e);
410
- // Fallback to text output
411
411
  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
412
  return textLines.join('\n\n');
413
413
  }
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.4",
4
4
  "description": "剑灵怀旧服副本黑名单查询 - 从腾讯文档实时拉取数据,输入角色名即可生成黑名单截图",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",