From 64189d2d6784b9dd182d4b37488bcf4fa6d78059 Mon Sep 17 00:00:00 2001 From: Pedro Lopez Date: Sun, 1 Aug 2021 23:59:56 -0400 Subject: [PATCH] chore: mark version v1.14.0 --- docs/Base.html | 6 +- docs/BusinessContact.html | 6 +- docs/Call.html | 159 +++++++++++++++++++ docs/Chat.html | 6 +- docs/Client.html | 172 ++++++++++++++++++++- docs/Client.js.html | 39 ++++- docs/ClientInfo.html | 6 +- docs/Contact.html | 6 +- docs/GroupChat.html | 6 +- docs/GroupNotification.html | 6 +- docs/InterfaceController.html | 6 +- docs/Label.html | 6 +- docs/Location.html | 6 +- docs/Message.html | 23 ++- docs/MessageMedia.html | 134 +++++++++++++++- docs/Order.html | 6 +- docs/PrivateChat.html | 6 +- docs/PrivateContact.html | 6 +- docs/Product.html | 6 +- docs/Util.html | 6 +- docs/global.html | 19 ++- docs/index.html | 180 ++++++++++++++++++---- docs/scripts/jsdoc-toc.js | 2 +- docs/structures_Base.js.html | 6 +- docs/structures_BusinessContact.js.html | 6 +- docs/structures_Call.js.html | 121 +++++++++++++++ docs/structures_Chat.js.html | 6 +- docs/structures_ClientInfo.js.html | 6 +- docs/structures_Contact.js.html | 6 +- docs/structures_GroupChat.js.html | 6 +- docs/structures_GroupNotification.js.html | 6 +- docs/structures_Label.js.html | 6 +- docs/structures_Location.js.html | 6 +- docs/structures_Message.js.html | 64 +++++--- docs/structures_MessageMedia.js.html | 58 ++++++- docs/structures_Order.js.html | 6 +- docs/structures_PrivateChat.js.html | 6 +- docs/structures_PrivateContact.js.html | 6 +- docs/structures_Product.js.html | 6 +- docs/structures_ProductMetadata.js.html | 6 +- docs/util_Constants.js.html | 9 +- docs/util_InterfaceController.js.html | 6 +- docs/util_Util.js.html | 10 +- package.json | 2 +- 44 files changed, 985 insertions(+), 187 deletions(-) create mode 100644 docs/Call.html create mode 100644 docs/structures_Call.js.html diff --git a/docs/Base.html b/docs/Base.html index 891064e..3caea4a 100644 --- a/docs/Base.html +++ b/docs/Base.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: Base + whatsapp-web.js 1.14.0 » Class: Base @@ -15,7 +15,7 @@ @@ -50,7 +50,7 @@ diff --git a/docs/BusinessContact.html b/docs/BusinessContact.html index f8193a0..b216187 100644 --- a/docs/BusinessContact.html +++ b/docs/BusinessContact.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: BusinessContact + whatsapp-web.js 1.14.0 » Class: BusinessContact @@ -15,7 +15,7 @@ @@ -290,7 +290,7 @@ diff --git a/docs/Call.html b/docs/Call.html new file mode 100644 index 0000000..97c5991 --- /dev/null +++ b/docs/Call.html @@ -0,0 +1,159 @@ + + + + + + + whatsapp-web.js 1.14.0 » Class: Call + + + + + + + + +
+
+
+
+ +
+
+

Properties

+
+
+
+
canHandleLocally
+
+
+
from
+
+
+
fromMe
+
+
+
+
+
+
+
id
+
+
+
isGroup
+
+
+
isVideo
+
+
+
+
+
+
+
participants
+
+
+
timestamp
+
+
+
webClientShouldHandle
+
+
+
+
+
+
+
+
+

new Call()

+
+
Extends
+
Base
+
+
+
+

Properties

+
+

canHandleLocally +  boolean

+

Indicates if the call can be handled in waweb

+
+
+

from +  string

+

From

+
+
+

fromMe +  boolean

+

Indicates if the call was sent by the current user

+
+
+

id +  string

+

Call ID

+
+
+

isGroup +  boolean

+

Is Group

+
+
+

isVideo +  boolean

+

Is video

+
+
+

participants +  object

+

Object with participants

+
+
+

timestamp +  number

+

Unix timestamp for when the call was created

+
+
+

webClientShouldHandle +  boolean

+

Indicates if the call Should be handled in waweb

