Nurutomo / wabot-aq

WhatsApp Bot
GNU General Public License v3.0
700 stars 1.38k forks source link

how to extend saving Database time #339

Closed bilal-08 closed 3 years ago

bilal-08 commented 3 years ago

https://github.com/Nurutomo/wabot-aq/blob/fe3b924cdc5bcf51d62e033add8acfd7d9d659ab/main.js#L53

in line this How can i Change the Every Minute duration to Hour or two, because when it does Saving data it takes time and Delays the Command execution so you should Make changes on that :)

Afdhan commented 3 years ago

You don't need to change the duration, if you don't want the log save database to bother you.. You can simply disable the log like this

example:

global.conn = new WAConnection()
let authFile = `${opts._[0] || 'session'}.data.json`
if (fs.existsSync(authFile)) conn.loadAuthInfo(authFile)
if (opts['trace']) conn.logger.level = 'trace'
if (opts['debug']) conn.logger.level = 'debug'
if (opts['big-qr'] || opts['server']) conn.on('qr', qr => generate(qr, { small: false }))
let lastJSON = JSON.stringify(global.DATABASE.data)
if (!opts['test']) setInterval(() => {
  /*conn.logger.info('Saving database . . .')
  if (JSON.stringify(global.DATABASE.data) == lastJSON) conn.logger.info('Database is up to date')
  else {*/
    global.DATABASE.save()
    //conn.logger.info('Done saving database!')
    lastJSON = JSON.stringify(global.DATABASE.data)
  //}
}, 60 * 1000) // Save every minute
if (opts['server']) require('./server')(global.conn, PORT)
bilal-08 commented 3 years ago

That helped me thanks^^