2.4.2 • Published 4 years ago

chatdb.js v2.4.2

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

ChatDB.js

NPM version built with typescript npm.io

A library that parses the chat.db file on Macs into a comprehensive data structure using ES6 promises.

Installation

$ npm install chatdb.js

Getting Started

// 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
}())

Examples

Simple Message Logger

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
}());

Common Problems

W.I.P.

Documentation

Constructors

Properties

Methods

Constructors

constructor

+ new Chat(path?: string): Chat

Defined in app.ts:12

Parameters:

NameType
path?string

Returns: Chat

Properties

db

db: DatabaseSqlite‹Database, Statement›

Defined in app.ts:11


json

json: Conversation[]

Defined in app.ts:12


path

path: string

Defined in app.ts:10

Methods

close

close(): Promise‹void›

Defined in app.ts:224

Returns: Promise‹void›


Private dbDateToDate

dbDateToDate(nano: number): Date

Defined in app.ts:228

Parameters:

NameType
nanonumber

Returns: Date


getConversationCount

getConversationCount(): Promise‹any›

Defined in app.ts:212

Returns: Promise‹any›


getConversations

getConversations(max?: number, reverse?: boolean): Promise‹Conversation[]›

Defined in app.ts:130

Parameters:

NameType
max?number
reverse?boolean

Returns: Promise‹Conversation[]›


getHandleCount

getHandleCount(): Promise‹any›

Defined in app.ts:216

Returns: Promise‹any›


getHandles

getHandles(max?: number, reverse?: boolean): Promise‹Handle[]›

Defined in app.ts:109

Parameters:

NameType
max?number
reverse?boolean

Returns: Promise‹Handle[]›


getMessageCount

getMessageCount(): Promise‹any›

Defined in app.ts:220

Returns: Promise‹any›


getMessages

getMessages(max?: number, reverse?: boolean): Promise‹Message[]›

Defined in app.ts:151

Parameters:

NameType
max?number
reverse?boolean

Returns: Promise‹Message[]›


init

init(): Promise‹Chat

Defined in app.ts:19

Returns: Promise‹Chat


parse

parse(): Promise‹Conversation[]›

Defined in app.ts:28

Returns: Promise‹Conversation[]›

2.4.2

4 years ago

2.4.19

4 years ago

2.4.18

4 years ago

2.4.17

4 years ago

2.4.16

4 years ago

2.4.15

4 years ago

2.4.14

4 years ago

2.4.13

4 years ago

2.4.12

4 years ago

2.3.12

4 years ago

2.3.11

4 years ago

2.2.11

4 years ago

2.2.10

4 years ago

1.2.10

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago