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.
@@ -130,6 +130,14 @@ client.initialize();-
+
-
+ BusinessContact#
id +
+ - +
-
BusinessContact#
isBlocked
@@ -362,6 +380,55 @@ client.initialize();
Buttons
+-
+
- + Buttons(body, buttons, title, footer) + +
- + +
-
+ Buttons#
_format(buttons) +
+ - + +
-
+
-
+ Buttons#
body +
+ - + +
-
+ Buttons#
buttons +
+ - + +
-
+
-
+ Buttons#
footer +
+ - + +
-
+ Buttons#
title +
+ - + +
Call
@@ -720,15 +787,15 @@ client.initialize();-
Client#
event:message_revoke_everyone
@@ -749,6 +816,11 @@ client.initialize();
- +
-
+ Client#
getBlockedContacts() +
+ - +
-
Client#
getChatById(chatId)
@@ -779,6 +851,16 @@ client.initialize();
- +
-
+ Client#
getCountryCode(number) +
+ - + +
-
+ Client#
getFormattedNumber(number) +
+ - +
-
Client#
getInviteInfo(inviteCode)
@@ -809,15 +891,15 @@ client.initialize();
- +
-
Client#
info
@@ -988,11 +1070,25 @@ client.initialize();
- +
-
+ Contact#
getCountryCode() +
+ - + +
-
+ Contact#
getFormattedNumber() +
+ - +
-
Contact#
getProfilePicUrl() - +
-
Contact#
id
@@ -1003,10 +1099,6 @@ client.initialize();
- -
-
Contact#
isBusiness
@@ -1032,6 +1124,10 @@ client.initialize();
- +
-
Contact#
isUser
@@ -1042,10 +1138,6 @@ client.initialize();
- -
-
Contact#
name
@@ -1675,6 +1767,60 @@ client.initialize();
List
+-
+
- + List(body, buttonText, sections, title, footer) + +
- + +
-
+ List#
_format(sections) +
+ - + +
-
+ List#
buttonText +
+ - + +
-
+
-
+ List#
description +
+ - + +
-
+ List#
footer +
+ - + +
-
+ List#
sections +
+ - + +
-
+
-
+ List#
title +
+ - + +
Location
@@ -1785,15 +1931,15 @@ client.initialize();-
Message#
getContact()
@@ -1814,6 +1960,11 @@ client.initialize();
- +
-
+ Message#
getPayment() +
+ - +
-
Message#
getQuotedMessage()
@@ -1854,15 +2005,15 @@ client.initialize();
- -
-
Message#
location
@@ -2037,6 +2188,11 @@ client.initialize();
- +
-
+ MessageTypes.
BUTTONS_RESPONSE +
+ - +
-
MessageTypes.
CONTACT_CARD
@@ -2066,6 +2222,11 @@ client.initialize();
- +
-
+ MessageTypes.
LIST +
+ - +
-
MessageTypes.
LOCATION
@@ -2077,12 +2238,12 @@ client.initialize();
-
- MessageTypes.
PRODUCT + MessageTypes.PAYMENT -
- MessageTypes.
REVOKED + MessageTypes.PRODUCT - @@ -2090,6 +2251,11 @@ client.initialize();
-
+
-
+ MessageTypes.
REVOKED +
+ - +
-
MessageTypes.
STICKER
@@ -2164,6 +2330,65 @@ client.initialize();
Payment
+-
+
-
+ Payment#
id +
+ - + +
-
+ Payment#
paymentAmount1000 +
+ - + +
-
+ Payment#
paymentCurrency +
+ - + +
-
+
-
+ Payment#
paymentMessageReceiverJid +
+ - + +
-
+ Payment#
paymentNote +
+ - + +
-
+ Payment#
paymentStatus +
+ - + +
-
+
-
+ Payment#
paymentTransactionTimestamp +
+ - + +
-
+ Payment#
paymentTxnStatus +
+ - + +
PrivateChat
@@ -2349,11 +2574,25 @@ client.initialize();-
PrivateContact#
id
@@ -2364,10 +2603,6 @@ client.initialize();
- -
-
PrivateContact#
isBusiness
@@ -2393,6 +2628,10 @@ client.initialize();
- +
-
PrivateContact#
isUser
@@ -2403,10 +2642,6 @@ client.initialize();
- -
-
PrivateContact#
name
@@ -2701,7 +2936,7 @@ client.initialize();
diff --git a/docs/scripts/jsdoc-toc.js b/docs/scripts/jsdoc-toc.js
index a57fd14..16181ee 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":"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":[]}],
+ data: [{"label":"Globals","id":"global","children":[]},{"label":"Base","id":"Base","children":[]},{"label":"BusinessContact","id":"BusinessContact","children":[]},{"label":"Buttons","id":"Buttons","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":"List","id":"List","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 f7423c2..6ce5ea3 100644
--- a/docs/structures_Base.js.html
+++ b/docs/structures_Base.js.html
@@ -4,7 +4,7 @@
-
Source: structures/Buttons.js
+'use strict';
+
+const MessageMedia = require('./MessageMedia');
+const Util = require('../util/Util');
+
+/**
+ * Message type buttons
+ */
+class Buttons {
+ /**
+ * @param {string|MessageMedia} body
+ * @param {Array<Array<string>>} buttons
+ * @param {string?} title
+ * @param {string?} footer
+ */
+ constructor(body, buttons, title, footer) {
+ /**
+ * Message body
+ * @type {string|MessageMedia}
+ */
+ this.body = body;
+
+ /**
+ * title of message
+ * @type {string}
+ */
+ this.title = title;
+
+ /**
+ * footer of message
+ * @type {string}
+ */
+ this.footer = footer;
+
+ if (body instanceof MessageMedia) {
+ this.type = 'media';
+ this.title = '';
+ }else{
+ this.type = 'chat';
+ }
+
+ /**
+ * buttons of message
+ * @type {Array<Array<string>>}
+ */
+ this.buttons = this._format(buttons);
+ if(!this.buttons.length){ throw '[BT01] No buttons';}
+
+ }
+
+ /**
+ * Creates button array from simple array
+ * @param {Array<Array<string>>} buttons
+ * @returns {Array<Array<string>>}
+ * @example
+ * Input: [{id:'customId',body:'button1'},{body:'button2'},{body:'button3'},{body:'button4'}]
+ * Returns: [{ buttonId:'customId',buttonText:{'displayText':'button1'},type: 1 },{buttonId:'n3XKsL',buttonText:{'displayText':'button2'},type:1},{buttonId:'NDJk0a',buttonText:{'displayText':'button3'},type:1}]
+ */
+ _format(buttons){
+ buttons = buttons.slice(0,3); // phone users can only see 3 buttons, so lets limit this
+ return buttons.map((btn) => {
+ return {'buttonId':btn.id ? btn.id : Util.generateHash(6),'buttonText':{'displayText':btn.body},'type':1};
+ });
+ }
+
+}
+
+module.exports = Buttons;
+ Source: structures/List.js
+'use strict';
+
+const Util = require('../util/Util');
+
+/**
+ * Message type List
+ */
+class List {
+ /**
+ * @param {string} body
+ * @param {string} buttonText
+ * @param {Array<any>} sections
+ * @param {string?} title
+ * @param {string?} footer
+ */
+ constructor(body, buttonText, sections, title, footer) {
+ /**
+ * Message body
+ * @type {string}
+ */
+ this.description = body;
+
+ /**
+ * List button text
+ * @type {string}
+ */
+ this.buttonText = buttonText;
+
+ /**
+ * title of message
+ * @type {string}
+ */
+ this.title = title;
+
+
+ /**
+ * footer of message
+ * @type {string}
+ */
+ this.footer = footer;
+
+ /**
+ * sections of message
+ * @type {Array<any>}
+ */
+ this.sections = this._format(sections);
+
+ }
+
+ /**
+ * Creates section array from simple array
+ * @param {Array<any>} sections
+ * @returns {Array<any>}
+ * @example
+ * Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
+ * Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]
+ */
+ _format(sections){
+ if(!sections.length){throw '[LT02] List without sections';}
+ if(sections.length > 1){throw '[LT05] Lists with more than one section are having problems';}
+ return sections.map( (section) =>{
+ if(!section.rows.length){throw '[LT03] Section without rows';}
+ return {
+ title: section.title ? section.title : undefined,
+ rows: section.rows.map( (row) => {
+ if(!row.title){throw '[LT04] Row without title';}
+ return {
+ rowId: row.id ? row.id : Util.generateHash(6),
+ title: row.title,
+ description: row.description ? row.description : ''
+ };
+ })
+ };
+ });
+ }
+
+}
+
+module.exports = List;
+ Source: structures/Payment.js
+const Base = require('./Base');
+
+class Payment extends Base {
+ constructor(client, data) {
+ super(client);
+
+ if (data) this._patch(data);
+ }
+
+ _patch(data) {
+ /**
+ * The payment Id
+ * @type {object}
+ */
+ this.id = data.id;
+
+ /**
+ * The payment currency
+ * @type {string}
+ */
+ this.paymentCurrency = data.paymentCurrency;
+
+ /**
+ * The payment ammount ( R$ 1.00 = 1000 )
+ * @type {number}
+ */
+ this.paymentAmount1000 = data.paymentAmount1000;
+
+ /**
+ * The payment receiver
+ * @type {object}
+ */
+ this.paymentMessageReceiverJid = data.paymentMessageReceiverJid;
+
+ /**
+ * The payment transaction timestamp
+ * @type {number}
+ */
+ this.paymentTransactionTimestamp = data.paymentTransactionTimestamp;
+
+ /**
+ * The paymentStatus
+ * @type {number}
+ *
+ * Possible Status
+ * 0:UNKNOWN_STATUS
+ * 1:PROCESSING
+ * 2:SENT
+ * 3:NEED_TO_ACCEPT
+ * 4:COMPLETE
+ * 5:COULD_NOT_COMPLETE
+ * 6:REFUNDED
+ * 7:EXPIRED
+ * 8:REJECTED
+ * 9:CANCELLED
+ * 10:WAITING_FOR_PAYER
+ * 11:WAITING
+ */
+ this.paymentStatus = data.paymentStatus;
+
+ /**
+ * Integer that represents the payment Text
+ * @type {number}
+ */
+ this.paymentTxnStatus = data.paymentTxnStatus;
+
+ /**
+ * The note sent with the payment
+ * @type {string}
+ */
+ this.paymentNote = !data.paymentNoteMsg ? undefined : data.paymentNoteMsg.body ? data.paymentNoteMsg.body : undefined ;
+
+ return super._patch(data);
+ }
+
+}
+
+module.exports = Payment;
+
+