koishi-plugin-maple-drift-bottle 0.1.2 → 0.1.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.
Files changed (2) hide show
  1. package/lib/index.js +10 -8
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -256,6 +256,9 @@ ${textContent}`;
256
256
  if (options.invisible && options.visible) {
257
257
  return "选项冲突:-i(匿名)和-v(公开)不能同时使用";
258
258
  }
259
+ if (!content && !session.elements?.some((el) => el.type === "image")) {
260
+ return "格式错误!请使用:\n扔漂流瓶 [-i|-v] 内容\n例如:\n扔漂流瓶 你好世界\n扔漂流瓶 -i 匿名消息";
261
+ }
259
262
  let processedContent = content || "";
260
263
  let imageBase64 = null;
261
264
  try {
@@ -325,9 +328,9 @@ ID: #${newBottle.id}
325
328
  currentPageBottles.forEach((bottle, index) => {
326
329
  const displayIndex = startIndex + index + 1;
327
330
  const timeDisplay = formatTime(bottle.created);
328
- const anonymousText = bottle.anonymous ? "(匿名)" : "";
331
+ const anonymousText = bottle.anonymous ? "匿名" : "";
329
332
  const contentPreview = getContentPreview(bottle.content, !!bottle.image, config.maxPreviewLength);
330
- output += `${displayIndex}. 漂流瓶 #${bottle.id} ${anonymousText} - ${timeDisplay}
333
+ output += `${displayIndex}. #${bottle.id} ${anonymousText} - ${timeDisplay}
331
334
  预览: ${contentPreview}
332
335
  `;
333
336
  });
@@ -375,7 +378,6 @@ ID: #${newBottle.id}
375
378
  let output = `【漂流瓶 #${bottle.id}】
376
379
  发送者:${senderDisplay}
377
380
  时间:${timeDisplay}
378
- 状态:${bottle.anonymous ? "匿名" : "公开"}
379
381
  内容:
380
382
  ${textContent}`;
381
383
  if (comments.length > 0) {
@@ -429,13 +431,13 @@ ${textContent}`;
429
431
  });
430
432
  ctx.command("漂流瓶/评论漂流瓶 <bottleId:number> <content:text>", "对指定的漂流瓶进行评论").alias("评论漂流瓶").option("invisible", "-i 匿名评论(不显示评论者)").option("visible", "-v 公开评论(显示评论者)").example("评论漂流瓶 1 这是一条评论").example("评论漂流瓶 2 -i 这是一条匿名评论").action(async ({ session, options }, bottleId, content) => {
431
433
  try {
434
+ if (!bottleId || !content) {
435
+ return "格式错误!请使用:\n评论漂流瓶 序号 评论内容\n例如:\n评论漂流瓶 1 写得真好!\n匿名评论:\n评论漂流瓶 1 -i 匿名评论";
436
+ }
432
437
  const bottles = await ctx.database.get("maple-drift-bottles", { id: bottleId });
433
438
  if (bottles.length === 0) {
434
439
  return `没有找到ID为 #${bottleId} 的漂流瓶。`;
435
440
  }
436
- if (!content || content.trim().length === 0) {
437
- return "评论内容不能为空!";
438
- }
439
441
  const trimmedContent = content.trim();
440
442
  if (trimmedContent.length > config.maxCommentLength) {
441
443
  return `评论内容太长了!最多只能输入${config.maxCommentLength}个字(当前: ${trimmedContent.length})。`;
@@ -506,13 +508,13 @@ ${textContent}`;
506
508
  author: userId
507
509
  });
508
510
  const deletedCount = userComments.length;
509
- return `已成功删除你在漂流瓶 #${bottleId} 的评论(共 ${deletedCount} 条)。`;
511
+ return `已成功删除你在漂流瓶 #${bottleId} 的评论。`;
510
512
  }
511
513
  }
512
514
  await ctx.database.remove("maple-drift-bottle-comments", {
513
515
  bottleId
514
516
  });
515
- return `已成功删除漂流瓶 #${bottleId} 的所有评论(共 ${comments.length} 条)。`;
517
+ return `已成功删除漂流瓶 #${bottleId} 的所有评论。`;
516
518
  } catch (error) {
517
519
  ctx.logger("maple-drift-bottle").error("删除漂流瓶评论时出错:", error);
518
520
  return "删除漂流瓶评论时出错了,请稍后再试。";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-maple-drift-bottle",
3
3
  "description": "-",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [