koishi-plugin-echo-cave 1.16.4 → 1.16.5
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.cjs +7 -8
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -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:
|
|
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:
|
|
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
|
|
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,
|
|
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:
|
|
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,
|
|
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:
|
|
751
|
+
relatedUsers: userIds
|
|
753
752
|
});
|
|
754
753
|
return session.text(".userBoundSuccess", [id]);
|
|
755
754
|
}
|