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 +5 -6
- package/lib/index.js +12 -12
- package/package.json +1 -1
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:
|
|
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('黑名单
|
|
392
|
+
// /黑名单 [角色名] - 查询黑名单(不输入角色名则显示全部)
|
|
393
|
+
ctx.command('黑名单 [keyword:text]', '查询剑灵怀旧服副本黑名单')
|
|
393
394
|
.action(async ({ session }, keyword) => {
|
|
394
|
-
|
|
395
|
-
|
|
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
|
-
|
|
400
|
-
`未找到与 "${keyword}"
|
|
401
|
-
|
|
398
|
+
if (isSearch) {
|
|
399
|
+
return `未找到与 "${keyword}" 相关的黑名单记录。可输入 /黑名单 查看全部 ${blacklistCache.length} 条记录。`;
|
|
400
|
+
}
|
|
401
|
+
return '黑名单暂无数据,请先使用 /刷新黑名单 拉取数据。';
|
|
402
402
|
}
|
|
403
403
|
try {
|
|
404
|
-
const
|
|
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
|
}
|