koishi-plugin-ll-mc 3.0.0 → 3.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.
Files changed (2) hide show
  1. package/lib/index.js +13 -3
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -335,6 +335,13 @@ function sanitizeText(text) {
335
335
  if (typeof text !== "string") return text ?? "";
336
336
  return text.replace(/[\u0000-\u001F\u007F-\u009F]/g, "").replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])/g, "").replace(/(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "").trim();
337
337
  }
338
+ // 官机补丁:去掉 emoji(画图时字体无 emoji 字形会显示"?"),保留 ★ 等符号
339
+ function stripEmoji(text) {
340
+ return String(text == null ? "" : text)
341
+ .replace(/[\u{1F000}-\u{1FAFF}\u{1F1E6}-\u{1F1FF}\u{FE0F}\u{200D}\u{20E3}\u{00A9}\u{00AE}\u{2122}\u{3030}\u{2B50}]/gu, "")
342
+ .replace(/\s+/g, " ")
343
+ .trim();
344
+ }
338
345
  __name(sanitizeText, "sanitizeText");
339
346
  var periodMapping = {
340
347
  today: { field: "todayPostCount", name: "今日" },
@@ -528,12 +535,13 @@ async function apply(ctx, config) {
528
535
  processedMessages.set(dedupKey, Date.now() + MESSAGE_DEDUP_TTL);
529
536
  }
530
537
  let sessionChannelName = session.event.channel.name;
531
- let username = sanitizeText(author?.nick || author?.name);
538
+ // 群昵称优先:群名片/群昵称(官机原始事件 member.nick,OneBot member.name/card)
539
+ let username = sanitizeText(author?.nickname || author?.nick);
532
540
  if (!username) {
533
- // 官机补丁:官方QQ原始事件自带 member.nick / author.username,零 API
534
541
  const raw = session.event?._data?.d;
535
- username = sanitizeText(raw?.member?.nick || raw?.author?.username);
542
+ username = sanitizeText(raw?.member?.nick);
536
543
  }
544
+ if (!username) username = sanitizeText(author?.name || author?.username);
537
545
  if (!username) username = userId;
538
546
  const userAvatar = author?.avatar;
539
547
  try {
@@ -2515,6 +2523,8 @@ ${targetUserRecord[0].username}
2515
2523
  if (!config.showStarInChart && newItem.name.startsWith("★")) {
2516
2524
  newItem.name = newItem.name.substring(1);
2517
2525
  }
2526
+ // 官机补丁:emoji 在画图字体里显示为 "?",剥掉
2527
+ newItem.name = stripEmoji(newItem.name);
2518
2528
  return newItem;
2519
2529
  });
2520
2530
  await Promise.all(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ll-mc",
3
3
  "description": "消息数量统计插件(基于 koishi-plugin-message-counter 重做,官方QQ机器人兼容)",
4
- "version": "3.0.0",
4
+ "version": "3.0.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [