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.
- package/lib/index.js +10 -11
- 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('黑名单
|
|
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
|
}
|