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,
|
||||
defaultQueryTimeoutMs,
|
||||
syncFullHistory,
|
||||
transactionOpts
|
||||
transactionOpts,
|
||||
qrTimeout
|
||||
}: SocketConfig) => {
|
||||
const ws = new WebSocket(waWebSocketUrl, undefined, {
|
||||
origin: DEFAULT_ORIGIN,
|
||||
@@ -450,7 +451,7 @@ export const makeSocket = ({
|
||||
const identityKeyB64 = Buffer.from(creds.signedIdentityKey.public).toString('base64')
|
||||
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 = () => {
|
||||
if(ws.readyState !== ws.OPEN) {
|
||||
return
|
||||
@@ -468,7 +469,7 @@ export const makeSocket = ({
|
||||
ev.emit('connection.update', { qr })
|
||||
|
||||
qrTimer = setTimeout(genPairQR, qrMs)
|
||||
qrMs = 20_000 // shorter subsequent qrs
|
||||
qrMs = qrTimeout || 20_000 // shorter subsequent qrs
|
||||
}
|
||||
|
||||
genPairQR()
|
||||
@@ -572,4 +573,4 @@ export const makeSocket = ({
|
||||
}
|
||||
}
|
||||
|
||||
export type Socket = ReturnType<typeof makeSocket>
|
||||
export type Socket = ReturnType<typeof makeSocket>
|
||||
|
||||
@@ -37,4 +37,6 @@ export type CommonSocketConfig = {
|
||||
customUploadHosts: MediaConnInfo['hosts']
|
||||
/** time to wait between sending new retry requests */
|
||||
retryRequestDelayMs: number
|
||||
/** time to wait for the generation of the next QR in ms */
|
||||
qrTimeout?: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user