Skip to content

Commit

Permalink
use title as filename for InputFile
Browse files Browse the repository at this point in the history
  • Loading branch information
vaaski committed May 7, 2024
1 parent b77eba6 commit 1fe67b1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit 1fe67b1

Please sign in to comment.