From 1fe67b16ff49634dc4a6fcfa42cc60ee9bcf5aa3 Mon Sep 17 00:00:00 2001 From: vaaski Date: Tue, 7 May 2024 13:58:02 +0200 Subject: [PATCH] use title as filename for `InputFile` --- src/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index bbf31dc..21c977b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -64,18 +64,20 @@ bot.on("message:text").on("::url", async (ctx, next) => { const [download] = info.requested_downloads ?? [] if (!download || !download.url) throw new Error("No download available") + const title = removeHashtagsMentions(info.title) + if (download.vcodec !== "none") { let video: InputFile | string if (isTiktok) { const stream = streamFromInfo(info) - video = new InputFile(stream.stdout) + video = new InputFile(stream.stdout, title) } else { - video = new InputFile({ url: download.url }) + video = new InputFile({ url: download.url }, title) } await ctx.replyWithVideo(video, { - caption: removeHashtagsMentions(info.title), + caption: title, supports_streaming: true, reply_parameters: { message_id: ctx.message?.message_id, @@ -87,7 +89,7 @@ bot.on("message:text").on("::url", async (ctx, next) => { const audio = new InputFile(stream.stdout) await ctx.replyWithAudio(audio, { - caption: removeHashtagsMentions(info.title), + caption: title, performer: info.uploader, title: info.title, thumbnail: getThumbnail(info.thumbnails),