Utility for reading WhatsApp chat file
npm install wa-reader
Read and parse WhatsApp backup chat file. It will return JSON object.
var wa = require('wa-reader');
var chatFile = path.join(path.dirname(__filename), '/backup-chats.txt');
wa.read(chatFile, function(err, chats) {
chats.forEach(function(chat) {
process.stdout.write('date: ' + chat.date + "\n");
process.stdout.write('time: ' + chat.time + "\n");
process.stdout.write('sender: ' + chat.sender + "\n");
process.stdout.write('chat: ' + chat.chat + "\n");
});
});
var wa = require('wa-reader');
Parse text from WhatsApp backup chat file. It will return JSON object.
var chatFile = path.join(path.dirname(__filename), '/backup-chats.txt');
wa.parse(chatText, function(err, chats) {
chats.forEach(function(chat) {
process.stdout.write('date: ' + chat.date + "\n");
process.stdout.write('time: ' + chat.time + "\n");
process.stdout.write('sender: ' + chat.sender + "\n");
process.stdout.write('chat: ' + chat.chat + "\n");
});
});
Both read()
and parse()
function will return an array of JSON object with the following format:
[
{
date: '31/1/16',
time: '07:22',
sender: 'John Doe',
message: 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.'
}
]
If no sender property return on the object, the message is sent by system.