koishi-plugin-echo-cave 1.4.1 → 1.6.0
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 +47 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -264,12 +264,58 @@ function apply(ctx) {
|
|
|
264
264
|
"cave [id:number]",
|
|
265
265
|
"\u968F\u673A\u83B7\u53D6 / \u83B7\u53D6\u7279\u5B9A id \u7684\u56DE\u58F0\u6D1E\u4FE1\u606F"
|
|
266
266
|
).action(async ({ session }, id) => await getCave(ctx, session, id));
|
|
267
|
-
ctx.command("cave.echo", "\u5C06\u6D88\u606F\u5B58\u5165\u56DE\u58F0\u6D1E
|
|
267
|
+
ctx.command("cave.echo", "\u5C06\u6D88\u606F\u5B58\u5165\u56DE\u58F0\u6D1E").action(
|
|
268
268
|
async ({ session }) => await addCave(ctx, session)
|
|
269
269
|
);
|
|
270
270
|
ctx.command("cave.wipe <id:number>", "\u62B9\u53BB\u7279\u5B9A id \u7684\u56DE\u58F0\u6D1E\u4FE1\u606F").action(
|
|
271
271
|
async ({ session }, id) => await deleteCave(ctx, session, id)
|
|
272
272
|
);
|
|
273
|
+
ctx.command("cave.listen", "\u83B7\u5F97\u7531\u81EA\u5DF1\u6295\u7A3F\u7684\u56DE\u58F0\u6D1E\u5217\u8868").action(
|
|
274
|
+
async ({ session }) => await getCaveListByUser(ctx, session)
|
|
275
|
+
);
|
|
276
|
+
ctx.command("cave.trace", "\u83B7\u5F97\u81EA\u5DF1\u53D1\u8A00\u7684\u56DE\u58F0\u6D1E\u5217\u8868").action(
|
|
277
|
+
async ({ session }) => await getCaveListByOriginUser(ctx, session)
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
async function getCaveListByUser(ctx, session) {
|
|
281
|
+
if (!session.guildId) {
|
|
282
|
+
return "\u274C \u8BF7\u5728\u7FA4\u804A\u4E2D\u4F7F\u7528\u8BE5\u547D\u4EE4\uFF01";
|
|
283
|
+
}
|
|
284
|
+
const { userId, channelId } = session;
|
|
285
|
+
const caves = await ctx.database.get("echo_cave", {
|
|
286
|
+
userId,
|
|
287
|
+
channelId
|
|
288
|
+
});
|
|
289
|
+
if (caves.length === 0) {
|
|
290
|
+
return '\u{1F680} \u60A8\u5728\u56DE\u58F0\u6D1E\u4E2D\u6682\u65E0\u6295\u7A3F\uFF0C\u5FEB\u4F7F\u7528 "cave.echo" \u547D\u4EE4\u6DFB\u52A0\u7B2C\u4E00\u6761\u6D88\u606F\u5427\uFF01';
|
|
291
|
+
}
|
|
292
|
+
let response = `\u{1F4DC} \u60A8\u5728\u672C\u9891\u9053\u6295\u7A3F\u7684\u56DE\u58F0\u6D1E\u6D88\u606F\u5217\u8868\uFF1A
|
|
293
|
+
`;
|
|
294
|
+
for (const cave of caves) {
|
|
295
|
+
response += `ID: ${cave.id} | \u521B\u5EFA\u65F6\u95F4: ${formatDate(cave.createTime)}
|
|
296
|
+
`;
|
|
297
|
+
}
|
|
298
|
+
return response;
|
|
299
|
+
}
|
|
300
|
+
async function getCaveListByOriginUser(ctx, session) {
|
|
301
|
+
if (!session.guildId) {
|
|
302
|
+
return "\u274C \u8BF7\u5728\u7FA4\u804A\u4E2D\u4F7F\u7528\u8BE5\u547D\u4EE4\uFF01";
|
|
303
|
+
}
|
|
304
|
+
const { userId, channelId } = session;
|
|
305
|
+
const caves = await ctx.database.get("echo_cave", {
|
|
306
|
+
originUserId: userId,
|
|
307
|
+
channelId
|
|
308
|
+
});
|
|
309
|
+
if (caves.length === 0) {
|
|
310
|
+
return '\u{1F680} \u60A8\u5728\u56DE\u58F0\u6D1E\u4E2D\u6682\u65E0\u53D1\u8A00\u88AB\u6295\u7A3F\uFF0C\u5FEB\u4F7F\u7528 "cave.echo" \u547D\u4EE4\u6DFB\u52A0\u7B2C\u4E00\u6761\u6D88\u606F\u5427\uFF01';
|
|
311
|
+
}
|
|
312
|
+
let response = `\u{1F4DC} \u60A8\u5728\u672C\u9891\u9053\u53D1\u8A00\u7684\u56DE\u58F0\u6D1E\u6D88\u606F\u5217\u8868\uFF1A
|
|
313
|
+
`;
|
|
314
|
+
for (const cave of caves) {
|
|
315
|
+
response += `ID: ${cave.id} | \u521B\u5EFA\u65F6\u95F4: ${formatDate(cave.createTime)}
|
|
316
|
+
`;
|
|
317
|
+
}
|
|
318
|
+
return response;
|
|
273
319
|
}
|
|
274
320
|
async function getCave(ctx, session, id) {
|
|
275
321
|
if (!session.guildId) {
|