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