A library that parses the chat.db file on Macs into a comprehensive data structure using ES6 promises.
$ npm install chatdb.js
// Import the package
const { Chat } = require('chatdb.js');
(async function () {
// Create new instance of Chat
// and initialize it asynchronously
const chat = await new Chat('/path/to/chat.db').init();
// ... Do the thing
}())
const { Chat } = require('chatdb.js');
const fs = require('fs');
(async function() {
const chat = await new Chat().init(); // Initialize Client
const lastId = 0;
// Declare loop
async function loop() {
const msg = (await chat.getMessages(1, true))[0]; // Get the most recent message
if(msg.id != lastId) { // Check if the most recent message id changed
lastId = msg.id;
console.log(`${msg.isFromMe ? "Me" : msg.handle.name}: ${msg.text}`); // Format and log the message
}
}
setInterval(loop, 1000); // Start loop
}());
W.I.P.
- close
- dbDateToDate
- getConversationCount
- getConversations
- getHandleCount
- getHandles
- getMessageCount
- getMessages
- init
- parse
+ new Chat(path?
: string): Chat
Defined in app.ts:12
Parameters:
Name | Type |
---|---|
path? |
string |
Returns: Chat
• db: DatabaseSqlite‹Database, Statement›
Defined in app.ts:11
• json: Conversation[]
Defined in app.ts:12
• path: string
Defined in app.ts:10
▸ close(): Promise‹void›
Defined in app.ts:224
Returns: Promise‹void›
▸ dbDateToDate(nano
: number): Date
Defined in app.ts:228
Parameters:
Name | Type |
---|---|
nano |
number |
Returns: Date
▸ getConversationCount(): Promise‹any›
Defined in app.ts:212
Returns: Promise‹any›
▸ getConversations(max?
: number, reverse?
: boolean): Promise‹Conversation[]›
Defined in app.ts:130
Parameters:
Name | Type |
---|---|
max? |
number |
reverse? |
boolean |
Returns: Promise‹Conversation[]›
▸ getHandleCount(): Promise‹any›
Defined in app.ts:216
Returns: Promise‹any›
▸ getHandles(max?
: number, reverse?
: boolean): Promise‹Handle[]›
Defined in app.ts:109
Parameters:
Name | Type |
---|---|
max? |
number |
reverse? |
boolean |
Returns: Promise‹Handle[]›
▸ getMessageCount(): Promise‹any›
Defined in app.ts:220
Returns: Promise‹any›
▸ getMessages(max?
: number, reverse?
: boolean): Promise‹Message[]›
Defined in app.ts:151
Parameters:
Name | Type |
---|---|
max? |
number |
reverse? |
boolean |
Returns: Promise‹Message[]›
▸ init(): Promise‹Chat›
Defined in app.ts:19
Returns: Promise‹Chat›
▸ parse(): Promise‹Conversation[]›
Defined in app.ts:28
Returns: Promise‹Conversation[]›