mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: add option to set timeout between each qr generation
This commit is contained in:
@@ -26,7 +26,8 @@ export const makeSocket = ({
|
|||||||
printQRInTerminal,
|
printQRInTerminal,
|
||||||
defaultQueryTimeoutMs,
|
defaultQueryTimeoutMs,
|
||||||
syncFullHistory,
|
syncFullHistory,
|
||||||
transactionOpts
|
transactionOpts,
|
||||||
|
qrTimeout
|
||||||
}: SocketConfig) => {
|
}: SocketConfig) => {
|
||||||
const ws = new WebSocket(waWebSocketUrl, undefined, {
|
const ws = new WebSocket(waWebSocketUrl, undefined, {
|
||||||
origin: DEFAULT_ORIGIN,
|
origin: DEFAULT_ORIGIN,
|
||||||
@@ -450,7 +451,7 @@ export const makeSocket = ({
|
|||||||
const identityKeyB64 = Buffer.from(creds.signedIdentityKey.public).toString('base64')
|
const identityKeyB64 = Buffer.from(creds.signedIdentityKey.public).toString('base64')
|
||||||
const advB64 = creds.advSecretKey
|
const advB64 = creds.advSecretKey
|
||||||
|
|
||||||
let qrMs = 60_000 // time to let a QR live
|
let qrMs = qrTimeout || 60_000 // time to let a QR live
|
||||||
const genPairQR = () => {
|
const genPairQR = () => {
|
||||||
if(ws.readyState !== ws.OPEN) {
|
if(ws.readyState !== ws.OPEN) {
|
||||||
return
|
return
|
||||||
@@ -468,7 +469,7 @@ export const makeSocket = ({
|
|||||||
ev.emit('connection.update', { qr })
|
ev.emit('connection.update', { qr })
|
||||||
|
|
||||||
qrTimer = setTimeout(genPairQR, qrMs)
|
qrTimer = setTimeout(genPairQR, qrMs)
|
||||||
qrMs = 20_000 // shorter subsequent qrs
|
qrMs = qrTimeout || 20_000 // shorter subsequent qrs
|
||||||
}
|
}
|
||||||
|
|
||||||
genPairQR()
|
genPairQR()
|
||||||
|
|||||||
@@ -37,4 +37,6 @@ export type CommonSocketConfig = {
|
|||||||
customUploadHosts: MediaConnInfo['hosts']
|
customUploadHosts: MediaConnInfo['hosts']
|
||||||
/** time to wait between sending new retry requests */
|
/** time to wait between sending new retry requests */
|
||||||
retryRequestDelayMs: number
|
retryRequestDelayMs: number
|
||||||
|
/** time to wait for the generation of the next QR in ms */
|
||||||
|
qrTimeout?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user