Closed Arjun-M closed 2 years ago
// Let's imagine that the file id is from an image
cont fileStream = bot.getFileStream("<Id of the file>"
// Do something?
bot.sendPhoto("chat_id, fileStream)
Internally what it does is call bot.getFileLink("<Id of the file")
. When it gets that URL, it does a get to download the file and returns the file stream.
let code = 111 let newFile = JSON.parse( Bot.getFileStream(body.message.reply_to_message.document.file_id ) ) console.log (newFile) let oldFile = JSON.parse( fs.readFileSync( 'server/history/'+code+'.json' , 'utf8')) let merged = { ...newFile , ...oldFile } fs.writeFileSync( 'server/history/'+code+'.json' , JSON.stringify(merged)); return Bot.sendDocument(body.message.from.id , 'server/history/'+code+'.json' , {caption : "Updated Chat History" , parse_mode: "Markdown" } , {contentType: 'application/json' , filename: data.username+".json"})
I tried using this but fails