koishi-plugin-ll-mc 1.0.0 → 1.0.1

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
@@ -19,6 +19,8 @@ export interface Config {
19
19
  hiddenChannelIdsInLeaderboard: string[];
20
20
  /** 排除统计的频道 ID 列表,这些群的消息不会被计数。 */
21
21
  excludedChannelIds: string[];
22
+ /** 排除统计的用户 ID 列表,这些用户的消息不会被计数。 */
23
+ excludedUserIds: string[];
22
24
  /** 是否将文本排行榜转为 Markdown 图片。 */
23
25
  isTextToImageConversionEnabled: boolean;
24
26
  /** 是否将排行榜渲染为水平柱状图。 */
package/lib/index.js CHANGED
@@ -86,6 +86,9 @@ exports.Config = koishi_1.Schema.intersect([
86
86
  excludedChannelIds: koishi_1.Schema.array(String)
87
87
  .role("table")
88
88
  .description("排除统计的频道 ID 列表,这些群的消息不会被计数。"),
89
+ excludedUserIds: koishi_1.Schema.array(String)
90
+ .role("table")
91
+ .description("排除统计的用户 ID 列表,这些用户的消息不会被计数。"),
89
92
  }).description("排行榜设置"),
90
93
  // --- 图片生成 ---
91
94
  koishi_1.Schema.intersect([
@@ -495,6 +498,9 @@ async function apply(ctx, config) {
495
498
  // 排除指定群聊的统计
496
499
  if (config.excludedChannelIds?.includes(session.channelId))
497
500
  return next();
501
+ // 排除指定用户的统计
502
+ if (config.excludedUserIds?.includes(session.userId))
503
+ return next();
498
504
  session[PROCESSED] = true;
499
505
  const { userId, channelId, author } = session;
500
506
  let sessionChannelName = session.event.channel.name;
@@ -2525,13 +2531,17 @@ async function apply(ctx, config) {
2525
2531
  return content;
2526
2532
  }
2527
2533
  async function getChannelName(bot, channelId) {
2534
+ // 部分适配器(如官方 bot)未实现 getChannel 方法,此时直接回退为 channelId
2535
+ if (!bot || typeof bot.getChannel !== "function") {
2536
+ return channelId;
2537
+ }
2528
2538
  try {
2529
2539
  const channel = await bot.getChannel(channelId);
2530
- return channel?.name;
2540
+ return channel?.name || channelId;
2531
2541
  }
2532
2542
  catch (error) {
2533
2543
  logger.warn(`Failed to get channelId name for ${channelId}:`, error);
2534
- return undefined;
2544
+ return channelId;
2535
2545
  }
2536
2546
  }
2537
2547
  function parseList(str) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ll-mc",
3
3
  "description": "消息统计插件(克隆自 message-counter),支持排除指定群聊",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -36,10 +36,10 @@
36
36
  "koishi": "^4.18.9"
37
37
  },
38
38
  "devDependencies": {
39
- "koishi": "^4.18.9",
40
- "typescript": "^5.4.0",
39
+ "koishi": "^4.18.11",
41
40
  "koishi-plugin-cron": "^3.1.0",
42
41
  "koishi-plugin-markdown-to-image-service": "^1.3.6",
43
- "koishi-plugin-puppeteer": "^3.9.0"
42
+ "koishi-plugin-puppeteer": "^3.9.0",
43
+ "typescript": "^5.4.0"
44
44
  }
45
45
  }