1623
This commit is contained in:
1 parent
310be913ef
commit
fe8c99a53e
8 files changed
+367
-157
No files matched your search
@@ -257,11 +257,17 @@ async function handleDocument(chatId: number, fileId: string, fileName?: string,
|
||||
const filename = Date.now() + "-" + fileId.slice(0, 8) + "." + ext;
|
||||
fs.writeFileSync(path.join(articleDir, filename), Buffer.from(fileBuffer));
|
||||
|
||||
// GIF 用图片语法,其他用链接
|
||||
const isImage = ["gif", "webp", "png", "jpg", "jpeg"].includes(ext.toLowerCase());
|
||||
// GIF 用图片语法,视频用 shortcode,其他用链接
|
||||
const extLower = ext.toLowerCase();
|
||||
const isImage = ["gif", "webp", "png", "jpg", "jpeg"].includes(extLower);
|
||||
const isVideo = ["mp4", "webm", "mov", "avi", "mkv", "flv"].includes(extLower);
|
||||
const fileCaption = caption || fileName || "file";
|
||||
if (isImage) {
|
||||
appendContent(chatId, `\n\n`);
|
||||
} else if (isVideo) {
|
||||
appendContent(chatId, `\n{{< video src="${filename}" caption="${fileCaption}" >}}\n`);
|
||||
await sendMessage(chatId, `🎬 视频已保存:${filename}`);
|
||||
return;
|
||||
} else {
|
||||
appendContent(chatId, `\n[${fileCaption}](${filename})\n`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user