mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Added Contact + Location Send/Receive + LiveLocation Receive
This commit is contained in:
@@ -7,7 +7,7 @@ const Utils = require('./WhatsAppWeb.Utils')
|
||||
module.exports = {
|
||||
/**
|
||||
* Connect to WhatsAppWeb
|
||||
* @param {object} [authInfo] credentials to log back in
|
||||
* @param {Object} [authInfo] credentials to log back in
|
||||
* @param {number} [timeoutMs] timeout after which the connect will fail, set to null for an infinite timeout
|
||||
* @return {promise<[object, any[], any[], any[]]>} returns [userMetaData, chats, contacts, unreadMessages]
|
||||
*/
|
||||
@@ -24,7 +24,7 @@ module.exports = {
|
||||
}
|
||||
this.conn = new WebSocket("wss://web.whatsapp.com/ws", {origin: "https://web.whatsapp.com"})
|
||||
|
||||
const promise = new Promise ( (resolve, reject) => {
|
||||
let promise = new Promise ( (resolve, reject) => {
|
||||
this.conn.on('open', () => {
|
||||
this.conn.on('message', (m) => this.onMessageRecieved(m)) // in WhatsAppWeb.Recv.js
|
||||
this.beginAuthentication ().then (resolve).catch (reject)
|
||||
@@ -34,15 +34,11 @@ module.exports = {
|
||||
reject (error)
|
||||
})
|
||||
})
|
||||
if (timeoutMs) {
|
||||
return Utils.promiseTimeout (timeoutMs, promise)
|
||||
.catch (error => {
|
||||
this.close()
|
||||
throw error
|
||||
})
|
||||
} else {
|
||||
return promise
|
||||
}
|
||||
promise = timeoutMs ? Utils.promiseTimeout (timeoutMs, promise) : promise
|
||||
return promise.catch (err => {
|
||||
this.close ()
|
||||
throw err
|
||||
})
|
||||
},
|
||||
/** once a connection has been successfully established
|
||||
* @private
|
||||
@@ -148,10 +144,6 @@ module.exports = {
|
||||
// resolve the promise
|
||||
return [this.userMetaData, chats, contacts, unreadMessages]
|
||||
})
|
||||
.catch (err => {
|
||||
this.close ()
|
||||
throw err
|
||||
})
|
||||
},
|
||||
/**
|
||||
* Once the QR code is scanned and we can validate our connection, or we resolved the challenge when logging back in
|
||||
|
||||
Reference in New Issue
Block a user