koishi-plugin-best-cave 1.5.8 → 1.5.9
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 +12 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1208,10 +1208,7 @@ async function buildMessage(cave, resourceDir, session) {
|
|
|
1208
1208
|
lines.push(element.content);
|
|
1209
1209
|
} else if (element.type === "img" && element.file) {
|
|
1210
1210
|
const filePath = path5.join(resourceDir, element.file);
|
|
1211
|
-
|
|
1212
|
-
if (base64Data) {
|
|
1213
|
-
lines.push((0, import_koishi5.h)("image", { src: base64Data }));
|
|
1214
|
-
}
|
|
1211
|
+
lines.push(import_koishi5.h.image(filePath));
|
|
1215
1212
|
}
|
|
1216
1213
|
}
|
|
1217
1214
|
lines.push(session.text("commands.cave.message.contributorSuffix", [cave.contributor_name]));
|
|
@@ -1237,9 +1234,17 @@ async function sendMessage(session, key, params = [], isTemp = true, timeout = 1
|
|
|
1237
1234
|
}
|
|
1238
1235
|
__name(sendMessage, "sendMessage");
|
|
1239
1236
|
async function processMediaFile(filePath, type) {
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1237
|
+
try {
|
|
1238
|
+
await fs5.promises.access(filePath);
|
|
1239
|
+
if (type === "image") {
|
|
1240
|
+
return filePath;
|
|
1241
|
+
} else {
|
|
1242
|
+
const data = await fs5.promises.readFile(filePath);
|
|
1243
|
+
return `data:${type}/mp4;base64,${data.toString("base64")}`;
|
|
1244
|
+
}
|
|
1245
|
+
} catch {
|
|
1246
|
+
return null;
|
|
1247
|
+
}
|
|
1243
1248
|
}
|
|
1244
1249
|
__name(processMediaFile, "processMediaFile");
|
|
1245
1250
|
async function extractMediaContent(originalContent, config, session) {
|