4.4.4 • Published 7 years ago
wareader-chat-parser v4.4.4
WhatsApp Chat Parser
A package to parse WhatsApp chat logs 💬
Install
$ npm install whatsapp-chat-parser-altor
$ yarn add whatsapp-chat-parser-altUsage
const whatsapp = require('whatsapp-chat-parser');
whatsapp
.parseString([raw whatsapp conversation])
.then(result => {
// Do whatever you want with result
})
.catch(err => {
// Something went wrong
});The result variable is an object like this:
{
messages: [
{
date: '2018-06-02T22:45:00.000Z', // Date object
author: 'Luke',
message: 'Hey how are you?',
dateString: '02-06-2018', // Computed with toLocaleDateString() using 'en-BG'
dateDay: 6,
time: '22:45', // Computed with toLocaleDateString() using 'en-BG'
isPreviousAuthor: false, // Previous author is the same as the current one,
isNextAuthor: false // Next author is the same as the current one
},
{
date: '2018-06-02T23:48:00.000Z', // Date object
author: 'Joe',
message: 'All good, thanks',
dateString: '02-06-2018', // Computed with toLocaleDateString() using 'en-BG'
dateDay: 6,
time: '23:48', // Computed with toLocaleDateString() using 'en-BG'
isPreviousAuthor: false, // Previous author is the same as the current one
isNextAuthor: false // Next author is the same as the current one
},
],
authorList: [ // 'System' user is not added to this array
'Luke',
'Joe'
],
isGroup: false
};In the case of a system message, the author will be System
[
{
date: '2018-06-02T22:45:00.000Z', // Date object
author: 'System',
message: 'You created group "Party 🎉"',
dateString: '02-06-2018', // Computed with toLocaleDateString() using 'en-BG'
dateDay: 6,
time: '22:45', // Computed with toLocaleDateString() using 'en-BG'
isPreviousAuthor: false, // Previous author is the same as the current one
isNextAuthor: false // Next author is the same as the current one
},
];API
parseString(string, options) → Promise
string
Type: string
Raw string of the WhatsApp conversation
options
Type: object
Options
| Name | Type | Default | Description |
|---|---|---|---|
| daysFirst | Boolean | undefined | Specify if your log file's date starts with a day (true) or a month (false). Manually specifying this may improve performance. By default the program will try to infer this information using 3 different methods (look at date.js for the implementation), if all fails it defaults to interpret the first digit as the day. |
Technologies used
- Testing: Jest
- Code formatting: Prettier
- Linting: ESLint (with Airbnb rules)
Requirements
Node.js >= 8.0.0