koishi-plugin-echo-cave 1.18.1 → 1.18.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/core/command/search-cave.d.ts +1 -1
- package/lib/index.cjs +8 -10
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Context, Session } from 'koishi';
|
|
2
|
-
export declare function searchCave(ctx: Context, session: Session, userIds:
|
|
2
|
+
export declare function searchCave(ctx: Context, session: Session, userIds: string): Promise<string>;
|
package/lib/index.cjs
CHANGED
|
@@ -206,7 +206,7 @@ async function checkUsersInGroup(ctx, session, userIds) {
|
|
|
206
206
|
var import_koishi = require("koishi");
|
|
207
207
|
function parseUserIds(userIds) {
|
|
208
208
|
const parsedUserIds = [];
|
|
209
|
-
for (const userId of userIds) {
|
|
209
|
+
for (const userId of typeof userIds === "string" ? [userIds] : userIds) {
|
|
210
210
|
const num = Number(userId);
|
|
211
211
|
if (!Number.isNaN(num)) {
|
|
212
212
|
parsedUserIds.push(userId);
|
|
@@ -818,7 +818,6 @@ async function bindUsersToCave(ctx, session, id, userIds) {
|
|
|
818
818
|
}
|
|
819
819
|
|
|
820
820
|
// src/core/command/search-cave.ts
|
|
821
|
-
var import_koishi2 = require("koishi");
|
|
822
821
|
async function searchCave(ctx, session, userIds) {
|
|
823
822
|
if (!session.guildId) {
|
|
824
823
|
return session.text("echo-cave.general.privateChatReminder");
|
|
@@ -826,7 +825,7 @@ async function searchCave(ctx, session, userIds) {
|
|
|
826
825
|
if (!userIds) {
|
|
827
826
|
return session.text(".noUserIdProvided");
|
|
828
827
|
}
|
|
829
|
-
const result = parseUserIds(userIds
|
|
828
|
+
const result = parseUserIds(userIds);
|
|
830
829
|
if (result.error === "invalid_all_mention") {
|
|
831
830
|
return session.text("echo-cave.user.invalidAllMention");
|
|
832
831
|
}
|
|
@@ -840,12 +839,11 @@ async function searchCave(ctx, session, userIds) {
|
|
|
840
839
|
}
|
|
841
840
|
const targetUserId = parsedUserIds[0];
|
|
842
841
|
const { channelId } = session;
|
|
843
|
-
const
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
)
|
|
842
|
+
const caves = await ctx.database.get("echo_cave", {
|
|
843
|
+
channelId
|
|
844
|
+
});
|
|
845
|
+
const matchingCaves = caves.filter(
|
|
846
|
+
(cave) => cave.originUserId === targetUserId || cave.relatedUsers.includes(targetUserId)
|
|
849
847
|
);
|
|
850
848
|
if (matchingCaves.length === 0) {
|
|
851
849
|
return session.text(".noMatchingCaves", [targetUserId]);
|
|
@@ -893,7 +891,7 @@ function apply(ctx, cfg) {
|
|
|
893
891
|
ctx.command("cave.purge <...ids:number>").action(
|
|
894
892
|
async ({ session }, ...ids) => await deleteCaves(ctx, session, cfg, ids)
|
|
895
893
|
);
|
|
896
|
-
ctx.command("cave.search <id
|
|
894
|
+
ctx.command("cave.search <id>").action(
|
|
897
895
|
async ({ session }, id) => await searchCave(ctx, session, id)
|
|
898
896
|
);
|
|
899
897
|
ctx.command("cave.bind <id:number> <...userIds>", { authority: 4 }).action(
|