mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Rewrite for extensibility & compactness
-This is a break from previous versions unfortunately -Connecting is now a promise -Chats, contacts & previously unread messages are supplied on connection -Groups! -Message confirmations are more reliable -Timeout queries & connections
This commit is contained in:
@@ -104,7 +104,16 @@ module.exports = {
|
||||
},
|
||||
// generate a buffer with random bytes of the specified length
|
||||
randomBytes: function (length) { return Crypto.randomBytes(length) },
|
||||
|
||||
promiseTimeout: function(ms, promise) {
|
||||
// Create a promise that rejects in <ms> milliseconds
|
||||
let timeout = new Promise((_, reject) => {
|
||||
let id = setTimeout(() => {
|
||||
clearTimeout(id)
|
||||
reject('Timed out')
|
||||
}, ms)
|
||||
})
|
||||
return Promise.race([promise, timeout])
|
||||
},
|
||||
// whatsapp requires a message tag for every message, we just use the timestamp as one
|
||||
generateMessageTag: function () { return new Date().getTime().toString() },
|
||||
// generate a random 16 byte client ID
|
||||
|
||||
Reference in New Issue
Block a user