whatsapp-web-sj.js 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +3 -0
- package/CODE_OF_CONDUCT.md +133 -0
- package/LICENSE +201 -0
- package/README.md +185 -0
- package/example.js +634 -0
- package/index.d.ts +1842 -0
- package/index.js +32 -0
- package/package.json +55 -0
- package/shell.js +36 -0
- package/src/Client.js +1747 -0
- package/src/authStrategies/BaseAuthStrategy.js +27 -0
- package/src/authStrategies/LocalAuth.js +56 -0
- package/src/authStrategies/NoAuth.js +12 -0
- package/src/authStrategies/RemoteAuth.js +204 -0
- package/src/factories/ChatFactory.js +16 -0
- package/src/factories/ContactFactory.js +16 -0
- package/src/structures/Base.js +22 -0
- package/src/structures/BusinessContact.js +21 -0
- package/src/structures/Buttons.js +82 -0
- package/src/structures/Call.js +76 -0
- package/src/structures/Chat.js +275 -0
- package/src/structures/ClientInfo.js +71 -0
- package/src/structures/Contact.js +208 -0
- package/src/structures/GroupChat.js +475 -0
- package/src/structures/GroupNotification.js +104 -0
- package/src/structures/Label.js +50 -0
- package/src/structures/List.js +79 -0
- package/src/structures/Location.js +61 -0
- package/src/structures/Message.js +711 -0
- package/src/structures/MessageMedia.js +111 -0
- package/src/structures/Order.js +52 -0
- package/src/structures/Payment.js +79 -0
- package/src/structures/Poll.js +44 -0
- package/src/structures/PollVote.js +61 -0
- package/src/structures/PrivateChat.js +13 -0
- package/src/structures/PrivateContact.js +13 -0
- package/src/structures/Product.js +68 -0
- package/src/structures/ProductMetadata.js +25 -0
- package/src/structures/Reaction.js +69 -0
- package/src/structures/index.js +24 -0
- package/src/util/Constants.js +176 -0
- package/src/util/Injected/AuthStore/AuthStore.js +17 -0
- package/src/util/Injected/AuthStore/LegacyAuthStore.js +22 -0
- package/src/util/Injected/LegacyStore.js +146 -0
- package/src/util/Injected/Store.js +167 -0
- package/src/util/Injected/Utils.js +1017 -0
- package/src/util/InterfaceController.js +127 -0
- package/src/util/Util.js +186 -0
- package/src/webCache/LocalWebCache.js +40 -0
- package/src/webCache/RemoteWebCache.js +40 -0
- package/src/webCache/WebCache.js +14 -0
- package/src/webCache/WebCacheFactory.js +20 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const Util = require('../util/Util');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Message type List
|
7
|
+
*/
|
8
|
+
class List {
|
9
|
+
/**
|
10
|
+
* @param {string} body
|
11
|
+
* @param {string} buttonText
|
12
|
+
* @param {Array<any>} sections
|
13
|
+
* @param {string?} title
|
14
|
+
* @param {string?} footer
|
15
|
+
*/
|
16
|
+
constructor(body, buttonText, sections, title, footer) {
|
17
|
+
/**
|
18
|
+
* Message body
|
19
|
+
* @type {string}
|
20
|
+
*/
|
21
|
+
this.description = body;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* List button text
|
25
|
+
* @type {string}
|
26
|
+
*/
|
27
|
+
this.buttonText = buttonText;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* title of message
|
31
|
+
* @type {string}
|
32
|
+
*/
|
33
|
+
this.title = title;
|
34
|
+
|
35
|
+
|
36
|
+
/**
|
37
|
+
* footer of message
|
38
|
+
* @type {string}
|
39
|
+
*/
|
40
|
+
this.footer = footer;
|
41
|
+
|
42
|
+
/**
|
43
|
+
* sections of message
|
44
|
+
* @type {Array<any>}
|
45
|
+
*/
|
46
|
+
this.sections = this._format(sections);
|
47
|
+
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Creates section array from simple array
|
52
|
+
* @param {Array<any>} sections
|
53
|
+
* @returns {Array<any>}
|
54
|
+
* @example
|
55
|
+
* Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
|
56
|
+
* Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]
|
57
|
+
*/
|
58
|
+
_format(sections){
|
59
|
+
if(!sections.length){throw '[LT02] List without sections';}
|
60
|
+
if(sections.length > 1 && sections.filter(s => typeof s.title == 'undefined').length > 1){throw '[LT05] You can\'t have more than one empty title.';}
|
61
|
+
return sections.map( (section) =>{
|
62
|
+
if(!section.rows.length){throw '[LT03] Section without rows';}
|
63
|
+
return {
|
64
|
+
title: section.title ? section.title : undefined,
|
65
|
+
rows: section.rows.map( (row) => {
|
66
|
+
if(!row.title){throw '[LT04] Row without title';}
|
67
|
+
return {
|
68
|
+
rowId: row.id ? row.id : Util.generateHash(6),
|
69
|
+
title: row.title,
|
70
|
+
description: row.description ? row.description : ''
|
71
|
+
};
|
72
|
+
})
|
73
|
+
};
|
74
|
+
});
|
75
|
+
}
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
module.exports = List;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Location send options
|
5
|
+
* @typedef {Object} LocationSendOptions
|
6
|
+
* @property {string} [name] Location name
|
7
|
+
* @property {string} [address] Location address
|
8
|
+
* @property {string} [url] URL address to be shown within a location message
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Location information
|
13
|
+
*/
|
14
|
+
class Location {
|
15
|
+
/**
|
16
|
+
* @param {number} latitude
|
17
|
+
* @param {number} longitude
|
18
|
+
* @param {LocationSendOptions} [options] Location send options
|
19
|
+
*/
|
20
|
+
constructor(latitude, longitude, options = {}) {
|
21
|
+
/**
|
22
|
+
* Location latitude
|
23
|
+
* @type {number}
|
24
|
+
*/
|
25
|
+
this.latitude = latitude;
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Location longitude
|
29
|
+
* @type {number}
|
30
|
+
*/
|
31
|
+
this.longitude = longitude;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Name for the location
|
35
|
+
* @type {string|undefined}
|
36
|
+
*/
|
37
|
+
this.name = options.name;
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Location address
|
41
|
+
* @type {string|undefined}
|
42
|
+
*/
|
43
|
+
this.address = options.address;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* URL address to be shown within a location message
|
47
|
+
* @type {string|undefined}
|
48
|
+
*/
|
49
|
+
this.url = options.url;
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Location full description
|
53
|
+
* @type {string|undefined}
|
54
|
+
*/
|
55
|
+
this.description = this.name && this.address
|
56
|
+
? `${this.name}\n${this.address}`
|
57
|
+
: this.name || this.address || '';
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
module.exports = Location;
|