add max query response time + update package

This commit is contained in:
Adhiraj Singh
2021-06-16 11:59:21 +05:30
parent 1c8d7df829
commit 3607357152
3 changed files with 5 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@adiwajshing/baileys",
"version": "3.5.0",
"version": "3.5.1",
"description": "WhatsApp Web API",
"homepage": "https://github.com/adiwajshing/Baileys",
"main": "lib/index.js",

View File

@@ -46,6 +46,7 @@ export class WAConnection extends EventEmitter {
maxRetries: 10,
connectCooldownMs: 4000,
phoneResponseTime: 15_000,
maxQueryResponseTime: 10_000,
alwaysUseTakeover: true,
queryChatsTillReceived: true
}
@@ -280,7 +281,7 @@ export class WAConnection extends EventEmitter {
timeout = setTimeout(() => {
this.logger.info({ tag }, `cancelling wait for message as a response is no longer expected from the phone`)
cancel({ reason: 'Not expecting a response', status: 422 })
}, 5_000)
}, this.connectOptions.maxQueryResponseTime)
this.off('connection-phone-change', listener)
}
}

View File

@@ -134,6 +134,8 @@ export type WAConnectOptions = {
* this keeps pinging the phone to send the chats over
* */
queryChatsTillReceived?: boolean
/** max time for the phone to respond to a query */
maxQueryResponseTime?: number
}
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
export const URL_REGEX = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)?/gi