+
+
+
+
+
+
+ +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/docs/Chat.html b/docs/Chat.html index 44ff97d..4a7bb01 100644 --- a/docs/Chat.html +++ b/docs/Chat.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: Chat + whatsapp-web.js 1.14.0 » Class: Chat @@ -15,7 +15,7 @@ @@ -477,7 +477,7 @@ diff --git a/docs/Client.html b/docs/Client.html index 5fb7471..a942cbd 100644 --- a/docs/Client.html +++ b/docs/Client.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: Client + whatsapp-web.js 1.14.0 » Class: Client @@ -15,7 +15,7 @@ @@ -202,6 +202,9 @@
group_update
+
incoming_call
+
+
media_uploaded
@@ -211,13 +214,13 @@
message_ack
-
message_create
-
-
+
message_create
+
+
message_revoke_everyone
@@ -1863,6 +1866,163 @@
+

incoming_call

+

Emitted when a call is received

+
+

Parameters

+ + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

call

+
+

object

+
+

 

+
+

Values in call have the following properties:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

id

+
+

number

+
+

 

+
+

Call id

+
+

peerJid

+
+

string

+
+

 

+
+

Who called

+
+

isVideo

+
+

boolean

+
+

 

+
+

if is video

+
+

isGroup

+
+

boolean

+
+

 

+
+

if is group

+
+

canHandleLocally

+
+

boolean

+
+

 

+
+

if we can handle in waweb

+
+

outgoing

+
+

boolean

+
+

 

+
+

if is outgoing

+
+

webClientShouldHandle

+
+

boolean

+
+

 

+
+

If Waweb should handle

+
+

participants

+
+

object

+
+

 

+
+

Participants

+
+
+
+
+

media_uploaded

Emitted when media has been uploaded for a message sent by the client.

