Skip to content

Commit

Permalink
fix: baileys provider store file read and write
Browse files Browse the repository at this point in the history
  • Loading branch information
andresayac committed Mar 2, 2024
1 parent ca7c380 commit fca82e4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/provider/src/baileys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const pino = require('pino')
const rimraf = require('rimraf')
const mime = require('mime-types')
const { join } = require('path')
const { createWriteStream, readFileSync, existsSync } = require('fs')
const { createWriteStream, readFileSync } = require('fs')
const { Console } = require('console')

const {
Expand Down Expand Up @@ -62,12 +62,9 @@ class BaileysProvider extends ProviderClass {

if (this.globalVendorArgs.useBaileysStore) {
this.store = makeInMemoryStore({ loggerBaileys })
this.store.readFromFile(`${NAME_DIR_SESSION}/baileys_store.json`)
this.store?.readFromFile(`${NAME_DIR_SESSION}/baileys_store.json`)
setInterval(() => {
const path = `${NAME_DIR_SESSION}/baileys_store.json`
if (existsSync(NAME_DIR_SESSION)) {
this.store.writeToFile(path)
}
this.store?.writeToFile(`${NAME_DIR_SESSION}/baileys_store.json`)
}, 10_000)
}

Expand Down

0 comments on commit fca82e4

Please sign in to comment.