koishi-plugin-maple-drift-bottle 0.1.2 → 0.1.4
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.js +11 -8
- 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,10 @@ 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}
|
|
333
|
+
output += `${displayIndex}. 漂流瓶 #${bottle.id} ${anonymousText}
|
|
334
|
+
${timeDisplay}
|
|
331
335
|
预览: ${contentPreview}
|
|
332
336
|
`;
|
|
333
337
|
});
|
|
@@ -375,7 +379,6 @@ ID: #${newBottle.id}
|
|
|
375
379
|
let output = `【漂流瓶 #${bottle.id}】
|
|
376
380
|
发送者:${senderDisplay}
|
|
377
381
|
时间:${timeDisplay}
|
|
378
|
-
状态:${bottle.anonymous ? "匿名" : "公开"}
|
|
379
382
|
内容:
|
|
380
383
|
${textContent}`;
|
|
381
384
|
if (comments.length > 0) {
|
|
@@ -429,13 +432,13 @@ ${textContent}`;
|
|
|
429
432
|
});
|
|
430
433
|
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
434
|
try {
|
|
435
|
+
if (!bottleId || !content) {
|
|
436
|
+
return "格式错误!请使用:\n评论漂流瓶 序号 评论内容\n例如:\n评论漂流瓶 1 写得真好!\n匿名评论:\n评论漂流瓶 1 -i 匿名评论";
|
|
437
|
+
}
|
|
432
438
|
const bottles = await ctx.database.get("maple-drift-bottles", { id: bottleId });
|
|
433
439
|
if (bottles.length === 0) {
|
|
434
440
|
return `没有找到ID为 #${bottleId} 的漂流瓶。`;
|
|
435
441
|
}
|
|
436
|
-
if (!content || content.trim().length === 0) {
|
|
437
|
-
return "评论内容不能为空!";
|
|
438
|
-
}
|
|
439
442
|
const trimmedContent = content.trim();
|
|
440
443
|
if (trimmedContent.length > config.maxCommentLength) {
|
|
441
444
|
return `评论内容太长了!最多只能输入${config.maxCommentLength}个字(当前: ${trimmedContent.length})。`;
|
|
@@ -506,13 +509,13 @@ ${textContent}`;
|
|
|
506
509
|
author: userId
|
|
507
510
|
});
|
|
508
511
|
const deletedCount = userComments.length;
|
|
509
|
-
return `已成功删除你在漂流瓶 #${bottleId}
|
|
512
|
+
return `已成功删除你在漂流瓶 #${bottleId} 的评论。`;
|
|
510
513
|
}
|
|
511
514
|
}
|
|
512
515
|
await ctx.database.remove("maple-drift-bottle-comments", {
|
|
513
516
|
bottleId
|
|
514
517
|
});
|
|
515
|
-
return `已成功删除漂流瓶 #${bottleId}
|
|
518
|
+
return `已成功删除漂流瓶 #${bottleId} 的所有评论。`;
|
|
516
519
|
} catch (error) {
|
|
517
520
|
ctx.logger("maple-drift-bottle").error("删除漂流瓶评论时出错:", error);
|
|
518
521
|
return "删除漂流瓶评论时出错了,请稍后再试。";
|