mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
added experimental always use takeover
This commit is contained in:
@@ -48,7 +48,8 @@ export class WAConnection extends EventEmitter {
|
||||
waitForChats: true,
|
||||
maxRetries: 5,
|
||||
connectCooldownMs: 3000,
|
||||
phoneResponseTime: 7500
|
||||
phoneResponseTime: 7500,
|
||||
alwaysUseTakeover: false
|
||||
}
|
||||
/** When to auto-reconnect */
|
||||
autoReconnect = ReconnectMode.onConnectionLost
|
||||
|
||||
@@ -79,7 +79,7 @@ export class WAConnection extends Base {
|
||||
// determine whether reconnect should be used or not
|
||||
const shouldUseReconnect = (this.lastDisconnectReason === DisconnectReason.close ||
|
||||
this.lastDisconnectReason === DisconnectReason.lost) &&
|
||||
this.user?.jid
|
||||
!this.connectOptions.alwaysUseTakeover
|
||||
const reconnectID = shouldUseReconnect && this.user.jid.replace ('@s.whatsapp.net', '@c.us')
|
||||
|
||||
this.conn = new WS(WS_URL, null, {
|
||||
|
||||
@@ -88,6 +88,8 @@ export type WAConnectOptions = {
|
||||
agent?: Agent
|
||||
/** agent used for fetch requests -- uploading/downloading media */
|
||||
fetchAgent?: Agent
|
||||
/** Always uses takeover for connections */
|
||||
alwaysUseTakeover?: boolean
|
||||
}
|
||||
/** 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
|
||||
|
||||
Reference in New Issue
Block a user