node-telegram-bot-api
node-telegram-bot-api copied to clipboard
How to use getFileStream
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