@wppconnect-team/wppconnect 1.14.3 → 1.15.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/CHANGELOG.md +12 -0
- package/README.md +5 -5
- package/dist/api/layers/group.layer.d.ts +14 -0
- package/dist/api/layers/group.layer.js +61 -0
- package/dist/api/layers/host.layer.js +4 -0
- package/dist/api/layers/labels.layer.d.ts +63 -0
- package/dist/api/layers/labels.layer.js +196 -0
- package/dist/api/layers/listener.layer.d.ts +15 -0
- package/dist/api/layers/listener.layer.js +43 -6
- package/dist/api/layers/profile.layer.d.ts +2 -2
- package/dist/api/layers/profile.layer.js +2 -2
- package/dist/api/layers/retriever.layer.js +24 -15
- package/dist/api/layers/sender.layer.d.ts +19 -2
- package/dist/api/layers/sender.layer.js +28 -1
- package/dist/api/layers/status.layer.d.ts +37 -0
- package/dist/api/layers/status.layer.js +216 -0
- package/dist/api/model/chat.d.ts +6 -0
- package/dist/api/model/group-metadata.d.ts +15 -0
- package/dist/config/create-config.d.ts +21 -0
- package/dist/config/create-config.js +4 -0
- package/dist/controllers/initializer.js +1 -1
- package/package.json +24 -24
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
> WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination... 😀🤔💭
|
|
14
14
|
|
|
15
15
|
<p align="center">
|
|
16
|
-
<a href="https://wppconnect
|
|
17
|
-
<a href="https://wppconnect
|
|
18
|
-
<a href="https://wppconnect
|
|
16
|
+
<a href="https://wppconnect.io/wppconnect/pages/Getting%20Started/installation.html">Getting Started</a> •
|
|
17
|
+
<a href="https://wppconnect.io/wppconnect/pages/Getting%20Started/basic-functions.html">Basic Function</a> •
|
|
18
|
+
<a href="https://wppconnect.io/wppconnect/">Documentation</a>
|
|
19
19
|
</p>
|
|
20
20
|
|
|
21
21
|
## Our online channels
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
| Send _location_ | ✔ |
|
|
43
43
|
| **and much more** | ✔ |
|
|
44
44
|
|
|
45
|
-
See more at <a href="https://wppconnect
|
|
45
|
+
See more at <a href="https://wppconnect.io/wppconnect/classes/Whatsapp.html">WhatsApp methods</a>
|
|
46
46
|
|
|
47
47
|
## Installation
|
|
48
48
|
|
|
@@ -52,7 +52,7 @@ The first thing that you had to do is install the `npm package` :
|
|
|
52
52
|
npm i --save @wppconnect-team/wppconnect
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
See more at <a href="https://wppconnect
|
|
55
|
+
See more at <a href="https://wppconnect.io/wppconnect/pages/Getting%20Started/installation.html">Getting Started</a>
|
|
56
56
|
|
|
57
57
|
## Development
|
|
58
58
|
|
|
@@ -152,4 +152,18 @@ export declare class GroupLayer extends RetrieverLayer {
|
|
|
152
152
|
* @returns empty object
|
|
153
153
|
*/
|
|
154
154
|
setGroupProperty(groupId: string, property: GroupProperty, value: boolean): Promise<boolean>;
|
|
155
|
+
/**
|
|
156
|
+
* Set group subject (if allowed)
|
|
157
|
+
* @category Group
|
|
158
|
+
* @param groupId Group ID ('000000-000000@g.us')
|
|
159
|
+
* @param base64 Image in base64 ( data:image/jpeg;base64,..... )
|
|
160
|
+
* @returns empty object
|
|
161
|
+
*/
|
|
162
|
+
setGroupIcon(groupId: string, pathOrBase64: string): Promise<{
|
|
163
|
+
eurl: string;
|
|
164
|
+
status: number;
|
|
165
|
+
tag: string;
|
|
166
|
+
token: string;
|
|
167
|
+
_duplicate: boolean;
|
|
168
|
+
}>;
|
|
155
169
|
}
|
|
@@ -386,6 +386,67 @@ var GroupLayer = /** @class */ (function (_super) {
|
|
|
386
386
|
});
|
|
387
387
|
});
|
|
388
388
|
};
|
|
389
|
+
/**
|
|
390
|
+
* Set group subject (if allowed)
|
|
391
|
+
* @category Group
|
|
392
|
+
* @param groupId Group ID ('000000-000000@g.us')
|
|
393
|
+
* @param base64 Image in base64 ( data:image/jpeg;base64,..... )
|
|
394
|
+
* @returns empty object
|
|
395
|
+
*/
|
|
396
|
+
GroupLayer.prototype.setGroupIcon = function (groupId, pathOrBase64) {
|
|
397
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
398
|
+
var base64, fileContent, error, mimeInfo, error;
|
|
399
|
+
return __generator(this, function (_a) {
|
|
400
|
+
switch (_a.label) {
|
|
401
|
+
case 0:
|
|
402
|
+
base64 = '';
|
|
403
|
+
if (!pathOrBase64.startsWith('data:')) return [3 /*break*/, 1];
|
|
404
|
+
base64 = pathOrBase64;
|
|
405
|
+
return [3 /*break*/, 5];
|
|
406
|
+
case 1: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(pathOrBase64, [
|
|
407
|
+
'image/gif',
|
|
408
|
+
'image/png',
|
|
409
|
+
'image/jpg',
|
|
410
|
+
'image/jpeg',
|
|
411
|
+
'image/webp',
|
|
412
|
+
])];
|
|
413
|
+
case 2:
|
|
414
|
+
fileContent = _a.sent();
|
|
415
|
+
if (!!fileContent) return [3 /*break*/, 4];
|
|
416
|
+
return [4 /*yield*/, (0, helpers_1.fileToBase64)(pathOrBase64)];
|
|
417
|
+
case 3:
|
|
418
|
+
fileContent = _a.sent();
|
|
419
|
+
_a.label = 4;
|
|
420
|
+
case 4:
|
|
421
|
+
if (fileContent) {
|
|
422
|
+
base64 = fileContent;
|
|
423
|
+
}
|
|
424
|
+
_a.label = 5;
|
|
425
|
+
case 5:
|
|
426
|
+
if (!base64) {
|
|
427
|
+
error = new Error('Empty or invalid file or base64');
|
|
428
|
+
Object.assign(error, {
|
|
429
|
+
code: 'empty_file',
|
|
430
|
+
});
|
|
431
|
+
throw error;
|
|
432
|
+
}
|
|
433
|
+
mimeInfo = (0, helpers_1.base64MimeType)(base64);
|
|
434
|
+
if (!mimeInfo || !mimeInfo.includes('image')) {
|
|
435
|
+
error = new Error('Not an image, allowed formats png, jpeg and webp');
|
|
436
|
+
Object.assign(error, {
|
|
437
|
+
code: 'invalid_image',
|
|
438
|
+
});
|
|
439
|
+
throw error;
|
|
440
|
+
}
|
|
441
|
+
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
442
|
+
var groupId = _a.groupId, base64 = _a.base64;
|
|
443
|
+
return WPP.group.setIcon(groupId, base64);
|
|
444
|
+
}, { groupId: groupId, base64: base64 })];
|
|
445
|
+
case 6: return [2 /*return*/, _a.sent()];
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
};
|
|
389
450
|
return GroupLayer;
|
|
390
451
|
}(retriever_layer_1.RetrieverLayer));
|
|
391
452
|
exports.GroupLayer = GroupLayer;
|
|
@@ -163,6 +163,10 @@ var HostLayer = /** @class */ (function () {
|
|
|
163
163
|
this.log('verbose', 'Injecting wapi.js');
|
|
164
164
|
options = {
|
|
165
165
|
deviceName: this.options.deviceName,
|
|
166
|
+
disableGoogleAnalytics: this.options.disableGoogleAnalytics,
|
|
167
|
+
googleAnalyticsId: this.options.googleAnalyticsId,
|
|
168
|
+
linkPreviewApiServers: this.options.linkPreviewApiServers,
|
|
169
|
+
poweredBy: this.options.poweredBy,
|
|
166
170
|
};
|
|
167
171
|
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (options) {
|
|
168
172
|
window.WPPConfig = options;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Page } from 'puppeteer';
|
|
2
|
+
import { CreateConfig } from '../../config/create-config';
|
|
3
|
+
import { HostLayer } from './host.layer';
|
|
4
|
+
export declare class LabelsLayer extends HostLayer {
|
|
5
|
+
page: Page;
|
|
6
|
+
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
7
|
+
/**
|
|
8
|
+
* Create New Label
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```javascript
|
|
12
|
+
* client.addNewLabel(`Name of label`);
|
|
13
|
+
* //or
|
|
14
|
+
* client.addNewLabel(`Name of label`, { labelColor: '#dfaef0' });
|
|
15
|
+
* //or
|
|
16
|
+
* client.addNewLabel(`Name of label`, { labelColor: 4292849392 });
|
|
17
|
+
* ```
|
|
18
|
+
* @param name Name of label
|
|
19
|
+
* @param options options of label
|
|
20
|
+
*/
|
|
21
|
+
addNewLabel(name: string, options?: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Add or delete label of chatId
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```javascript
|
|
27
|
+
* client.addOrRemoveLabels(['[number]@c.us','[number]@c.us'],
|
|
28
|
+
* [{labelId:'76', type:'add'},{labelId:'75', type:'remove'}]);
|
|
29
|
+
* //or
|
|
30
|
+
* ```
|
|
31
|
+
* @param name Name of label
|
|
32
|
+
* @param options options to remove or add
|
|
33
|
+
*/
|
|
34
|
+
addOrRemoveLabels(chatIds: string, options: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Get all Labels
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```javascript
|
|
40
|
+
* client.getAllLabels();
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
getAllLabels(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Delete all Labels
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```javascript
|
|
49
|
+
* client.deleteAllLabels();
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
deleteAllLabels(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Add or delete label of chatId
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```javascript
|
|
58
|
+
* client.deleteLabel();
|
|
59
|
+
* ```
|
|
60
|
+
* @param id Id or string to labels to delete
|
|
61
|
+
*/
|
|
62
|
+
deleteLabel(id: string | string[]): Promise<void>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This file is part of WPPConnect.
|
|
4
|
+
*
|
|
5
|
+
* WPPConnect is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* WPPConnect is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Lesser General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
16
|
+
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
var __extends = (this && this.__extends) || (function () {
|
|
19
|
+
var extendStatics = function (d, b) {
|
|
20
|
+
extendStatics = Object.setPrototypeOf ||
|
|
21
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
22
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
23
|
+
return extendStatics(d, b);
|
|
24
|
+
};
|
|
25
|
+
return function (d, b) {
|
|
26
|
+
if (typeof b !== "function" && b !== null)
|
|
27
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
28
|
+
extendStatics(d, b);
|
|
29
|
+
function __() { this.constructor = d; }
|
|
30
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
34
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
35
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
36
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
37
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
38
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
39
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
43
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
44
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
45
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
46
|
+
function step(op) {
|
|
47
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
48
|
+
while (_) try {
|
|
49
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
50
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
51
|
+
switch (op[0]) {
|
|
52
|
+
case 0: case 1: t = op; break;
|
|
53
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
54
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
55
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
56
|
+
default:
|
|
57
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
58
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
59
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
60
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
61
|
+
if (t[2]) _.ops.pop();
|
|
62
|
+
_.trys.pop(); continue;
|
|
63
|
+
}
|
|
64
|
+
op = body.call(thisArg, _);
|
|
65
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
66
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
exports.LabelsLayer = void 0;
|
|
71
|
+
var host_layer_1 = require("./host.layer");
|
|
72
|
+
var helpers_1 = require("../helpers");
|
|
73
|
+
var LabelsLayer = /** @class */ (function (_super) {
|
|
74
|
+
__extends(LabelsLayer, _super);
|
|
75
|
+
function LabelsLayer(page, session, options) {
|
|
76
|
+
var _this = _super.call(this, page, session, options) || this;
|
|
77
|
+
_this.page = page;
|
|
78
|
+
return _this;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create New Label
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```javascript
|
|
85
|
+
* client.addNewLabel(`Name of label`);
|
|
86
|
+
* //or
|
|
87
|
+
* client.addNewLabel(`Name of label`, { labelColor: '#dfaef0' });
|
|
88
|
+
* //or
|
|
89
|
+
* client.addNewLabel(`Name of label`, { labelColor: 4292849392 });
|
|
90
|
+
* ```
|
|
91
|
+
* @param name Name of label
|
|
92
|
+
* @param options options of label
|
|
93
|
+
*/
|
|
94
|
+
LabelsLayer.prototype.addNewLabel = function (name, options) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
return __generator(this, function (_a) {
|
|
97
|
+
switch (_a.label) {
|
|
98
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
99
|
+
var name = _a.name, options = _a.options;
|
|
100
|
+
WPP.labels.addNewLabel(name, options);
|
|
101
|
+
}, { name: name, options: options })];
|
|
102
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Add or delete label of chatId
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```javascript
|
|
112
|
+
* client.addOrRemoveLabels(['[number]@c.us','[number]@c.us'],
|
|
113
|
+
* [{labelId:'76', type:'add'},{labelId:'75', type:'remove'}]);
|
|
114
|
+
* //or
|
|
115
|
+
* ```
|
|
116
|
+
* @param name Name of label
|
|
117
|
+
* @param options options to remove or add
|
|
118
|
+
*/
|
|
119
|
+
LabelsLayer.prototype.addOrRemoveLabels = function (chatIds, options) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
124
|
+
var chatIds = _a.chatIds, options = _a.options;
|
|
125
|
+
WPP.labels.addOrRemoveLabels(chatIds, options);
|
|
126
|
+
}, { chatIds: chatIds, options: options })];
|
|
127
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Get all Labels
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```javascript
|
|
137
|
+
* client.getAllLabels();
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
LabelsLayer.prototype.getAllLabels = function () {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
+
return __generator(this, function (_a) {
|
|
143
|
+
switch (_a.label) {
|
|
144
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
|
|
145
|
+
WPP.labels.getAllLabels();
|
|
146
|
+
})];
|
|
147
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Delete all Labels
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```javascript
|
|
157
|
+
* client.deleteAllLabels();
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
LabelsLayer.prototype.deleteAllLabels = function () {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
+
return __generator(this, function (_a) {
|
|
163
|
+
switch (_a.label) {
|
|
164
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
|
|
165
|
+
WPP.labels.deleteAllLabels();
|
|
166
|
+
})];
|
|
167
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Add or delete label of chatId
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```javascript
|
|
177
|
+
* client.deleteLabel();
|
|
178
|
+
* ```
|
|
179
|
+
* @param id Id or string to labels to delete
|
|
180
|
+
*/
|
|
181
|
+
LabelsLayer.prototype.deleteLabel = function (id) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
183
|
+
return __generator(this, function (_a) {
|
|
184
|
+
switch (_a.label) {
|
|
185
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
186
|
+
var id = _a.id;
|
|
187
|
+
WPP.labels.deleteLabel(id);
|
|
188
|
+
}, { id: id })];
|
|
189
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
return LabelsLayer;
|
|
195
|
+
}(host_layer_1.HostLayer));
|
|
196
|
+
exports.LabelsLayer = LabelsLayer;
|
|
@@ -197,4 +197,19 @@ export declare class ListenerLayer extends ProfileLayer {
|
|
|
197
197
|
}) => any): {
|
|
198
198
|
dispose: () => void;
|
|
199
199
|
};
|
|
200
|
+
/**
|
|
201
|
+
* @event Listens to reaction messages
|
|
202
|
+
* @returns Disposable object to stop the listening
|
|
203
|
+
*/
|
|
204
|
+
onReactionMessage(callback: (data: {
|
|
205
|
+
id: string;
|
|
206
|
+
msgId: string;
|
|
207
|
+
reactionText: string;
|
|
208
|
+
read: boolean;
|
|
209
|
+
orphan: number;
|
|
210
|
+
orphanReason: any;
|
|
211
|
+
timestamp: number;
|
|
212
|
+
}) => any): {
|
|
213
|
+
dispose: () => void;
|
|
214
|
+
};
|
|
200
215
|
}
|
|
@@ -123,6 +123,7 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
123
123
|
'onAddedToGroup',
|
|
124
124
|
'onIncomingCall',
|
|
125
125
|
'onRevokedMessage',
|
|
126
|
+
'onReactionMessage',
|
|
126
127
|
], false);
|
|
127
128
|
_loop_1 = function (func) {
|
|
128
129
|
var has;
|
|
@@ -169,10 +170,14 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
169
170
|
.evaluate(function () {
|
|
170
171
|
try {
|
|
171
172
|
if (!window['onMessage'].exposed) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
173
|
+
WPP.on('chat.new_message', function (msg) {
|
|
174
|
+
if (msg.isSentByMe || msg.isStatusV3) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
var serialized = WAPI.processMessageObj(msg, false, false);
|
|
178
|
+
if (serialized) {
|
|
179
|
+
window['onMessage'](serialized);
|
|
180
|
+
}
|
|
176
181
|
});
|
|
177
182
|
window['onMessage'].exposed = true;
|
|
178
183
|
}
|
|
@@ -191,7 +196,12 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
191
196
|
}
|
|
192
197
|
try {
|
|
193
198
|
if (!window['onAnyMessage'].exposed) {
|
|
194
|
-
|
|
199
|
+
WPP.on('chat.new_message', function (msg) {
|
|
200
|
+
var serialized = WAPI.processMessageObj(msg, true, false);
|
|
201
|
+
if (serialized) {
|
|
202
|
+
window['onAnyMessage'](serialized);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
195
205
|
window['onAnyMessage'].exposed = true;
|
|
196
206
|
}
|
|
197
207
|
}
|
|
@@ -254,7 +264,7 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
254
264
|
}
|
|
255
265
|
try {
|
|
256
266
|
if (!window['onPresenceChanged'].exposed) {
|
|
257
|
-
|
|
267
|
+
WPP.on('chat.presence_change', window['onPresenceChanged']);
|
|
258
268
|
window['onPresenceChanged'].exposed = true;
|
|
259
269
|
}
|
|
260
270
|
}
|
|
@@ -288,6 +298,26 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
288
298
|
catch (error) {
|
|
289
299
|
console.error(error);
|
|
290
300
|
}
|
|
301
|
+
try {
|
|
302
|
+
if (!window['onReactionMessage'].exposed) {
|
|
303
|
+
WPP.on('chat.new_reaction', function (data) {
|
|
304
|
+
var eventData = {
|
|
305
|
+
id: data.id,
|
|
306
|
+
msgId: data.msgId,
|
|
307
|
+
reactionText: data.reactionText,
|
|
308
|
+
read: data.read,
|
|
309
|
+
orphan: data.orphan,
|
|
310
|
+
orphanReason: data.orphanReason,
|
|
311
|
+
timestamp: data.timestamp,
|
|
312
|
+
};
|
|
313
|
+
window['onReactionMessage'](eventData);
|
|
314
|
+
});
|
|
315
|
+
window['onReactionMessage'].exposed = true;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
console.error(error);
|
|
320
|
+
}
|
|
291
321
|
})
|
|
292
322
|
.catch(function () { })];
|
|
293
323
|
case 6:
|
|
@@ -498,6 +528,13 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
498
528
|
ListenerLayer.prototype.onRevokedMessage = function (callback) {
|
|
499
529
|
return this.registerEvent('onRevokedMessage', callback);
|
|
500
530
|
};
|
|
531
|
+
/**
|
|
532
|
+
* @event Listens to reaction messages
|
|
533
|
+
* @returns Disposable object to stop the listening
|
|
534
|
+
*/
|
|
535
|
+
ListenerLayer.prototype.onReactionMessage = function (callback) {
|
|
536
|
+
return this.registerEvent('onReactionMessage', callback);
|
|
537
|
+
};
|
|
501
538
|
return ListenerLayer;
|
|
502
539
|
}(profile_layer_1.ProfileLayer));
|
|
503
540
|
exports.ListenerLayer = ListenerLayer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Page } from 'puppeteer';
|
|
2
|
-
import { HostLayer } from './host.layer';
|
|
3
2
|
import { CreateConfig } from '../../config/create-config';
|
|
4
|
-
|
|
3
|
+
import { StatusLayer } from './status.layer';
|
|
4
|
+
export declare class ProfileLayer extends StatusLayer {
|
|
5
5
|
page: Page;
|
|
6
6
|
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
7
7
|
/**
|
|
@@ -68,8 +68,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
68
68
|
};
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.ProfileLayer = void 0;
|
|
71
|
-
var host_layer_1 = require("./host.layer");
|
|
72
71
|
var helpers_1 = require("../helpers");
|
|
72
|
+
var status_layer_1 = require("./status.layer");
|
|
73
73
|
var ProfileLayer = /** @class */ (function (_super) {
|
|
74
74
|
__extends(ProfileLayer, _super);
|
|
75
75
|
function ProfileLayer(page, session, options) {
|
|
@@ -212,5 +212,5 @@ var ProfileLayer = /** @class */ (function (_super) {
|
|
|
212
212
|
});
|
|
213
213
|
};
|
|
214
214
|
return ProfileLayer;
|
|
215
|
-
}(
|
|
215
|
+
}(status_layer_1.StatusLayer));
|
|
216
216
|
exports.ProfileLayer = ProfileLayer;
|
|
@@ -235,21 +235,30 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
235
235
|
RetrieverLayer.prototype.getAllGroups = function (withNewMessagesOnly) {
|
|
236
236
|
if (withNewMessagesOnly === void 0) { withNewMessagesOnly = false; }
|
|
237
237
|
return __awaiter(this, void 0, void 0, function () {
|
|
238
|
-
var
|
|
238
|
+
var _this = this;
|
|
239
239
|
return __generator(this, function (_a) {
|
|
240
240
|
switch (_a.label) {
|
|
241
|
-
case 0:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
241
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
242
|
+
var withNewMessagesOnly = _a.withNewMessagesOnly;
|
|
243
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
244
|
+
var chats, groups;
|
|
245
|
+
return __generator(this, function (_b) {
|
|
246
|
+
switch (_b.label) {
|
|
247
|
+
case 0: return [4 /*yield*/, WPP.chat.list({
|
|
248
|
+
onlyGroups: true,
|
|
249
|
+
onlyWithUnreadMessage: withNewMessagesOnly,
|
|
250
|
+
})];
|
|
251
|
+
case 1:
|
|
252
|
+
chats = _b.sent();
|
|
253
|
+
return [4 /*yield*/, Promise.all(chats.map(function (c) { return WPP.group.ensureGroup(c.id); }))];
|
|
254
|
+
case 2:
|
|
255
|
+
groups = _b.sent();
|
|
256
|
+
return [2 /*return*/, groups.map(function (g) { return WAPI._serializeChatObj(g); })];
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}, { withNewMessagesOnly: withNewMessagesOnly })];
|
|
261
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
253
262
|
}
|
|
254
263
|
});
|
|
255
264
|
});
|
|
@@ -374,8 +383,8 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
374
383
|
case 1:
|
|
375
384
|
status = _a.sent();
|
|
376
385
|
return [2 /*return*/, {
|
|
377
|
-
id:
|
|
378
|
-
status: status.status,
|
|
386
|
+
id: contactId,
|
|
387
|
+
status: (status === null || status === void 0 ? void 0 : status.status) || status,
|
|
379
388
|
}];
|
|
380
389
|
}
|
|
381
390
|
});
|
|
@@ -35,7 +35,7 @@ export declare class SenderLayer extends ListenerLayer {
|
|
|
35
35
|
* useTemplateButtons: true, // False for legacy
|
|
36
36
|
* buttons: [
|
|
37
37
|
* {
|
|
38
|
-
* url: 'https://wppconnect
|
|
38
|
+
* url: 'https://wppconnect.io/',
|
|
39
39
|
* text: 'WPPConnect Site'
|
|
40
40
|
* },
|
|
41
41
|
* {
|
|
@@ -176,7 +176,7 @@ export declare class SenderLayer extends ListenerLayer {
|
|
|
176
176
|
* useTemplateButtons: true, // False for legacy
|
|
177
177
|
* buttons: [
|
|
178
178
|
* {
|
|
179
|
-
* url: 'https://wppconnect
|
|
179
|
+
* url: 'https://wppconnect.io/',
|
|
180
180
|
* text: 'WPPConnect Site'
|
|
181
181
|
* },
|
|
182
182
|
* {
|
|
@@ -428,4 +428,21 @@ export declare class SenderLayer extends ListenerLayer {
|
|
|
428
428
|
* @deprecated Deprecated in favor of Use startTyping or startRecording functions
|
|
429
429
|
*/
|
|
430
430
|
setChatState(chatId: string, chatState: ChatState): Promise<void>;
|
|
431
|
+
/**
|
|
432
|
+
* Send reaction to message
|
|
433
|
+
* @example
|
|
434
|
+
* ```javascript
|
|
435
|
+
* // For send Reaction, just to send emoji
|
|
436
|
+
* await client.sendReactionToMessage('[number]@c.us', '🤯');
|
|
437
|
+
*
|
|
438
|
+
* // to remove reacition
|
|
439
|
+
* await client.startRecording('[number]@c.us', false);
|
|
440
|
+
* ```
|
|
441
|
+
* @category Chat
|
|
442
|
+
* @param to Chat Id
|
|
443
|
+
* @param duration Duration um miliseconds
|
|
444
|
+
*/
|
|
445
|
+
sendReactionToMessage(msgId: string, reaction: string | false): Promise<{
|
|
446
|
+
sendMsgResult: string;
|
|
447
|
+
}>;
|
|
431
448
|
}
|
|
@@ -160,7 +160,7 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
160
160
|
* useTemplateButtons: true, // False for legacy
|
|
161
161
|
* buttons: [
|
|
162
162
|
* {
|
|
163
|
-
* url: 'https://wppconnect
|
|
163
|
+
* url: 'https://wppconnect.io/',
|
|
164
164
|
* text: 'WPPConnect Site'
|
|
165
165
|
* },
|
|
166
166
|
* {
|
|
@@ -1264,6 +1264,33 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
1264
1264
|
});
|
|
1265
1265
|
});
|
|
1266
1266
|
};
|
|
1267
|
+
/**
|
|
1268
|
+
* Send reaction to message
|
|
1269
|
+
* @example
|
|
1270
|
+
* ```javascript
|
|
1271
|
+
* // For send Reaction, just to send emoji
|
|
1272
|
+
* await client.sendReactionToMessage('[number]@c.us', '🤯');
|
|
1273
|
+
*
|
|
1274
|
+
* // to remove reacition
|
|
1275
|
+
* await client.startRecording('[number]@c.us', false);
|
|
1276
|
+
* ```
|
|
1277
|
+
* @category Chat
|
|
1278
|
+
* @param to Chat Id
|
|
1279
|
+
* @param duration Duration um miliseconds
|
|
1280
|
+
*/
|
|
1281
|
+
SenderLayer.prototype.sendReactionToMessage = function (msgId, reaction) {
|
|
1282
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1283
|
+
return __generator(this, function (_a) {
|
|
1284
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
1285
|
+
var msgId = _a.msgId, reaction = _a.reaction;
|
|
1286
|
+
return WPP.chat.sendReactionToMessage(msgId, reaction);
|
|
1287
|
+
}, {
|
|
1288
|
+
msgId: msgId,
|
|
1289
|
+
reaction: reaction,
|
|
1290
|
+
})];
|
|
1291
|
+
});
|
|
1292
|
+
});
|
|
1293
|
+
};
|
|
1267
1294
|
return SenderLayer;
|
|
1268
1295
|
}(listener_layer_1.ListenerLayer));
|
|
1269
1296
|
exports.SenderLayer = SenderLayer;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Page } from 'puppeteer';
|
|
2
|
+
import { CreateConfig } from '../../config/create-config';
|
|
3
|
+
import { LabelsLayer } from './labels.layer';
|
|
4
|
+
export declare class StatusLayer extends LabelsLayer {
|
|
5
|
+
page: Page;
|
|
6
|
+
constructor(page: Page, session?: string, options?: CreateConfig);
|
|
7
|
+
/**
|
|
8
|
+
* Send a image message to status stories
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```javascript
|
|
12
|
+
* client.sendImageStatus('data:image/jpeg;base64,<a long base64 file...>');
|
|
13
|
+
* ```
|
|
14
|
+
* @param pathOrBase64 Path or base 64 image
|
|
15
|
+
*/
|
|
16
|
+
sendImageStatus(pathOrBase64: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Send a video message to status stories
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```javascript
|
|
22
|
+
* client.sendVideoStatus('data:video/mp4;base64,<a long base64 file...>');
|
|
23
|
+
* ```
|
|
24
|
+
* @param pathOrBase64 Path or base 64 image
|
|
25
|
+
*/
|
|
26
|
+
sendVideoStatus(pathOrBase64: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Send a text to status stories
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```javascript
|
|
32
|
+
* client.sendTextStatus(`Bootstrap primary color: #0275d8`, { backgroundColor: '#0275d8', font: 2});
|
|
33
|
+
* ```
|
|
34
|
+
* @param pathOrBase64 Path or base 64 image
|
|
35
|
+
*/
|
|
36
|
+
sendTextStatus(text: string, options: string): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This file is part of WPPConnect.
|
|
4
|
+
*
|
|
5
|
+
* WPPConnect is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* WPPConnect is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Lesser General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
16
|
+
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
var __extends = (this && this.__extends) || (function () {
|
|
19
|
+
var extendStatics = function (d, b) {
|
|
20
|
+
extendStatics = Object.setPrototypeOf ||
|
|
21
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
22
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
23
|
+
return extendStatics(d, b);
|
|
24
|
+
};
|
|
25
|
+
return function (d, b) {
|
|
26
|
+
if (typeof b !== "function" && b !== null)
|
|
27
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
28
|
+
extendStatics(d, b);
|
|
29
|
+
function __() { this.constructor = d; }
|
|
30
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
34
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
35
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
36
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
37
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
38
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
39
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
43
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
44
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
45
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
46
|
+
function step(op) {
|
|
47
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
48
|
+
while (_) try {
|
|
49
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
50
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
51
|
+
switch (op[0]) {
|
|
52
|
+
case 0: case 1: t = op; break;
|
|
53
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
54
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
55
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
56
|
+
default:
|
|
57
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
58
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
59
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
60
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
61
|
+
if (t[2]) _.ops.pop();
|
|
62
|
+
_.trys.pop(); continue;
|
|
63
|
+
}
|
|
64
|
+
op = body.call(thisArg, _);
|
|
65
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
66
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
exports.StatusLayer = void 0;
|
|
71
|
+
var labels_layer_1 = require("./labels.layer");
|
|
72
|
+
var helpers_1 = require("../helpers");
|
|
73
|
+
var StatusLayer = /** @class */ (function (_super) {
|
|
74
|
+
__extends(StatusLayer, _super);
|
|
75
|
+
function StatusLayer(page, session, options) {
|
|
76
|
+
var _this = _super.call(this, page, session, options) || this;
|
|
77
|
+
_this.page = page;
|
|
78
|
+
return _this;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Send a image message to status stories
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```javascript
|
|
85
|
+
* client.sendImageStatus('data:image/jpeg;base64,<a long base64 file...>');
|
|
86
|
+
* ```
|
|
87
|
+
* @param pathOrBase64 Path or base 64 image
|
|
88
|
+
*/
|
|
89
|
+
StatusLayer.prototype.sendImageStatus = function (pathOrBase64) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
+
var base64, fileContent, error, mimeInfo, error;
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
switch (_a.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
base64 = '';
|
|
96
|
+
if (!pathOrBase64.startsWith('data:')) return [3 /*break*/, 1];
|
|
97
|
+
base64 = pathOrBase64;
|
|
98
|
+
return [3 /*break*/, 5];
|
|
99
|
+
case 1: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(pathOrBase64, [
|
|
100
|
+
'image/gif',
|
|
101
|
+
'image/png',
|
|
102
|
+
'image/jpg',
|
|
103
|
+
'image/jpeg',
|
|
104
|
+
'image/webp',
|
|
105
|
+
])];
|
|
106
|
+
case 2:
|
|
107
|
+
fileContent = _a.sent();
|
|
108
|
+
if (!!fileContent) return [3 /*break*/, 4];
|
|
109
|
+
return [4 /*yield*/, (0, helpers_1.fileToBase64)(pathOrBase64)];
|
|
110
|
+
case 3:
|
|
111
|
+
fileContent = _a.sent();
|
|
112
|
+
_a.label = 4;
|
|
113
|
+
case 4:
|
|
114
|
+
if (fileContent) {
|
|
115
|
+
base64 = fileContent;
|
|
116
|
+
}
|
|
117
|
+
_a.label = 5;
|
|
118
|
+
case 5:
|
|
119
|
+
if (!base64) {
|
|
120
|
+
error = new Error('Empty or invalid file or base64');
|
|
121
|
+
Object.assign(error, {
|
|
122
|
+
code: 'empty_file',
|
|
123
|
+
});
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
mimeInfo = (0, helpers_1.base64MimeType)(base64);
|
|
127
|
+
if (!mimeInfo || !mimeInfo.includes('image')) {
|
|
128
|
+
error = new Error('Not an image, allowed formats png, jpeg and webp');
|
|
129
|
+
Object.assign(error, {
|
|
130
|
+
code: 'invalid_image',
|
|
131
|
+
});
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
135
|
+
var base64 = _a.base64;
|
|
136
|
+
WPP.status.sendImageStatus(base64);
|
|
137
|
+
}, { base64: base64 })];
|
|
138
|
+
case 6: return [2 /*return*/, _a.sent()];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Send a video message to status stories
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```javascript
|
|
148
|
+
* client.sendVideoStatus('data:video/mp4;base64,<a long base64 file...>');
|
|
149
|
+
* ```
|
|
150
|
+
* @param pathOrBase64 Path or base 64 image
|
|
151
|
+
*/
|
|
152
|
+
StatusLayer.prototype.sendVideoStatus = function (pathOrBase64) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
+
var base64, fileContent, error;
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0:
|
|
158
|
+
base64 = '';
|
|
159
|
+
if (!pathOrBase64.startsWith('data:')) return [3 /*break*/, 1];
|
|
160
|
+
base64 = pathOrBase64;
|
|
161
|
+
return [3 /*break*/, 5];
|
|
162
|
+
case 1: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(pathOrBase64)];
|
|
163
|
+
case 2:
|
|
164
|
+
fileContent = _a.sent();
|
|
165
|
+
if (!!fileContent) return [3 /*break*/, 4];
|
|
166
|
+
return [4 /*yield*/, (0, helpers_1.fileToBase64)(pathOrBase64)];
|
|
167
|
+
case 3:
|
|
168
|
+
fileContent = _a.sent();
|
|
169
|
+
_a.label = 4;
|
|
170
|
+
case 4:
|
|
171
|
+
if (fileContent) {
|
|
172
|
+
base64 = fileContent;
|
|
173
|
+
}
|
|
174
|
+
_a.label = 5;
|
|
175
|
+
case 5:
|
|
176
|
+
if (!base64) {
|
|
177
|
+
error = new Error('Empty or invalid file or base64');
|
|
178
|
+
Object.assign(error, {
|
|
179
|
+
code: 'empty_file',
|
|
180
|
+
});
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
184
|
+
var base64 = _a.base64;
|
|
185
|
+
WPP.status.sendVideoStatus(base64);
|
|
186
|
+
}, { base64: base64 })];
|
|
187
|
+
case 6: return [2 /*return*/, _a.sent()];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Send a text to status stories
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```javascript
|
|
197
|
+
* client.sendTextStatus(`Bootstrap primary color: #0275d8`, { backgroundColor: '#0275d8', font: 2});
|
|
198
|
+
* ```
|
|
199
|
+
* @param pathOrBase64 Path or base 64 image
|
|
200
|
+
*/
|
|
201
|
+
StatusLayer.prototype.sendTextStatus = function (text, options) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
203
|
+
return __generator(this, function (_a) {
|
|
204
|
+
switch (_a.label) {
|
|
205
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
206
|
+
var text = _a.text, options = _a.options;
|
|
207
|
+
WPP.status.sendTextStatus(text, options);
|
|
208
|
+
}, { text: text, options: options })];
|
|
209
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
return StatusLayer;
|
|
215
|
+
}(labels_layer_1.LabelsLayer));
|
|
216
|
+
exports.StatusLayer = StatusLayer;
|
package/dist/api/model/chat.d.ts
CHANGED
|
@@ -16,6 +16,12 @@ export interface Chat {
|
|
|
16
16
|
pin: number;
|
|
17
17
|
msgs: null;
|
|
18
18
|
kind: string;
|
|
19
|
+
isAnnounceGrpRestrict: boolean;
|
|
20
|
+
ephemeralDuration: number;
|
|
21
|
+
hasChatBeenOpened: boolean;
|
|
22
|
+
unreadMentionCount: number;
|
|
23
|
+
hasUnreadMention: boolean;
|
|
24
|
+
archiveAtMentionViewedInDrawer: boolean;
|
|
19
25
|
isBroadcast: boolean;
|
|
20
26
|
isGroup: boolean;
|
|
21
27
|
isReadOnly: boolean;
|
|
@@ -3,6 +3,21 @@ export interface GroupMetadata {
|
|
|
3
3
|
id: Wid;
|
|
4
4
|
creation: number;
|
|
5
5
|
owner: Wid;
|
|
6
|
+
desc: string;
|
|
7
|
+
descId: string;
|
|
8
|
+
descTime: number;
|
|
9
|
+
descOwner: Wid;
|
|
10
|
+
restrict: boolean;
|
|
11
|
+
announce: boolean;
|
|
12
|
+
noFrequentlyForwarded: boolean;
|
|
13
|
+
ephemeralDuration: number;
|
|
14
|
+
size: number;
|
|
15
|
+
support: boolean;
|
|
16
|
+
suspended: boolean;
|
|
17
|
+
terminated: boolean;
|
|
18
|
+
isParentGroup: boolean;
|
|
19
|
+
defaultSubgroup: boolean;
|
|
20
|
+
displayCadminPromotion: boolean;
|
|
6
21
|
participants: any[];
|
|
7
22
|
pendingParticipants: any[];
|
|
8
23
|
}
|
|
@@ -110,5 +110,26 @@ export interface CreateConfig {
|
|
|
110
110
|
* @default 'WPPConnect'
|
|
111
111
|
*/
|
|
112
112
|
deviceName?: string | false;
|
|
113
|
+
/**
|
|
114
|
+
* Set custom Link Preview API servers
|
|
115
|
+
* @default null
|
|
116
|
+
*/
|
|
117
|
+
linkPreviewApiServers?: string[] | null;
|
|
118
|
+
/**
|
|
119
|
+
* Disable custom Google Analytics
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
122
|
+
disableGoogleAnalytics?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Custom Google Analytics Tracker Id, like 'G-XXXXXXXXXX'
|
|
125
|
+
* collect analytics data to your GA account
|
|
126
|
+
* @default null
|
|
127
|
+
*/
|
|
128
|
+
googleAnalyticsId?: string | null;
|
|
129
|
+
/**
|
|
130
|
+
* Custom variable for Google Analytics
|
|
131
|
+
* @default 'WPPConnect'
|
|
132
|
+
*/
|
|
133
|
+
poweredBy?: string;
|
|
113
134
|
}
|
|
114
135
|
export declare const defaultOptions: CreateConfig;
|
|
@@ -147,7 +147,7 @@ function create(sessionOrOption, catchQR, statusFind, options, browserSessionTok
|
|
|
147
147
|
mergedOptions = __assign(__assign({}, create_config_1.defaultOptions), options);
|
|
148
148
|
logger = mergedOptions.logger;
|
|
149
149
|
if (usingDeprecatedCreate) {
|
|
150
|
-
logger.warn('You are using deprecated create method, please use create({options}) See: https://wppconnect
|
|
150
|
+
logger.warn('You are using deprecated create method, please use create({options}) See: https://wppconnect.io/wppconnect/pages/Getting%20Started/creating-client.html#passing-options-on-create');
|
|
151
151
|
}
|
|
152
152
|
if (!mergedOptions.disableWelcome) {
|
|
153
153
|
(0, welcome_1.welcomeScreen)();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wppconnect-team/wppconnect",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination... 😀🤔💭",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -58,51 +58,51 @@
|
|
|
58
58
|
},
|
|
59
59
|
"homepage": "https://github.com/wppconnect-team/wppconnect#readme",
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@babel/core": "^7.18.
|
|
61
|
+
"@babel/core": "^7.18.6",
|
|
62
62
|
"@babel/eslint-parser": "^7.18.2",
|
|
63
63
|
"@babel/eslint-plugin": "^7.17.7",
|
|
64
|
-
"@babel/preset-env": "^7.18.
|
|
65
|
-
"@commitlint/cli": "^17.0.
|
|
66
|
-
"@commitlint/config-conventional": "^17.0.
|
|
67
|
-
"@commitlint/cz-commitlint": "^17.0.
|
|
64
|
+
"@babel/preset-env": "^7.18.6",
|
|
65
|
+
"@commitlint/cli": "^17.0.3",
|
|
66
|
+
"@commitlint/config-conventional": "^17.0.3",
|
|
67
|
+
"@commitlint/cz-commitlint": "^17.0.3",
|
|
68
68
|
"@types/atob": "^2.1.2",
|
|
69
69
|
"@types/mime-types": "^2.1.1",
|
|
70
70
|
"@types/mocha": "^9.1.1",
|
|
71
|
-
"@types/node": "^16.11.
|
|
71
|
+
"@types/node": "^16.11.45",
|
|
72
72
|
"@types/rimraf": "^3.0.2",
|
|
73
73
|
"@types/sharp": "^0.30.4",
|
|
74
74
|
"@types/shelljs": "^0.8.11",
|
|
75
75
|
"@types/tmp": "^0.2.3",
|
|
76
76
|
"@types/ws": "^8.5.3",
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
78
|
-
"@typescript-eslint/parser": "^5.
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^5.29.0",
|
|
78
|
+
"@typescript-eslint/parser": "^5.29.0",
|
|
79
79
|
"babel-loader": "^8.2.5",
|
|
80
80
|
"commitizen": "^4.2.4",
|
|
81
81
|
"concurrently": "^7.2.2",
|
|
82
82
|
"conventional-changelog-cli": "^2.2.2",
|
|
83
83
|
"copy-webpack-plugin": "^11.0.0",
|
|
84
|
-
"eslint": "^8.
|
|
84
|
+
"eslint": "^8.18.0",
|
|
85
85
|
"eslint-config-prettier": "^8.5.0",
|
|
86
86
|
"eslint-plugin-prettier": "^4.0.0",
|
|
87
87
|
"gulp": "^4.0.2",
|
|
88
88
|
"husky": "^8.0.1",
|
|
89
89
|
"license-check-and-add": "^4.0.5",
|
|
90
90
|
"mocha": "^10.0.0",
|
|
91
|
-
"prettier": "^2.
|
|
91
|
+
"prettier": "^2.7.1",
|
|
92
92
|
"pretty-quick": "^3.1.3",
|
|
93
93
|
"regenerator-runtime": "^0.13.9",
|
|
94
|
-
"release-it": "^15.
|
|
94
|
+
"release-it": "^15.1.1",
|
|
95
95
|
"shx": "^0.3.4",
|
|
96
|
-
"ts-node": "^10.8.
|
|
96
|
+
"ts-node": "^10.8.2",
|
|
97
97
|
"typedoc": "^0.21.10",
|
|
98
98
|
"typedoc-plugin-pages": "^1.1.0",
|
|
99
|
-
"typescript": "^4.7.
|
|
99
|
+
"typescript": "^4.7.4",
|
|
100
100
|
"webpack": "^5.73.0",
|
|
101
101
|
"webpack-cli": "^4.10.0"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@wppconnect/wa-js": "^2.
|
|
105
|
-
"@wppconnect/wa-version": "^1.1.
|
|
104
|
+
"@wppconnect/wa-js": "^2.8.1",
|
|
105
|
+
"@wppconnect/wa-version": "^1.1.104",
|
|
106
106
|
"atob": "^2.1.2",
|
|
107
107
|
"axios": "^0.27.2",
|
|
108
108
|
"boxen": "^5.1.2",
|
|
@@ -113,23 +113,23 @@
|
|
|
113
113
|
"file-type": "~16.5.3",
|
|
114
114
|
"futoin-hkdf": "^1.5.1",
|
|
115
115
|
"latest-version": "^5.1.0",
|
|
116
|
-
"logform": "^2.4.
|
|
116
|
+
"logform": "^2.4.2",
|
|
117
117
|
"lookpath": "^1.2.2",
|
|
118
118
|
"mime-types": "^2.1.35",
|
|
119
119
|
"puppeteer": "*",
|
|
120
|
-
"puppeteer-extra": "^3.
|
|
121
|
-
"puppeteer-extra-plugin-stealth": "^2.
|
|
122
|
-
"puppeteer-extra-plugin-user-data-dir": "^2.
|
|
123
|
-
"puppeteer-extra-plugin-user-preferences": "^2.
|
|
120
|
+
"puppeteer-extra": "^3.3.4",
|
|
121
|
+
"puppeteer-extra-plugin-stealth": "^2.11.0",
|
|
122
|
+
"puppeteer-extra-plugin-user-data-dir": "^2.4.0",
|
|
123
|
+
"puppeteer-extra-plugin-user-preferences": "^2.4.0",
|
|
124
124
|
"qrcode-terminal": "^0.12.0",
|
|
125
125
|
"reflect-metadata": "^0.1.13",
|
|
126
126
|
"rimraf": "^3.0.2",
|
|
127
127
|
"sanitize-filename": "^1.6.3",
|
|
128
|
-
"sharp": "^0.30.
|
|
128
|
+
"sharp": "^0.30.7",
|
|
129
129
|
"tmp": "^0.2.1",
|
|
130
130
|
"tree-kill": "^1.2.2",
|
|
131
|
-
"winston": "^3.
|
|
132
|
-
"ws": "^8.8.
|
|
131
|
+
"winston": "^3.8.1",
|
|
132
|
+
"ws": "^8.8.1"
|
|
133
133
|
},
|
|
134
134
|
"optionalDependencies": {
|
|
135
135
|
"fsevents": "^2.3.2"
|