koishi-plugin-echo-cave 1.16.4 → 1.16.6

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.cjs +9 -10
  2. package/package.json +1 -1
package/lib/index.cjs CHANGED
@@ -368,7 +368,7 @@ async function getUserName(ctx, session, userId) {
368
368
  const memberInfo = await session.onebot.getGroupMemberInfo(session.channelId, userId);
369
369
  return memberInfo.card || memberInfo.nickname || userId;
370
370
  } catch (error) {
371
- ctx.logger.warn(`\u83B7\u53D6\u7FA4\u6210\u5458\u4FE1\u606F\u5931\u8D25\uFF08userId: ${userId}\uFF09\uFF1A`, error);
371
+ ctx.logger.warn(`Failed to get group member info (userId: ${userId}):`, error);
372
372
  return userId;
373
373
  }
374
374
  }
@@ -378,7 +378,7 @@ async function checkUsersInGroup(ctx, session, userIds) {
378
378
  const memberIds = groupMembers.map((member) => member.user_id.toString());
379
379
  return userIds.every((userId) => memberIds.includes(userId));
380
380
  } catch (error) {
381
- ctx.logger.warn(`\u83B7\u53D6\u7FA4\u6210\u5458\u5217\u8868\u5931\u8D25\uFF1A`, error);
381
+ ctx.logger.warn(`Failed to get group member list:`, error);
382
382
  return false;
383
383
  }
384
384
  }
@@ -550,7 +550,7 @@ function apply(ctx, cfg) {
550
550
  ctx.command("cave [id:number]").action(
551
551
  async ({ session }, id) => await getCave(ctx, session, cfg, id)
552
552
  );
553
- ctx.command("cave.echo [...userIds:number]").action(
553
+ ctx.command("cave.echo [...userIds:string]").action(
554
554
  async ({ session }, ...userIds) => await addCave(ctx, session, cfg, userIds)
555
555
  );
556
556
  ctx.command("cave.wipe <id:number>").action(
@@ -560,7 +560,7 @@ function apply(ctx, cfg) {
560
560
  ctx.command("cave.trace").action(
561
561
  async ({ session }) => await getCaveListByOriginUser(ctx, session)
562
562
  );
563
- ctx.command("cave.bind <id:number> <...userIds:number>", { authority: 4 }).action(
563
+ ctx.command("cave.bind <id:number> <...userIds:string>", { authority: 4 }).action(
564
564
  async ({ session }, id, ...userIds) => await bindUsersToCave(ctx, session, id, userIds)
565
565
  );
566
566
  }
@@ -677,9 +677,9 @@ async function addCave(ctx, session, cfg, userIds) {
677
677
  }
678
678
  const { userId, channelId, quote } = session;
679
679
  const messageId = quote.id;
680
- const userIdsStr = userIds.map((id) => id.toString());
680
+ const correctUserIds = userIds.map((s) => Number(s)).filter((n) => !Number.isNaN(n)).map(String);
681
681
  if (userIds && userIds.length > 0) {
682
- const isAllUsersInGroup = await checkUsersInGroup(ctx, session, userIdsStr);
682
+ const isAllUsersInGroup = await checkUsersInGroup(ctx, session, correctUserIds);
683
683
  if (!isAllUsersInGroup) {
684
684
  return session.text(".userNotInGroup");
685
685
  }
@@ -722,7 +722,7 @@ async function addCave(ctx, session, cfg, userIds) {
722
722
  originUserId: quote.user.id,
723
723
  type,
724
724
  content,
725
- relatedUsers: userIdsStr || []
725
+ relatedUsers: correctUserIds || []
726
726
  });
727
727
  return session.text(".msgSaved", [result.id]);
728
728
  } catch (error) {
@@ -739,17 +739,16 @@ async function bindUsersToCave(ctx, session, id, userIds) {
739
739
  if (!userIds || userIds.length === 0) {
740
740
  return session.text(".noUserIdProvided");
741
741
  }
742
- const userIdsStr = userIds.map((id2) => id2.toString());
743
742
  const caves = await ctx.database.get("echo_cave", id);
744
743
  if (caves.length === 0) {
745
744
  return session.text("echo-cave.general.noMsgWithId");
746
745
  }
747
- const isAllUsersInGroup = await checkUsersInGroup(ctx, session, userIdsStr);
746
+ const isAllUsersInGroup = await checkUsersInGroup(ctx, session, userIds);
748
747
  if (!isAllUsersInGroup) {
749
748
  return session.text(".userNotInGroup");
750
749
  }
751
750
  await ctx.database.set("echo_cave", id, {
752
- relatedUsers: userIdsStr
751
+ relatedUsers: userIds
753
752
  });
754
753
  return session.text(".userBoundSuccess", [id]);
755
754
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-echo-cave",
3
3
  "description": "Group echo cave",
4
- "version": "1.16.4",
4
+ "version": "1.16.6",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",