koishi-plugin-echo-cave 1.29.13 → 1.29.14

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 +34 -102
  2. package/package.json +2 -2
package/lib/index.cjs CHANGED
@@ -33706,11 +33706,7 @@ function getLocalMediaV2Root(ctx) {
33706
33706
  return import_node_path.default.join(getLocalMediaRoot(ctx), "v2");
33707
33707
  }
33708
33708
  function getLocalMediaV2Dir(ctx, channelId, type) {
33709
- return import_node_path.default.join(
33710
- getLocalMediaV2Root(ctx),
33711
- encodeURIComponent(channelId),
33712
- getMediaDirName(type)
33713
- );
33709
+ return import_node_path.default.join(getLocalMediaV2Root(ctx), encodeURIComponent(channelId), getMediaDirName(type));
33714
33710
  }
33715
33711
  function getLegacyMediaDir(ctx, type) {
33716
33712
  return import_node_path.default.join(getLocalMediaRoot(ctx), getMediaDirName(type));
@@ -34004,12 +34000,7 @@ async function transferS3ObjectToChannel(cfg, source, type, targetChannelId, mod
34004
34000
  throw new Error("S3 bucket is not configured.");
34005
34001
  }
34006
34002
  const extension = import_node_path.default.extname(source.key).slice(1) || getDefaultExtension(type);
34007
- const key = buildS3Key(
34008
- cfg,
34009
- targetChannelId,
34010
- type,
34011
- `${(0, import_uuid2.v4)().replace(/-/g, "")}.${extension}`
34012
- );
34003
+ const key = buildS3Key(cfg, targetChannelId, type, `${(0, import_uuid2.v4)().replace(/-/g, "")}.${extension}`);
34013
34004
  const target = { bucket, key };
34014
34005
  if (source.bucket === target.bucket && source.key === target.key) {
34015
34006
  return toS3Uri(source);
@@ -34088,13 +34079,7 @@ async function transferMediaRefToChannel(ctx, fileRef, type, targetChannelId, ta
34088
34079
  }
34089
34080
  const loaded2 = await loadMediaBuffer(ctx, fileRef, cfg);
34090
34081
  const extension2 = import_node_path.default.extname(loaded2.sourceKey).slice(1) || getDefaultExtension(type);
34091
- const targetPath = await writeLocalMedia(
34092
- ctx,
34093
- targetChannelId,
34094
- type,
34095
- loaded2.buffer,
34096
- extension2
34097
- );
34082
+ const targetPath = await writeLocalMedia(ctx, targetChannelId, type, loaded2.buffer, extension2);
34098
34083
  const plan2 = {
34099
34084
  nextRef: toFileUri(targetPath),
34100
34085
  rollback: createDeleteLocalFilePlan(targetPath).rollback
@@ -34215,9 +34200,7 @@ async function mutateMessageContent(ctx, content, handler) {
34215
34200
  const nextContent = await Promise.all(
34216
34201
  contentValue.map(async (child) => mutateElement(child))
34217
34202
  );
34218
- const hasChildChange = nextContent.some(
34219
- (child, index) => child !== contentValue[index]
34220
- );
34203
+ const hasChildChange = nextContent.some((child, index) => child !== contentValue[index]);
34221
34204
  if (hasChildChange) {
34222
34205
  changed = true;
34223
34206
  return {
@@ -34304,9 +34287,7 @@ async function deleteCavesForOversizedMedia(ctx, caves, cfg) {
34304
34287
  await removeCaveByEntryId(ctx, cave.entryId);
34305
34288
  ctx.logger.info(`Deleted cave #${cave.id} because its media exceeded the size limit.`);
34306
34289
  } catch (error2) {
34307
- ctx.logger.warn(
34308
- `Failed to delete cave #${cave.id} during oversized media cleanup: ${error2}`
34309
- );
34290
+ ctx.logger.warn(`Failed to delete cave #${cave.id} during oversized media cleanup: ${error2}`);
34310
34291
  }
34311
34292
  }
34312
34293
  }
@@ -34637,9 +34618,7 @@ async function checkAndCleanMediaFiles(ctx, cfg, type) {
34637
34618
  }
34638
34619
  const totalSize = fileInfos.reduce((sum, file) => sum + file.size, 0);
34639
34620
  if (totalSize <= maxSize) {
34640
- ctx.logger.debug(
34641
- `${type} check completed in ${Date.now() - startTime}ms: no cleanup needed`
34642
- );
34621
+ ctx.logger.debug(`${type} check completed in ${Date.now() - startTime}ms: no cleanup needed`);
34643
34622
  return;
34644
34623
  }
34645
34624
  fileInfos.sort((a5, b5) => a5.mtime - b5.mtime);
@@ -35542,9 +35521,7 @@ async function restoreReindexBackup(ctx, session, cfg, backupPathInput) {
35542
35521
  }
35543
35522
  async function runScheduledReindex(ctx, cfg) {
35544
35523
  if (caveMaintenanceLock) {
35545
- ctx.logger.warn(
35546
- "Skipped scheduled cave reindex because another maintenance task is running."
35547
- );
35524
+ ctx.logger.warn("Skipped scheduled cave reindex because another maintenance task is running.");
35548
35525
  return;
35549
35526
  }
35550
35527
  const caves = (await getAllCaves(ctx)).sort((a5, b5) => a5.id - b5.id);
@@ -35604,13 +35581,7 @@ function registerAutoReindexScheduler(ctx, cfg) {
35604
35581
  async function reconstructForwardMsg(ctx, session, message, cfg, processMedia = true) {
35605
35582
  return Promise.all(
35606
35583
  message.map(async (msg) => {
35607
- const content = await processForwardMessageContent(
35608
- ctx,
35609
- session,
35610
- msg,
35611
- cfg,
35612
- processMedia
35613
- );
35584
+ const content = await processForwardMessageContent(ctx, session, msg, cfg, processMedia);
35614
35585
  const senderNickname = msg.sender.nickname;
35615
35586
  let senderUserId = msg.sender.user_id;
35616
35587
  senderUserId = senderUserId === 1094950020 ? await getUserIdFromNickname(session, senderNickname, senderUserId) : senderUserId;
@@ -35754,13 +35725,7 @@ async function addCave(ctx, session, cfg, userIds) {
35754
35725
  session,
35755
35726
  cfg,
35756
35727
  hasMedia,
35757
- async (progressOptions) => await processStoredMessageMedia(
35758
- ctx,
35759
- content,
35760
- cfg,
35761
- channelId,
35762
- progressOptions
35763
- )
35728
+ async (progressOptions) => await processStoredMessageMedia(ctx, content, cfg, channelId, progressOptions)
35764
35729
  );
35765
35730
  }
35766
35731
  const finalParsedUserIds = selectedUsersWithNames.length !== 0 ? selectedUsersWithNames.map((user) => user.userId) : parsedUserIds;
@@ -35807,9 +35772,7 @@ async function formatRelatedUsers(ctx, session, selectedUsersWithNames, relatedU
35807
35772
  }
35808
35773
  if (relatedUserIds.length !== 0) {
35809
35774
  const relatedUserNames = await Promise.all(
35810
- relatedUserIds.map(
35811
- async (relatedUserId) => await getUserName(ctx, session, relatedUserId)
35812
- )
35775
+ relatedUserIds.map(async (relatedUserId) => await getUserName(ctx, session, relatedUserId))
35813
35776
  );
35814
35777
  return relatedUserNames.join(", ");
35815
35778
  }
@@ -35874,16 +35837,12 @@ ${promptFooter}`;
35874
35837
  selectedUsers = [];
35875
35838
  } else {
35876
35839
  const indices = trimmedMessage.split(/\s+/).map((index) => parseInt(index.trim()) - 1);
35877
- const validIndices = indices.filter(
35878
- (index) => index >= 0 && index < forwardUsers.length
35879
- );
35840
+ const validIndices = indices.filter((index) => index >= 0 && index < forwardUsers.length);
35880
35841
  if (validIndices.length > 0) {
35881
35842
  selectedUsers = validIndices.map((index) => forwardUsers[index]);
35882
35843
  } else {
35883
35844
  sentMessageIds.push(
35884
- ...normalizeMessageIds(
35885
- await session.send(session.text(".invalidSelection"))
35886
- )
35845
+ ...normalizeMessageIds(await session.send(session.text(".invalidSelection")))
35887
35846
  );
35888
35847
  return true;
35889
35848
  }
@@ -35918,9 +35877,13 @@ async function confirmSpecialForwardStorage(ctx, session, previewMessage) {
35918
35877
  sentMessageIds.push(
35919
35878
  ...normalizeMessageIds(await session.send(session.text(".specialForwardUserConfirmNotice")))
35920
35879
  );
35921
- sentMessageIds.push(...normalizeMessageIds(await session.send(previewMessage)));
35880
+ if (session.onebot) {
35881
+ sentMessageIds.push(
35882
+ (await session.onebot.sendGroupForwardMsg(session.channelId, previewMessage)).toString()
35883
+ );
35884
+ }
35922
35885
  scheduleSilentDelete(ctx, session, SPECIAL_FORWARD_RECALL_DELAY, sentMessageIds);
35923
- const shouldStore = await new Promise((resolve) => {
35886
+ return await new Promise((resolve) => {
35924
35887
  listenForUserMessage(
35925
35888
  ctx,
35926
35889
  session,
@@ -35948,7 +35911,6 @@ async function confirmSpecialForwardStorage(ctx, session, previewMessage) {
35948
35911
  }
35949
35912
  ).then((promptMessageIds) => sentMessageIds.push(...promptMessageIds));
35950
35913
  });
35951
- return shouldStore;
35952
35914
  }
35953
35915
 
35954
35916
  // src/core/command/delete-cave.ts
@@ -36163,9 +36125,7 @@ async function flushSendFailureSummary(ctx, cfg) {
36163
36125
  const [platform, selfId] = botKey.split(":");
36164
36126
  const bot = ctx.bots.find((item) => item.platform === platform && item.selfId === selfId);
36165
36127
  if (!bot) {
36166
- ctx.logger.warn(
36167
- `Skipped cave send failure summary because bot ${botKey} is unavailable.`
36168
- );
36128
+ ctx.logger.warn(`Skipped cave send failure summary because bot ${botKey} is unavailable.`);
36169
36129
  continue;
36170
36130
  }
36171
36131
  const messages = buildSummaryMessages(ctx, entries);
@@ -36347,9 +36307,7 @@ async function sendCaveMsg(ctx, session, caveMsg, cfg) {
36347
36307
  const { channelId } = session;
36348
36308
  let content = JSON.parse(caveMsg.content);
36349
36309
  content = await Promise.all(
36350
- content.map(
36351
- async (element) => await resolveMediaElementForSend(ctx, element, cfg)
36352
- )
36310
+ content.map(async (element) => await resolveMediaElementForSend(ctx, element, cfg))
36353
36311
  );
36354
36312
  const date2 = formatDate(caveMsg.createTime);
36355
36313
  const originName = await getUserName(ctx, session, caveMsg.originUserId);
@@ -36564,11 +36522,7 @@ async function getCave(ctx, session, cfg, target) {
36564
36522
  if (parseResult.parsedUserIds.length === 0) {
36565
36523
  return session.text("echo-cave.general.noMsgWithId");
36566
36524
  }
36567
- const targetedResult = await getTargetedUserCave(
36568
- ctx,
36569
- session,
36570
- parseResult.parsedUserIds[0]
36571
- );
36525
+ const targetedResult = await getTargetedUserCave(ctx, session, parseResult.parsedUserIds[0]);
36572
36526
  if (!targetedResult) {
36573
36527
  return session.text(".noMatchingUserCave");
36574
36528
  }
@@ -36913,8 +36867,8 @@ var zh_CN_default = {
36913
36867
  selectInstructionDetailed: "\u8F93\u5165\u793A\u4F8B\uFF1A1 2 \u6216 all \u6216 skip",
36914
36868
  selectInstructionBrief: "\u56DE\u590D\u5E8F\u53F7 / all / skip",
36915
36869
  invalidSelection: "\u274C \u65E0\u6548\u7684\u9009\u62E9\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\uFF01",
36916
- specialForwardUserBlocked: "\u26A0\uFE0F \u68C0\u6D4B\u5230\u8BE5\u5408\u5E76\u8F6C\u53D1\u4E2D\u5305\u542B\u7279\u6B8A\u7528\u6237 1094950020\uFF0C\u5F53\u524D\u914D\u7F6E\u4E0D\u5141\u8BB8\u5B58\u50A8\u8FD9\u6761\u56DE\u58F0\u6D1E\u3002\u8BE5\u63D0\u793A\u4F1A\u5728 1 \u5206\u949F\u540E\u81EA\u52A8\u64A4\u56DE\u3002",
36917
- specialForwardUserConfirmNotice: "\u26A0\uFE0F \u68C0\u6D4B\u5230\u8BE5\u5408\u5E76\u8F6C\u53D1\u4E2D\u5305\u542B\u7279\u6B8A\u7528\u6237 1094950020\u3002\u4E0B\u9762\u4F1A\u91CD\u65B0\u53D1\u51FA\u8BFB\u53D6\u5230\u7684\u8F6C\u53D1\u5185\u5BB9\uFF0C\u8BF7\u786E\u8BA4\u662F\u5426\u4ECD\u8981\u5B58\u50A8\u3002",
36870
+ specialForwardUserBlocked: "\u26A0\uFE0F \u68C0\u6D4B\u5230\u8BE5\u5408\u5E76\u8F6C\u53D1\u4E2D\u7684\u7528\u6237\u4FE1\u606F\u65E0\u6CD5\u8BFB\u53D6\uFF0C\u5F53\u524D\u914D\u7F6E\u4E0D\u5141\u8BB8\u5B58\u50A8\u8FD9\u6761\u56DE\u58F0\u6D1E\u3002\u8BE5\u63D0\u793A\u4F1A\u5728 1 \u5206\u949F\u540E\u81EA\u52A8\u64A4\u56DE\u3002",
36871
+ specialForwardUserConfirmNotice: "\u26A0\uFE0F \u68C0\u6D4B\u5230\u8BE5\u5408\u5E76\u8F6C\u53D1\u4E2D\u7684\u7528\u6237\u4FE1\u606F\u65E0\u6CD5\u8BFB\u53D6\u3002\u4E0B\u9762\u4F1A\u91CD\u65B0\u53D1\u51FA\u8BFB\u53D6\u5230\u7684\u8F6C\u53D1\u5185\u5BB9\uFF0C\u8BF7\u786E\u8BA4\u662F\u5426\u4ECD\u8981\u5B58\u50A8\u3002",
36918
36872
  specialForwardUserConfirmPrompt: "\u8BF7\u5728 60 \u79D2\u5185\u56DE\u590D\u201C\u5B58\u50A8\u201D\u7EE7\u7EED\uFF0C\u56DE\u590D\u201C\u53D6\u6D88\u201D\u6216\u201C\u4E0D\u5B58\u201D\u653E\u5F03\u3002",
36919
36873
  specialForwardUserConfirmRetry: "\u26A0\uFE0F \u65E0\u6CD5\u8BC6\u522B\u8F93\u5165\uFF0C\u8BF7\u56DE\u590D\u201C\u5B58\u50A8\u201D\u6216\u201C\u53D6\u6D88\u201D\u3002"
36920
36874
  }
@@ -37138,9 +37092,7 @@ var Config = import_koishi2.Schema.intersect([
37138
37092
  enableForwardUserSelection: import_koishi2.Schema.boolean().default(true),
37139
37093
  forwardSelectTimeout: import_koishi2.Schema.number().default(20),
37140
37094
  autoBindSingleForwardUser: import_koishi2.Schema.boolean().default(false),
37141
- forwardSpecialUserHandlingMode: import_koishi2.Schema.union(["ignore", "reject", "confirm"]).default(
37142
- "ignore"
37143
- )
37095
+ forwardSpecialUserHandlingMode: import_koishi2.Schema.union(["ignore", "reject", "confirm"]).default("ignore")
37144
37096
  }).description("\u6D88\u606F\u884C\u4E3A"),
37145
37097
  import_koishi2.Schema.object({
37146
37098
  deleteMediaWhenDeletingMsg: import_koishi2.Schema.boolean().default(true),
@@ -37299,31 +37251,17 @@ function apply(ctx, cfg) {
37299
37251
  await database.create(ACTIVE_CAVE_TABLE, toV3Record(record));
37300
37252
  }
37301
37253
  });
37302
- ctx.command("cave [target:text]").action(
37303
- async ({ session }, target) => await getCave(ctx, session, cfg, target)
37304
- );
37254
+ ctx.command("cave [target:text]").action(async ({ session }, target) => await getCave(ctx, session, cfg, target));
37305
37255
  ctx.command("cave.listen").action(async ({ session }) => await getCaveListByUser(ctx, session));
37306
- ctx.command("cave.trace").action(
37307
- async ({ session }) => await getCaveListByOriginUser(ctx, session)
37308
- );
37309
- ctx.command("cave.echo [...userIds]").action(
37310
- async ({ session }, ...userIds) => await addCave(ctx, session, cfg, userIds)
37311
- );
37312
- ctx.command("cave.drop <id:number>").action(
37313
- async ({ session }, id) => await deleteCave(ctx, session, cfg, id)
37314
- );
37315
- ctx.command("cave.purge <...ids:number>").action(
37316
- async ({ session }, ...ids) => await deleteCaves(ctx, session, cfg, ids)
37317
- );
37318
- ctx.command("cave.search <id>").action(
37319
- async ({ session }, id) => await searchCave(ctx, session, id)
37320
- );
37256
+ ctx.command("cave.trace").action(async ({ session }) => await getCaveListByOriginUser(ctx, session));
37257
+ ctx.command("cave.echo [...userIds]").action(async ({ session }, ...userIds) => await addCave(ctx, session, cfg, userIds));
37258
+ ctx.command("cave.drop <id:number>").action(async ({ session }, id) => await deleteCave(ctx, session, cfg, id));
37259
+ ctx.command("cave.purge <...ids:number>").action(async ({ session }, ...ids) => await deleteCaves(ctx, session, cfg, ids));
37260
+ ctx.command("cave.search <id>").action(async ({ session }, id) => await searchCave(ctx, session, id));
37321
37261
  ctx.command("cave.bind <id:number> <...userIds>", { authority: 4 }).action(
37322
37262
  async ({ session }, id, ...userIds) => await bindUsersToCave(ctx, session, id, userIds)
37323
37263
  );
37324
- ctx.command("cave.rank [period:string]").action(
37325
- async ({ session }, period) => await getRanking(ctx, session, cfg, period)
37326
- );
37264
+ ctx.command("cave.rank [period:string]").action(async ({ session }, period) => await getRanking(ctx, session, cfg, period));
37327
37265
  ctx.command(
37328
37266
  "cave.admin.merge <sourceChannelId:string> <targetChannelId:string> [keepSource:string]"
37329
37267
  ).action(
@@ -37336,18 +37274,12 @@ function apply(ctx, cfg) {
37336
37274
  keepSource
37337
37275
  )
37338
37276
  );
37339
- ctx.command("cave.admin.migrate-local-v2").action(
37340
- async ({ session }) => await migrateLegacyLocalMedia(ctx, session, cfg)
37341
- );
37342
- ctx.command("cave.admin.migrate-s3 [keepLocal:string]").action(
37343
- async ({ session }, keepLocal) => await migrateMediaToS3(ctx, session, cfg, keepLocal)
37344
- );
37277
+ ctx.command("cave.admin.migrate-local-v2").action(async ({ session }) => await migrateLegacyLocalMedia(ctx, session, cfg));
37278
+ ctx.command("cave.admin.migrate-s3 [keepLocal:string]").action(async ({ session }, keepLocal) => await migrateMediaToS3(ctx, session, cfg, keepLocal));
37345
37279
  ctx.command("cave.admin.inspect-media [idRanges:text]").action(
37346
37280
  async ({ session }, idRanges) => await inspectMediaRefsForMigration(ctx, session, cfg, idRanges)
37347
37281
  );
37348
- ctx.command("cave.admin.reindex").action(
37349
- async ({ session }) => await reindexCaveIds(ctx, session, cfg)
37350
- );
37282
+ ctx.command("cave.admin.reindex").action(async ({ session }) => await reindexCaveIds(ctx, session, cfg));
37351
37283
  ctx.command("cave.admin.restore-reindex <backupPath:text>").action(
37352
37284
  async ({ session }, backupPath) => await restoreReindexBackup(ctx, session, cfg, backupPath)
37353
37285
  );
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.29.13",
4
+ "version": "1.29.14",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",
@@ -33,7 +33,7 @@
33
33
  ]
34
34
  },
35
35
  "peerDependencies": {
36
- "koishi": "^4.18.10"
36
+ "koishi": "^4.18.11"
37
37
  },
38
38
  "dependencies": {
39
39
  "@aws-sdk/client-s3": "^3.1029.0",