@@ -2138,7 +2298,7 @@
diff --git a/docs/Client.js.html b/docs/Client.js.html index c75ce40..9d94c8c 100644 --- a/docs/Client.js.html +++ b/docs/Client.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: Client.js + whatsapp-web.js 1.14.0 » Source: Client.js @@ -15,7 +15,7 @@ @@ -42,7 +42,7 @@ const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./ut const { ExposeStore, LoadUtils } = require('./util/Injected'); const ChatFactory = require('./factories/ChatFactory'); const ContactFactory = require('./factories/ContactFactory'); -const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label } = require('./structures'); +const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label, Call } = require('./structures'); /** * Starting point for interacting with the WhatsApp Web API * @extends {EventEmitter} @@ -96,8 +96,16 @@ class Client extends EventEmitter { * Sets up events and requirements, kicks off authentication request */ async initialize() { - const browser = await puppeteer.launch(this.options.puppeteer); - const page = (await browser.pages())[0]; + let [browser, page] = [null, null]; + + if(this.options.puppeteer && this.options.puppeteer.browserWSEndpoint) { + browser = await puppeteer.connect(this.options.puppeteer); + page = await browser.newPage(); + } else { + browser = await puppeteer.launch(this.options.puppeteer); + page = (await browser.pages())[0]; + } + page.setUserAgent(this.options.userAgent); this.pupBrowser = browser; @@ -393,6 +401,24 @@ class Client extends EventEmitter { this.emit(Events.BATTERY_CHANGED, { battery, plugged }); }); + await page.exposeFunction('onIncomingCall', (call) => { + /** + * Emitted when a call is received + * @event Client#incoming_call + * @param {object} call + * @param {number} call.id - Call id + * @param {string} call.peerJid - Who called + * @param {boolean} call.isVideo - if is video + * @param {boolean} call.isGroup - if is group + * @param {boolean} call.canHandleLocally - if we can handle in waweb + * @param {boolean} call.outgoing - if is outgoing + * @param {boolean} call.webClientShouldHandle - If Waweb should handle + * @param {object} call.participants - Participants + */ + const cll = new Call(this,call); + this.emit(Events.INCOMING_CALL, cll); + }); + await page.evaluate(() => { window.Store.Msg.on('add', (msg) => { if (msg.isNewMsg) window.onAddMessageEvent(window.WWebJS.getMessageModel(msg)); }); window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); }); @@ -402,6 +428,7 @@ class Client extends EventEmitter { window.Store.Msg.on('remove', (msg) => { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); }); window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); }); window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); }); + window.Store.Call.on('add', (call) => { window.onIncomingCall(call); }); }); /** @@ -948,7 +975,7 @@ module.exports = Client;
diff --git a/docs/ClientInfo.html b/docs/ClientInfo.html index 3b54696..bff2ce8 100644 --- a/docs/ClientInfo.html +++ b/docs/ClientInfo.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: ClientInfo + whatsapp-web.js 1.14.0 » Class: ClientInfo @@ -15,7 +15,7 @@ @@ -235,7 +235,7 @@
diff --git a/docs/Contact.html b/docs/Contact.html index 1be9a16..6ecdbc4 100644 --- a/docs/Contact.html +++ b/docs/Contact.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: Contact + whatsapp-web.js 1.14.0 » Class: Contact @@ -15,7 +15,7 @@ @@ -257,7 +257,7 @@
diff --git a/docs/GroupChat.html b/docs/GroupChat.html index f010875..474fdf5 100644 --- a/docs/GroupChat.html +++ b/docs/GroupChat.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: GroupChat + whatsapp-web.js 1.14.0 » Class: GroupChat @@ -15,7 +15,7 @@ @@ -916,7 +916,7 @@
diff --git a/docs/GroupNotification.html b/docs/GroupNotification.html index deae6eb..ce15d47 100644 --- a/docs/GroupNotification.html +++ b/docs/GroupNotification.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: GroupNotification + whatsapp-web.js 1.14.0 » Class: GroupNotification @@ -15,7 +15,7 @@ @@ -233,7 +233,7 @@
diff --git a/docs/InterfaceController.html b/docs/InterfaceController.html index d80d2a4..1f00d0d 100644 --- a/docs/InterfaceController.html +++ b/docs/InterfaceController.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: InterfaceController + whatsapp-web.js 1.14.0 » Class: InterfaceController @@ -15,7 +15,7 @@ @@ -382,7 +382,7 @@
diff --git a/docs/Label.html b/docs/Label.html index 09dd3e6..194cec2 100644 --- a/docs/Label.html +++ b/docs/Label.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: Label + whatsapp-web.js 1.14.0 » Class: Label @@ -15,7 +15,7 @@ @@ -163,7 +163,7 @@
diff --git a/docs/Location.html b/docs/Location.html index 2de35df..428f09d 100644 --- a/docs/Location.html +++ b/docs/Location.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: Location + whatsapp-web.js 1.14.0 » Class: Location @@ -15,7 +15,7 @@ @@ -149,7 +149,7 @@
diff --git a/docs/Message.html b/docs/Message.html index 3d2ca26..fe43662 100644 --- a/docs/Message.html +++ b/docs/Message.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: Message + whatsapp-web.js 1.14.0 » Class: Message @@ -15,7 +15,7 @@ @@ -54,6 +54,9 @@
deviceType
+
forwardingScore
+
+
from
@@ -91,13 +94,13 @@
location
+
mediaKey
+
+
-
mediaKey
-
-
mentionedIds
@@ -215,6 +218,12 @@

String that represents from which device type the message was sent

+

forwardingScore +  number

+

Indicates how many times the message was forwarded.

+

The maximum value is 127.

+
+

from  string

ID for the Chat that this message was sent to, except if the message was sent by the current user.

@@ -261,7 +270,7 @@
+  Array of {link: string, isSuspicious: boolean}

Links included in the message.

@@ -543,7 +552,7 @@
diff --git a/docs/MessageMedia.html b/docs/MessageMedia.html index 7b6f13b..7390317 100644 --- a/docs/MessageMedia.html +++ b/docs/MessageMedia.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: MessageMedia + whatsapp-web.js 1.14.0 » Class: MessageMedia @@ -15,7 +15,7 @@ @@ -26,7 +26,7 @@
-

Method

+

Methods

@@ -71,6 +71,11 @@
@@ -159,7 +164,7 @@
-

Method

+

Methods

static

fromFilePath(filePath) → MessageMedia

@@ -198,6 +203,123 @@

MessageMedia 

+
async static
+

fromUrl(url[, options]) → Promise containing MessageMedia

+

Creates a MessageMedia instance from a URL

+
+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

url

+
+

string

+
+

 

+
+
+

options

+
+

Object

+
+

Yes

+
+

Values in options have the following properties:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeOptionalDescription
+

unsafeMime

+
+

number

+
+

Yes

+
+

Defaults to false.

+
+

client

+
+

object

+
+

Yes

+
+
+

reqOptions

+
+

object

+
+

Yes

+
+
+

reqOptions.size

+
+

number

+
+

Yes

+
+

Defaults to 0.

+
+
+
+
+
Returns
+
+

Promise containing MessageMedia 

+
+
@@ -208,7 +330,7 @@
diff --git a/docs/Order.html b/docs/Order.html index 08445ca..f26238b 100644 --- a/docs/Order.html +++ b/docs/Order.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: Order + whatsapp-web.js 1.14.0 » Class: Order @@ -15,7 +15,7 @@ @@ -102,7 +102,7 @@
diff --git a/docs/PrivateChat.html b/docs/PrivateChat.html index d4cf73c..47d668e 100644 --- a/docs/PrivateChat.html +++ b/docs/PrivateChat.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: PrivateChat + whatsapp-web.js 1.14.0 » Class: PrivateChat @@ -15,7 +15,7 @@ @@ -519,7 +519,7 @@
diff --git a/docs/PrivateContact.html b/docs/PrivateContact.html index 6f10e75..e165910 100644 --- a/docs/PrivateContact.html +++ b/docs/PrivateContact.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: PrivateContact + whatsapp-web.js 1.14.0 » Class: PrivateContact @@ -15,7 +15,7 @@ @@ -283,7 +283,7 @@
diff --git a/docs/Product.html b/docs/Product.html index e627fa6..127063e 100644 --- a/docs/Product.html +++ b/docs/Product.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: Product + whatsapp-web.js 1.14.0 » Class: Product @@ -15,7 +15,7 @@ @@ -127,7 +127,7 @@
diff --git a/docs/Util.html b/docs/Util.html index aa4f64e..9b3f7aa 100644 --- a/docs/Util.html +++ b/docs/Util.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Class: Util + whatsapp-web.js 1.14.0 » Class: Util @@ -15,7 +15,7 @@ @@ -240,7 +240,7 @@
diff --git a/docs/global.html b/docs/global.html index efc2b00..810074b 100644 --- a/docs/global.html +++ b/docs/global.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Globals + whatsapp-web.js 1.14.0 » Globals @@ -15,7 +15,7 @@ @@ -383,6 +383,19 @@ + + +

INCOMING_CALL

+ + +

 

+ + +

 

+ + + + @@ -1595,7 +1608,7 @@
diff --git a/docs/index.html b/docs/index.html index 6457bdd..0b5d9bf 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Home + whatsapp-web.js 1.14.0 » Home @@ -15,7 +15,7 @@ @@ -27,20 +27,21 @@
-

npm Depfu WhatsApp_Web 2.2126.10 Discord Chat

+

npm Depfu WhatsApp_Web 2.2126.14 Discord Chat

whatsapp-web.js

A WhatsApp API client that connects through the WhatsApp Web browser app

It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocked.

NOTE: I can't guarantee you will not be blocked by using this method, although it has worked for me. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.

Installation

The module is now available on npm! npm i whatsapp-web.js

-

Please note that Node v14+ is required.

+

Please note that Node v12+ is required.

Example usage

const { Client } = require('whatsapp-web.js');
+
 const client = new Client();
 
 client.on('qr', (qr) => {
@@ -60,6 +61,33 @@ client.on('message', msg => {
 
 client.initialize();
 
+

Remote Access

+

You could also connect to any previously existing browser instance:

+
const client = new Client({ 
+    puppeteer: {
+        browserWSEndpoint: `ws://localhost:3000`
+    }
+});
+
+

Docker

+
    +
  1. Installing a browser using browserless:
  2. +
+
docker run \
+  --rm \
+  -p 3000:3000 \
+  -e "MAX_CONCURRENT_SESSIONS=1" \
+  browserless/chrome:latest
+
+

Reference: https://docs.browserless.io/docs/docker-quickstart.html

+

Remote Debugging

+
    +
  1. Running a browser with websocket remote debugging enabled:
  2. +
+
+

chrome.exe --remote-debugging-port=9222

+
+

After that check the following webpage and check http://127.0.0.1:9220/json and get the webSocketDebuggerUrl

Take a look at example.js for another example with more use cases.

Supported features

@@ -84,7 +112,7 @@ client.initialize(); - + @@ -167,9 +195,10 @@ client.initialize();

Something missing? Make an issue and let us know!

Links

Contributing

Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.

@@ -333,6 +362,75 @@ client.initialize(); +
+
+

Call

+
+
+
+
+ Call() +
+
+
+
+ Call#canHandleLocally +
+
+
+
+ Call#from +
+
+
+
+ Call#fromMe +
+
+
+
+
+
+
+
+ Call#id +
+
+
+
+ Call#isGroup +
+
+
+
+ Call#isVideo +
+
+
+
+ Call#participants +
+
+
+
+
+
+
+
+ Call#timestamp +
+
+
+
+ Call#webClientShouldHandle +
+
+
+
+
+
+
+

Chat

@@ -602,6 +700,11 @@ client.initialize();
+
+ Client#event:incoming_call +
+
+
Client#event:media_uploaded
@@ -617,15 +720,15 @@ client.initialize();
+ +
+ -
-
Client#event:message_revoke_everyone
@@ -711,15 +814,15 @@ client.initialize();
+
+
+
+
Client#info
-
-
-
-
Client#initialize()
@@ -1018,6 +1121,11 @@ client.initialize();
+
+ Events.INCOMING_CALL +
+
+
Events.MEDIA_UPLOADED
@@ -1038,15 +1146,15 @@ client.initialize();
+
+
+ -
-
Events.MESSAGE_REVOKED_ME
@@ -1662,6 +1770,11 @@ client.initialize();
+
+ Message#forwardingScore +
+
+
Message#from
@@ -1672,15 +1785,15 @@ client.initialize();
+
+
+ -
-
Message#getContact()
@@ -1741,15 +1854,15 @@ client.initialize();
+
+
+ -
-
Message#location
@@ -1885,12 +1998,12 @@ client.initialize();
+
+ MessageMedia#filename +
+
+
MessageMedia#mimetype
@@ -2583,7 +2701,7 @@ client.initialize();
diff --git a/docs/scripts/jsdoc-toc.js b/docs/scripts/jsdoc-toc.js index ccd404e..a57fd14 100644 --- a/docs/scripts/jsdoc-toc.js +++ b/docs/scripts/jsdoc-toc.js @@ -6,7 +6,7 @@ treeNode.tree({ autoEscape: false, closedIcon: '⇢', - data: [{"label":"Globals","id":"global","children":[]},{"label":"Base","id":"Base","children":[]},{"label":"BusinessContact","id":"BusinessContact","children":[]},{"label":"Chat","id":"Chat","children":[]},{"label":"Client","id":"Client","children":[]},{"label":"ClientInfo","id":"ClientInfo","children":[]},{"label":"Contact","id":"Contact","children":[]},{"label":"GroupChat","id":"GroupChat","children":[]},{"label":"GroupNotification","id":"GroupNotification","children":[]},{"label":"InterfaceController","id":"InterfaceController","children":[]},{"label":"Label","id":"Label","children":[]},{"label":"Location","id":"Location","children":[]},{"label":"Message","id":"Message","children":[]},{"label":"MessageMedia","id":"MessageMedia","children":[]},{"label":"Order","id":"Order","children":[]},{"label":"PrivateChat","id":"PrivateChat","children":[]},{"label":"PrivateContact","id":"PrivateContact","children":[]},{"label":"Product","id":"Product","children":[]},{"label":"Util","id":"Util","children":[]}], + data: [{"label":"Globals","id":"global","children":[]},{"label":"Base","id":"Base","children":[]},{"label":"BusinessContact","id":"BusinessContact","children":[]},{"label":"Call","id":"Call","children":[]},{"label":"Chat","id":"Chat","children":[]},{"label":"Client","id":"Client","children":[]},{"label":"ClientInfo","id":"ClientInfo","children":[]},{"label":"Contact","id":"Contact","children":[]},{"label":"GroupChat","id":"GroupChat","children":[]},{"label":"GroupNotification","id":"GroupNotification","children":[]},{"label":"InterfaceController","id":"InterfaceController","children":[]},{"label":"Label","id":"Label","children":[]},{"label":"Location","id":"Location","children":[]},{"label":"Message","id":"Message","children":[]},{"label":"MessageMedia","id":"MessageMedia","children":[]},{"label":"Order","id":"Order","children":[]},{"label":"PrivateChat","id":"PrivateChat","children":[]},{"label":"PrivateContact","id":"PrivateContact","children":[]},{"label":"Product","id":"Product","children":[]},{"label":"Util","id":"Util","children":[]}], openedIcon: ' ⇣', saveState: false, useContextMenu: false diff --git a/docs/structures_Base.js.html b/docs/structures_Base.js.html index 539138f..5f75686 100644 --- a/docs/structures_Base.js.html +++ b/docs/structures_Base.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/Base.js + whatsapp-web.js 1.14.0 » Source: structures/Base.js @@ -15,7 +15,7 @@ @@ -60,7 +60,7 @@ module.exports = Base;
diff --git a/docs/structures_BusinessContact.js.html b/docs/structures_BusinessContact.js.html index d423ea7..fa62abf 100644 --- a/docs/structures_BusinessContact.js.html +++ b/docs/structures_BusinessContact.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/BusinessContact.js + whatsapp-web.js 1.14.0 » Source: structures/BusinessContact.js @@ -15,7 +15,7 @@ @@ -59,7 +59,7 @@ module.exports = BusinessContact;
diff --git a/docs/structures_Call.js.html b/docs/structures_Call.js.html new file mode 100644 index 0000000..ce9905b --- /dev/null +++ b/docs/structures_Call.js.html @@ -0,0 +1,121 @@ + + + + + + + whatsapp-web.js 1.14.0 » Source: structures/Call.js + + + + + + + + +
+
+
+ +
+ +
+
'use strict';
+
+const Base = require('./Base');
+
+/**
+ * Represents a Call on WhatsApp
+ * @extends {Base}
+ */
+class Call extends Base {
+    constructor(client, data) {
+        super(client);
+
+        if (data) this._patch(data);
+    }
+
+    _patch(data) {
+        /**
+         * Call ID
+         * @type {string}
+         */
+        this.id = data.id;
+        /**
+         * From
+         * @type {string}
+         */
+        this.from = data.peerJid;
+        /**
+         * Unix timestamp for when the call was created
+         * @type {number}
+         */
+        this.timestamp = data.offerTime;
+        /**
+         * Is video
+         * @type {boolean}
+         */
+        this.isVideo = data.isVideo;
+        /**
+         * Is Group
+         * @type {boolean}
+         */
+        this.isGroup = data.isGroup;
+        /**
+         * Indicates if the call was sent by the current user
+         * @type {boolean}
+         */
+        this.fromMe = data.outgoing;
+        /**
+         * Indicates if the call can be handled in waweb
+         * @type {boolean}
+         */
+        this.canHandleLocally = data.canHandleLocally;
+        /**
+         * Indicates if the call Should be handled in waweb
+         * @type {boolean}
+         */
+        this.webClientShouldHandle = data.webClientShouldHandle;
+        /**
+         * Object with participants
+         * @type {object}
+         */
+        this.participants = data.participants;
+        
+        return super._patch(data);
+    }
+    
+}
+
+module.exports = Call;
+
+
+
+ +
+
+
+ +
+ + + + + + + + + \ No newline at end of file diff --git a/docs/structures_Chat.js.html b/docs/structures_Chat.js.html index f072df6..34ad66e 100644 --- a/docs/structures_Chat.js.html +++ b/docs/structures_Chat.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/Chat.js + whatsapp-web.js 1.14.0 » Source: structures/Chat.js @@ -15,7 +15,7 @@ @@ -288,7 +288,7 @@ module.exports = Chat;
diff --git a/docs/structures_ClientInfo.js.html b/docs/structures_ClientInfo.js.html index 024ac67..5319b14 100644 --- a/docs/structures_ClientInfo.js.html +++ b/docs/structures_ClientInfo.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/ClientInfo.js + whatsapp-web.js 1.14.0 » Source: structures/ClientInfo.js @@ -15,7 +15,7 @@ @@ -108,7 +108,7 @@ module.exports = ClientInfo;
diff --git a/docs/structures_Contact.js.html b/docs/structures_Contact.js.html index 39c338a..aa01623 100644 --- a/docs/structures_Contact.js.html +++ b/docs/structures_Contact.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/Contact.js + whatsapp-web.js 1.14.0 » Source: structures/Contact.js @@ -15,7 +15,7 @@ @@ -219,7 +219,7 @@ module.exports = Contact;
diff --git a/docs/structures_GroupChat.js.html b/docs/structures_GroupChat.js.html index 8d51a80..82154a5 100644 --- a/docs/structures_GroupChat.js.html +++ b/docs/structures_GroupChat.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/GroupChat.js + whatsapp-web.js 1.14.0 » Source: structures/GroupChat.js @@ -15,7 +15,7 @@ @@ -239,7 +239,7 @@ module.exports = GroupChat;
diff --git a/docs/structures_GroupNotification.js.html b/docs/structures_GroupNotification.js.html index c6f7ab0..fa19ca3 100644 --- a/docs/structures_GroupNotification.js.html +++ b/docs/structures_GroupNotification.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/GroupNotification.js + whatsapp-web.js 1.14.0 » Source: structures/GroupNotification.js @@ -15,7 +15,7 @@ @@ -143,7 +143,7 @@ module.exports = GroupNotification;
diff --git a/docs/structures_Label.js.html b/docs/structures_Label.js.html index 73e8f7f..e4a7a1d 100644 --- a/docs/structures_Label.js.html +++ b/docs/structures_Label.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/Label.js + whatsapp-web.js 1.14.0 » Source: structures/Label.js @@ -15,7 +15,7 @@ @@ -88,7 +88,7 @@ module.exports = Label;
diff --git a/docs/structures_Location.js.html b/docs/structures_Location.js.html index ea8c985..4467d6e 100644 --- a/docs/structures_Location.js.html +++ b/docs/structures_Location.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/Location.js + whatsapp-web.js 1.14.0 » Source: structures/Location.js @@ -15,7 +15,7 @@ @@ -71,7 +71,7 @@ module.exports = Location;
diff --git a/docs/structures_Message.js.html b/docs/structures_Message.js.html index b3a5ddd..71a5d9d 100644 --- a/docs/structures_Message.js.html +++ b/docs/structures_Message.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/Message.js + whatsapp-web.js 1.14.0 » Source: structures/Message.js @@ -15,7 +15,7 @@ @@ -125,6 +125,14 @@ class Message extends Base { */ this.isForwarded = data.isForwarded; + /** + * Indicates how many times the message was forwarded. + * + * The maximum value is 127. + * @type {number} + */ + this.forwardingScore = data.forwardingScore || 0; + /** * Indicates if the message is a status update * @type {boolean} @@ -223,7 +231,8 @@ class Message extends Base { /** * Links included in the message. - * @type {Array<string>} + * @type {Array<{link: string, isSuspicious: boolean}>} + * */ this.links = data.links; @@ -335,32 +344,39 @@ class Message extends Base { if (msg.mediaData.mediaStage != 'RESOLVED') { // try to resolve media - await msg.downloadMedia(true, 1); + await msg.downloadMedia({ + downloadEvenIfExpensive: true, + rmrReason: 1 + }); } - if (msg.mediaData.mediaStage.includes('ERROR')) { + if (msg.mediaData.mediaStage.includes('ERROR') || msg.mediaData.mediaStage === 'FETCHING') { // media could not be downloaded return undefined; } - const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt({ - directPath: msg.directPath, - encFilehash: msg.encFilehash, - filehash: msg.filehash, - mediaKey: msg.mediaKey, - mediaKeyTimestamp: msg.mediaKeyTimestamp, - type: msg.type, - signal: (new AbortController).signal - }); - - const data = window.WWebJS.arrayBufferToBase64(decryptedMedia); - - return { - data, - mimetype: msg.mimetype, - filename: msg.filename - }; - + try { + const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt({ + directPath: msg.directPath, + encFilehash: msg.encFilehash, + filehash: msg.filehash, + mediaKey: msg.mediaKey, + mediaKeyTimestamp: msg.mediaKeyTimestamp, + type: msg.type, + signal: (new AbortController).signal + }); + + const data = window.WWebJS.arrayBufferToBase64(decryptedMedia); + + return { + data, + mimetype: msg.mimetype, + filename: msg.filename + }; + } catch (e) { + if(e.status && e.status === 404) return undefined; + throw e; + } }, this.id._serialized); if (!result) return undefined; @@ -466,7 +482,7 @@ module.exports = Message;
diff --git a/docs/structures_MessageMedia.js.html b/docs/structures_MessageMedia.js.html index 7cfc33b..9fc4bda 100644 --- a/docs/structures_MessageMedia.js.html +++ b/docs/structures_MessageMedia.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/MessageMedia.js + whatsapp-web.js 1.14.0 » Source: structures/MessageMedia.js @@ -15,7 +15,7 @@ @@ -34,6 +34,8 @@ const fs = require('fs'); const path = require('path'); const mime = require('mime'); +const fetch = require('node-fetch'); +const { URL } = require('url'); /** * Media attached to a message @@ -74,6 +76,56 @@ class MessageMedia { return new MessageMedia(mimetype, b64data, filename); } + + /** + * Creates a MessageMedia instance from a URL + * @param {string} url + * @param {Object} [options] + * @param {number} [options.unsafeMime=false] + * @param {object} [options.client] + * @param {object} [options.reqOptions] + * @param {number} [options.reqOptions.size=0] + * @returns {Promise<MessageMedia>} + */ + static async fromUrl(url, options = {}) { + let mimetype; + + if (!options.unsafeMime) { + const pUrl = new URL(url); + mimetype = mime.getType(pUrl.pathname); + + if (!mimetype) + throw new Error('Unable to determine MIME type'); + } + + async function fetchData (url, options) { + const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options); + const response = await fetch(url, reqOptions); + const mime = response.headers.get('Content-Type'); + let data = ''; + + if (response.buffer) { + data = (await response.buffer()).toString('base64'); + } else { + const bArray = new Uint8Array(await response.arrayBuffer()); + bArray.forEach((b) => { + data += String.fromCharCode(b); + }); + data = btoa(data); + } + + return { data, mime }; + } + + const res = options.client + ? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions)) + : (await fetchData(url, options.reqOptions)); + + if (!mimetype) + mimetype = res.mime; + + return new MessageMedia(mimetype, res.data, null); + } } module.exports = MessageMedia; @@ -86,7 +138,7 @@ module.exports = MessageMedia;
diff --git a/docs/structures_Order.js.html b/docs/structures_Order.js.html index fb993df..aeb36a4 100644 --- a/docs/structures_Order.js.html +++ b/docs/structures_Order.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/Order.js + whatsapp-web.js 1.14.0 » Source: structures/Order.js @@ -15,7 +15,7 @@ @@ -90,7 +90,7 @@ module.exports = Order;
diff --git a/docs/structures_PrivateChat.js.html b/docs/structures_PrivateChat.js.html index c79041c..1f63721 100644 --- a/docs/structures_PrivateChat.js.html +++ b/docs/structures_PrivateChat.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/PrivateChat.js + whatsapp-web.js 1.14.0 » Source: structures/PrivateChat.js @@ -15,7 +15,7 @@ @@ -51,7 +51,7 @@ module.exports = PrivateChat;
diff --git a/docs/structures_PrivateContact.js.html b/docs/structures_PrivateContact.js.html index f81a496..435c190 100644 --- a/docs/structures_PrivateContact.js.html +++ b/docs/structures_PrivateContact.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/PrivateContact.js + whatsapp-web.js 1.14.0 » Source: structures/PrivateContact.js @@ -15,7 +15,7 @@ @@ -51,7 +51,7 @@ module.exports = PrivateContact;
diff --git a/docs/structures_Product.js.html b/docs/structures_Product.js.html index 6ea5f83..0fd3bfb 100644 --- a/docs/structures_Product.js.html +++ b/docs/structures_Product.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/Product.js + whatsapp-web.js 1.14.0 » Source: structures/Product.js @@ -15,7 +15,7 @@ @@ -106,7 +106,7 @@ module.exports = Product;
diff --git a/docs/structures_ProductMetadata.js.html b/docs/structures_ProductMetadata.js.html index d089b9e..4ef90aa 100644 --- a/docs/structures_ProductMetadata.js.html +++ b/docs/structures_ProductMetadata.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: structures/ProductMetadata.js + whatsapp-web.js 1.14.0 » Source: structures/ProductMetadata.js @@ -15,7 +15,7 @@ @@ -63,7 +63,7 @@ module.exports = ProductMetadata;
diff --git a/docs/util_Constants.js.html b/docs/util_Constants.js.html index 351dc2b..8692424 100644 --- a/docs/util_Constants.js.html +++ b/docs/util_Constants.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: util/Constants.js + whatsapp-web.js 1.14.0 » Source: util/Constants.js @@ -15,7 +15,7 @@ @@ -81,7 +81,8 @@ exports.Events = { QR_RECEIVED: 'qr', DISCONNECTED: 'disconnected', STATE_CHANGED: 'change_state', - BATTERY_CHANGED: 'change_battery' + BATTERY_CHANGED: 'change_battery', + INCOMING_CALL: 'incoming_call' }; /** @@ -178,7 +179,7 @@ exports.MessageAck = {
diff --git a/docs/util_InterfaceController.js.html b/docs/util_InterfaceController.js.html index 3d9afe3..1c18ff1 100644 --- a/docs/util_InterfaceController.js.html +++ b/docs/util_InterfaceController.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: util/InterfaceController.js + whatsapp-web.js 1.14.0 » Source: util/InterfaceController.js @@ -15,7 +15,7 @@ @@ -160,7 +160,7 @@ module.exports = InterfaceController;
diff --git a/docs/util_Util.js.html b/docs/util_Util.js.html index 36072ab..9063a69 100644 --- a/docs/util_Util.js.html +++ b/docs/util_Util.js.html @@ -4,7 +4,7 @@ - whatsapp-web.js 1.13.2 » Source: util/Util.js + whatsapp-web.js 1.14.0 » Source: util/Util.js @@ -15,7 +15,7 @@ @@ -214,9 +214,9 @@ class Util { let jsonBuffer = Buffer.from(JSON.stringify(json), 'utf8'); let exif = Buffer.concat([exifAttr, jsonBuffer]); exif.writeUIntLE(jsonBuffer.length, 14, 4); - await img.loadBuffer(Buffer.from(webpMedia.data, 'base64')); + await img.load(Buffer.from(webpMedia.data, 'base64')); img.exif = exif; - webpMedia.data = (await img.saveBuffer()).toString('base64'); + webpMedia.data = (await img.save(null)).toString('base64'); } return webpMedia; @@ -242,7 +242,7 @@ module.exports = Util;
diff --git a/package.json b/package.json index e881dde..53ab1ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "whatsapp-web.js", - "version": "1.13.2", + "version": "1.14.0", "description": "Library for interacting with the WhatsApp Web API ", "main": "./index.js", "typings": "./index.d.ts",
Send media (video)(requires google chrome)(requires google chrome)
Send stickers