mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Added offline check for isOnWhatsApp
This commit is contained in:
@@ -3,7 +3,7 @@ import WS from 'ws'
|
||||
import * as Utils from './Utils'
|
||||
import Encoder from '../Binary/Encoder'
|
||||
import Decoder from '../Binary/Decoder'
|
||||
import fetch from 'node-fetch'
|
||||
import fetch, { RequestRedirect } from 'node-fetch'
|
||||
import {
|
||||
AuthenticationCredentials,
|
||||
WAUser,
|
||||
@@ -31,7 +31,7 @@ const logger = pino({ prettyPrint: { levelFirst: true, ignore: 'hostname', trans
|
||||
|
||||
export class WAConnection extends EventEmitter {
|
||||
/** The version of WhatsApp Web we're telling the servers we are */
|
||||
version: [number, number, number] = [2, 2045, 19]
|
||||
version: [number, number, number] = [2, 2047, 10]
|
||||
/** The Browser we're telling the WhatsApp Web servers we are */
|
||||
browserDescription: [string, string, string] = Utils.Browsers.baileys ('Chrome')
|
||||
/** Metadata like WhatsApp id, name set on WhatsApp etc. */
|
||||
@@ -406,10 +406,11 @@ export class WAConnection extends EventEmitter {
|
||||
/**
|
||||
* Does a fetch request with the configuration of the connection
|
||||
*/
|
||||
protected fetchRequest = (endpoint: string, method: string = 'GET', body?: any, agent?: Agent, headers?: {[k: string]: string}) => (
|
||||
protected fetchRequest = (endpoint: string, method: string = 'GET', body?: any, agent?: Agent, headers?: {[k: string]: string}, redirect: RequestRedirect = 'follow') => (
|
||||
fetch(endpoint, {
|
||||
method,
|
||||
body,
|
||||
redirect,
|
||||
headers: { Origin: DEFAULT_ORIGIN, ...(headers || {}) },
|
||||
agent: agent || this.connectOptions.fetchAgent
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user