Closed ianmsfvenom closed 2 years ago
This is a little fast example:
bot.onText(/\/download/, async (msg) => {
// Check if the user reply to a message
if (msg.reply_to_message) {
if (msg.reply_to_message.photo) {
// Get the photo file_id
let photoId = msg.reply_to_message.photo[msg.reply_to_message.photo.length - 1].file_id
// Download the photo (file_id, folder path)
bot.downloadFile(photoId, "./download/")
}
else if (msg.reply_to_message.sticker) {
// Get the sticker file_id
let stickerId = msg.reply_to_message.sticker.file_id
// Get the sticker file
bot.downloadFile(stickerId, "./download/")
}
else if (msg.reply_to_message.video) {
// Get the video file_id
let videoId = msg.reply_to_message.video.file_id
// Download the video
bot.downloadFile(videoId, "./download/")
}
else if (msg.reply_to_message.audio) {
// Get the audio file_id
let audioId = msg.reply_to_message.audio.file_id
// Download the audio
bot.downloadFile(audioId, "./download/")
}
else if (msg.reply_to_message.voice) {
// Get the voiceId file_id
let voiceId = msg.reply_to_message.voice.file_id
// Get the voice file
bot.downloadFile(voiceId, "./download/")
}
else if (msg.reply_to_message.document) {
// Get the document file_id
let documentId = msg.reply_to_message.document.file_id
// Get the document file
bot.downloadFile(documentId, "./download/")
}
} else {
bot.sendMessage(msg.chat.id, "Reply to a message to download it")
}
})
I'm trying to make a command that when I reply to an image with it, I want the bot to download the answered image. I'm new to this telegram bot api and only know the basic commands