feat: add "--no-store" option

This commit is contained in:
Adhiraj Singh
2022-04-12 19:21:45 +05:30
parent 37178547ba
commit d399cbf810

View File

@@ -5,13 +5,15 @@ import MAIN_LOGGER from '../src/Utils/logger'
const logger = MAIN_LOGGER.child({ }) const logger = MAIN_LOGGER.child({ })
logger.level = 'trace' logger.level = 'trace'
const useStore = !process.argv.includes('--no-store')
// the store maintains the data of the WA connection in memory // the store maintains the data of the WA connection in memory
// can be written out to a file & read from it // can be written out to a file & read from it
const store = makeInMemoryStore({ logger }) const store = useStore ? makeInMemoryStore({ logger }) : undefined
store.readFromFile('./baileys_store_multi.json') store?.readFromFile('./baileys_store_multi.json')
// save every 10s // save every 10s
setInterval(() => { setInterval(() => {
store.writeToFile('./baileys_store_multi.json') store?.writeToFile('./baileys_store_multi.json')
}, 10_000) }, 10_000)
const { state, saveState } = useSingleFileAuthState('./auth_info_multi.json') const { state, saveState } = useSingleFileAuthState('./auth_info_multi.json')
@@ -35,7 +37,7 @@ const startSock = async() => {
} }
}) })
store.bind(sock.ev) store?.bind(sock.ev)
const sendMessageWTyping = async(msg: AnyMessageContent, jid: string) => { const sendMessageWTyping = async(msg: AnyMessageContent, jid: string) => {
await sock.presenceSubscribe(jid) await sock.presenceSubscribe(jid)