feat: add WA Web version auto fetch

This commit is contained in:
Adhiraj Singh
2022-02-20 19:43:15 +05:30
parent 7c5071d8d5
commit 75582e4541
3 changed files with 39 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
import { Boom } from '@hapi/boom'
import P from 'pino'
import makeWASocket, { AnyMessageContent, delay, DisconnectReason, makeInMemoryStore, useSingleFileAuthState } from '../src'
import makeWASocket, { AnyMessageContent, delay, DisconnectReason, fetchLatestBaileysVersion, makeInMemoryStore, useSingleFileAuthState } from '../src'
// the store maintains the data of the WA connection in memory
// can be written out to a file & read from it
@@ -14,9 +14,13 @@ setInterval(() => {
const { state, saveState } = useSingleFileAuthState('./auth_info_multi.json')
// start a connection
const startSock = () => {
const startSock = async() => {
// fetch latest version of WA Web
const { version, isLatest } = await fetchLatestBaileysVersion()
console.log(`using WA v${version.join('.')}, isLatest: ${isLatest}`)
const sock = makeWASocket({
version,
logger: P({ level: 'trace' }),
printQRInTerminal: true,
auth: state,