@wppconnect-team/wppconnect 1.10.1 → 1.11.1
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 +31 -0
- package/dist/api/helpers/decrypt.js +1 -1
- package/dist/api/helpers/download-file.js +3 -3
- package/dist/api/helpers/evaluate-and-return.js +1 -1
- package/dist/api/helpers/file-to-base64.js +1 -1
- package/dist/api/helpers/index.d.ts +0 -1
- package/dist/api/helpers/index.js +1 -3
- package/dist/api/helpers/select-sticker.js +1 -1
- package/dist/api/layers/controls.layer.js +6 -1
- package/dist/api/layers/host.layer.js +6 -6
- package/dist/api/layers/listener.layer.js +2 -2
- package/dist/api/layers/retriever.layer.d.ts +4 -1
- package/dist/api/layers/retriever.layer.js +6 -1
- package/dist/api/layers/sender.layer.d.ts +46 -7
- package/dist/api/layers/sender.layer.js +131 -31
- package/dist/config/create-config.d.ts +1 -1
- package/dist/config/create-config.js +1 -1
- package/dist/controllers/browser.js +2 -0
- package/dist/controllers/initializer.js +1 -1
- package/dist/controllers/welcome.js +3 -3
- package/dist/lib/wapi/wapi.js +1 -1
- package/dist/utils/ffmpeg.js +2 -2
- package/dist/utils/logger.js +1 -1
- package/package.json +24 -25
- package/dist/api/helpers/scrape-desconnect.d.ts +0 -7
- package/dist/api/helpers/scrape-desconnect.js +0 -78
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
## 1.11.1 (2021-12-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Fixed getNumberProfile function (fix [#717](https://github.com/wppconnect-team/wppconnect/issues/717)) ([89a0720](https://github.com/wppconnect-team/wppconnect/commit/89a072066991213d301739b0788d19f05a9b0912))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# 1.11.0 (2021-12-09)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* Fixed initialization of onPresenceChanged (fix [#704](https://github.com/wppconnect-team/wppconnect/issues/704)) ([0470ea8](https://github.com/wppconnect-team/wppconnect/commit/0470ea8a0fd15727f91e18c913b96f3c1e1f79a9))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## 1.10.3 (2021-11-18)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## 1.10.2 (2021-11-15)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* Fixed call of createWid function (fix [#647](https://github.com/wppconnect-team/wppconnect/issues/647)) ([c381000](https://github.com/wppconnect-team/wppconnect/commit/c3810003a4f145f9c3ec54f49cde97ddbe01a164))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
1
32
|
## 1.10.1 (2021-11-11)
|
|
2
33
|
|
|
3
34
|
|
|
@@ -76,7 +76,7 @@ var magix = function (fileData, mediaKeyBase64, mediaType, expectedSize) {
|
|
|
76
76
|
var encodedHex = fileData.toString('hex');
|
|
77
77
|
var encodedBytes = hexToBytes(encodedHex);
|
|
78
78
|
var mediaKeyBytes = base64ToBytes(mediaKeyBase64);
|
|
79
|
-
var info = "WhatsApp "
|
|
79
|
+
var info = "WhatsApp ".concat(exports.mediaTypes[mediaType.toUpperCase()], " Keys");
|
|
80
80
|
var hash = 'sha256';
|
|
81
81
|
var salt = new Uint8Array(32);
|
|
82
82
|
var expandedSize = 112;
|
|
@@ -65,7 +65,7 @@ function downloadFileToBase64(_path, _mines) {
|
|
|
65
65
|
switch (_a.label) {
|
|
66
66
|
case 0:
|
|
67
67
|
if (!Array.isArray(_mines)) {
|
|
68
|
-
console.error("set mines string array, not \""
|
|
68
|
+
console.error("set mines string array, not \"".concat(typeof _mines, "\" "));
|
|
69
69
|
return [2 /*return*/, false];
|
|
70
70
|
}
|
|
71
71
|
reHttp = /^https?:/;
|
|
@@ -89,12 +89,12 @@ function downloadFileToBase64(_path, _mines) {
|
|
|
89
89
|
return m.exec(mimeType_1);
|
|
90
90
|
});
|
|
91
91
|
if (!isValidMime) {
|
|
92
|
-
console.error("Content-Type \""
|
|
92
|
+
console.error("Content-Type \"".concat(mimeType_1, "\" of ").concat(_path, " is not allowed"));
|
|
93
93
|
return [2 /*return*/, false];
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
content = Buffer.from(response.data, 'binary').toString('base64');
|
|
97
|
-
return [2 /*return*/, "data:"
|
|
97
|
+
return [2 /*return*/, "data:".concat(mimeType_1, ";base64,").concat(content)];
|
|
98
98
|
case 3:
|
|
99
99
|
error_1 = _a.sent();
|
|
100
100
|
return [3 /*break*/, 4];
|
|
@@ -94,7 +94,7 @@ function evaluateAndReturn(page, pageFunction) {
|
|
|
94
94
|
throw new Error('Passed function is not well-serializable!');
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
func = new Function("\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };\n var _this; // for arrow function\n\n return new Promise(async (resolve) => {\n try {\n return resolve(await ("
|
|
97
|
+
func = new Function("\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };\n\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };\n var _this; // for arrow function\n\n return new Promise(async (resolve) => {\n try {\n return resolve(await (".concat(functionText, ").apply(this, arguments));\n } catch (error) {\n return resolve({\n __error: JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error))),\n });\n }\n });"));
|
|
98
98
|
return [4 /*yield*/, page.evaluate.apply(page, __spreadArray([func], args, false))];
|
|
99
99
|
case 1:
|
|
100
100
|
result = (_a.sent());
|
|
@@ -101,7 +101,7 @@ function fileToBase64(path, mime) {
|
|
|
101
101
|
if (!mime) {
|
|
102
102
|
mime = 'application/octet-stream';
|
|
103
103
|
}
|
|
104
|
-
data = "data:"
|
|
104
|
+
data = "data:".concat(mime, ";base64,").concat(base64);
|
|
105
105
|
return [2 /*return*/, data];
|
|
106
106
|
case 3: return [2 /*return*/, false];
|
|
107
107
|
}
|
|
@@ -4,5 +4,4 @@ export { downloadFileToBase64 } from './download-file';
|
|
|
4
4
|
export { stickerSelect, resizeImg } from './select-sticker';
|
|
5
5
|
export { scrapeImg } from './scrape-img-qr';
|
|
6
6
|
export { scrapeLogin } from './scrape-login';
|
|
7
|
-
export { scrapeDesconnected } from './scrape-desconnect';
|
|
8
7
|
export { evaluateAndReturn } from './evaluate-and-return';
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.evaluateAndReturn = exports.
|
|
19
|
+
exports.evaluateAndReturn = exports.scrapeLogin = exports.scrapeImg = exports.resizeImg = exports.stickerSelect = exports.downloadFileToBase64 = exports.base64MimeType = exports.fileToBase64 = void 0;
|
|
20
20
|
var file_to_base64_1 = require("./file-to-base64");
|
|
21
21
|
Object.defineProperty(exports, "fileToBase64", { enumerable: true, get: function () { return file_to_base64_1.fileToBase64; } });
|
|
22
22
|
var base64_mimetype_1 = require("./base64-mimetype");
|
|
@@ -30,7 +30,5 @@ var scrape_img_qr_1 = require("./scrape-img-qr");
|
|
|
30
30
|
Object.defineProperty(exports, "scrapeImg", { enumerable: true, get: function () { return scrape_img_qr_1.scrapeImg; } });
|
|
31
31
|
var scrape_login_1 = require("./scrape-login");
|
|
32
32
|
Object.defineProperty(exports, "scrapeLogin", { enumerable: true, get: function () { return scrape_login_1.scrapeLogin; } });
|
|
33
|
-
var scrape_desconnect_1 = require("./scrape-desconnect");
|
|
34
|
-
Object.defineProperty(exports, "scrapeDesconnected", { enumerable: true, get: function () { return scrape_desconnect_1.scrapeDesconnected; } });
|
|
35
33
|
var evaluate_and_return_1 = require("./evaluate-and-return");
|
|
36
34
|
Object.defineProperty(exports, "evaluateAndReturn", { enumerable: true, get: function () { return evaluate_and_return_1.evaluateAndReturn; } });
|
|
@@ -87,7 +87,7 @@ function stickerSelect(_B, _t) {
|
|
|
87
87
|
case 6:
|
|
88
88
|
metadata = _c.sent();
|
|
89
89
|
if (metadata.width > 512 || metadata.pageHeight > 512) {
|
|
90
|
-
console.error("Invalid image size (max 512x512):"
|
|
90
|
+
console.error("Invalid image size (max 512x512):".concat(metadata.width, "x").concat(metadata.pageHeight));
|
|
91
91
|
return [2 /*return*/, false];
|
|
92
92
|
}
|
|
93
93
|
_b = {};
|
|
@@ -122,7 +122,12 @@ var ControlsLayer = /** @class */ (function (_super) {
|
|
|
122
122
|
ControlsLayer.prototype.markUnseenMessage = function (contactId) {
|
|
123
123
|
return __awaiter(this, void 0, void 0, function () {
|
|
124
124
|
return __generator(this, function (_a) {
|
|
125
|
-
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (contactId) { return WPP.chat.markIsUnread(contactId); }, contactId)];
|
|
127
|
+
case 1:
|
|
128
|
+
_a.sent();
|
|
129
|
+
return [2 /*return*/, true];
|
|
130
|
+
}
|
|
126
131
|
});
|
|
127
132
|
});
|
|
128
133
|
};
|
|
@@ -171,7 +171,7 @@ var HostLayer = /** @class */ (function () {
|
|
|
171
171
|
_this.log('verbose', 'wapi.js injected');
|
|
172
172
|
_this.getWAVersion()
|
|
173
173
|
.then(function (version) {
|
|
174
|
-
_this.log('info', "WhatsApp WEB version: "
|
|
174
|
+
_this.log('info', "WhatsApp WEB version: ".concat(version));
|
|
175
175
|
})
|
|
176
176
|
.catch(function () { return null; });
|
|
177
177
|
})
|
|
@@ -205,7 +205,7 @@ var HostLayer = /** @class */ (function () {
|
|
|
205
205
|
var _this = this;
|
|
206
206
|
if (this.options.autoClose > 0 && !this.autoCloseInterval) {
|
|
207
207
|
var seconds = Math.round(this.options.autoClose / 1000);
|
|
208
|
-
this.log('info', "Auto close configured to "
|
|
208
|
+
this.log('info', "Auto close configured to ".concat(seconds, "s"));
|
|
209
209
|
var remain_1 = seconds;
|
|
210
210
|
this.autoCloseInterval = setInterval(function () {
|
|
211
211
|
if (_this.page.isClosed()) {
|
|
@@ -214,7 +214,7 @@ var HostLayer = /** @class */ (function () {
|
|
|
214
214
|
}
|
|
215
215
|
remain_1 -= 1;
|
|
216
216
|
if (remain_1 % 10 === 0 || remain_1 <= 5) {
|
|
217
|
-
_this.log('http', "Auto close remain: "
|
|
217
|
+
_this.log('http', "Auto close remain: ".concat(remain_1, "s"));
|
|
218
218
|
}
|
|
219
219
|
if (remain_1 <= 0) {
|
|
220
220
|
_this.tryAutoClose();
|
|
@@ -270,10 +270,10 @@ var HostLayer = /** @class */ (function () {
|
|
|
270
270
|
_a.label = 5;
|
|
271
271
|
case 5:
|
|
272
272
|
if (this.options.logQR) {
|
|
273
|
-
this.log('info', "Waiting for QRCode Scan (Attempt "
|
|
273
|
+
this.log('info', "Waiting for QRCode Scan (Attempt ".concat(attempt, ")...:\n").concat(qr), { code: urlCode });
|
|
274
274
|
}
|
|
275
275
|
else {
|
|
276
|
-
this.log('verbose', "Waiting for QRCode Scan: Attempt "
|
|
276
|
+
this.log('verbose', "Waiting for QRCode Scan: Attempt ".concat(attempt));
|
|
277
277
|
}
|
|
278
278
|
if (catchQR) {
|
|
279
279
|
catchQR(result.base64Image, qr, attempt, result.urlCode);
|
|
@@ -510,7 +510,7 @@ var HostLayer = /** @class */ (function () {
|
|
|
510
510
|
switch (_a.label) {
|
|
511
511
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
|
|
512
512
|
//@ts-ignore
|
|
513
|
-
return
|
|
513
|
+
return WPP.whatsapp.State.state;
|
|
514
514
|
})];
|
|
515
515
|
case 1: return [2 /*return*/, _a.sent()];
|
|
516
516
|
}
|
|
@@ -89,7 +89,7 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
89
89
|
_this.page = page;
|
|
90
90
|
_this.listenerEmitter = new events_1.EventEmitter();
|
|
91
91
|
_this.listenerEmitter.on(exposed_enum_1.ExposedFn.onInterfaceChange, function (state) {
|
|
92
|
-
_this.log('http', "Current state: "
|
|
92
|
+
_this.log('http', "Current state: ".concat(state.mode, " (").concat(state.displayInfo, ")"));
|
|
93
93
|
});
|
|
94
94
|
return _this;
|
|
95
95
|
}
|
|
@@ -117,7 +117,7 @@ var ListenerLayer = /** @class */ (function (_super) {
|
|
|
117
117
|
case 1:
|
|
118
118
|
has = _b.sent();
|
|
119
119
|
if (!!has) return [3 /*break*/, 3];
|
|
120
|
-
this_1.log('debug', "Exposing "
|
|
120
|
+
this_1.log('debug', "Exposing ".concat(func, " function"));
|
|
121
121
|
return [4 /*yield*/, this_1.page
|
|
122
122
|
.exposeFunction(func, function () {
|
|
123
123
|
var _a;
|
|
@@ -30,7 +30,7 @@ export declare class RetrieverLayer extends SenderLayer {
|
|
|
30
30
|
* @category Blocklist
|
|
31
31
|
* @returns array of [0,1,2,3....]
|
|
32
32
|
*/
|
|
33
|
-
getBlockList(): Promise<
|
|
33
|
+
getBlockList(): Promise<string[]>;
|
|
34
34
|
/**
|
|
35
35
|
* Retrieves all chats
|
|
36
36
|
* @category Chat
|
|
@@ -115,6 +115,9 @@ export declare class RetrieverLayer extends SenderLayer {
|
|
|
115
115
|
getStatus(contactId: string): Promise<import("../model").ContactStatus>;
|
|
116
116
|
/**
|
|
117
117
|
* Checks if a number is a valid whatsapp number
|
|
118
|
+
*
|
|
119
|
+
* Deprecated in favor of checkNumberStatus
|
|
120
|
+
* @deprecated Deprecated in favor of checkNumberStatus
|
|
118
121
|
* @category Contact
|
|
119
122
|
* @param contactId, you need to include the @c.us at the end.
|
|
120
123
|
* @returns contact detial as promise
|
|
@@ -162,7 +162,9 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
162
162
|
return __awaiter(this, void 0, void 0, function () {
|
|
163
163
|
return __generator(this, function (_a) {
|
|
164
164
|
switch (_a.label) {
|
|
165
|
-
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
|
|
165
|
+
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function () {
|
|
166
|
+
return WPP.blocklist.all().map(function (b) { return b.toString(); });
|
|
167
|
+
})];
|
|
166
168
|
case 1: return [2 /*return*/, _a.sent()];
|
|
167
169
|
}
|
|
168
170
|
});
|
|
@@ -361,6 +363,9 @@ var RetrieverLayer = /** @class */ (function (_super) {
|
|
|
361
363
|
};
|
|
362
364
|
/**
|
|
363
365
|
* Checks if a number is a valid whatsapp number
|
|
366
|
+
*
|
|
367
|
+
* Deprecated in favor of checkNumberStatus
|
|
368
|
+
* @deprecated Deprecated in favor of checkNumberStatus
|
|
364
369
|
* @category Contact
|
|
365
370
|
* @param contactId, you need to include the @c.us at the end.
|
|
366
371
|
* @returns contact detial as promise
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListMessageOptions } from '@wppconnect/wa-js/dist/chat';
|
|
1
|
+
import type { ListMessageOptions, TextMessageOptions } from '@wppconnect/wa-js/dist/chat';
|
|
2
2
|
import { Page } from 'puppeteer';
|
|
3
3
|
import { CreateConfig } from '../../config/create-config';
|
|
4
4
|
import { Message, SendFileResult, SendLinkResult, SendStickerResult } from '../model';
|
|
@@ -20,8 +20,30 @@ export declare class SenderLayer extends ListenerLayer {
|
|
|
20
20
|
* @category Chat
|
|
21
21
|
* @param to chat id: xxxxx@us.c
|
|
22
22
|
* @param content text message
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```javascript
|
|
26
|
+
* // Simple message
|
|
27
|
+
* client.sendText('<number>@c.us', 'A simple message');
|
|
28
|
+
*
|
|
29
|
+
* // With buttons
|
|
30
|
+
* client.sendText('<number>@c.us', 'A simple message with buttons', {
|
|
31
|
+
* buttons: [
|
|
32
|
+
* {
|
|
33
|
+
* id: 'your custom id 1',
|
|
34
|
+
* text: 'Some text'
|
|
35
|
+
* },
|
|
36
|
+
* {
|
|
37
|
+
* id: 'another id 2',
|
|
38
|
+
* text: 'Another text'
|
|
39
|
+
* }
|
|
40
|
+
* ],
|
|
41
|
+
* title: 'Title text' // Optional
|
|
42
|
+
* footer: 'Footer text' // Optional
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
23
45
|
*/
|
|
24
|
-
sendText(to: string, content: string): Promise<Message>;
|
|
46
|
+
sendText(to: string, content: string, options?: TextMessageOptions): Promise<Message>;
|
|
25
47
|
/**
|
|
26
48
|
*
|
|
27
49
|
* @category Chat
|
|
@@ -181,7 +203,7 @@ export declare class SenderLayer extends ListenerLayer {
|
|
|
181
203
|
* @param to Chat id
|
|
182
204
|
* @param contactsId Example: 0000@c.us | [000@c.us, 1111@c.us]
|
|
183
205
|
*/
|
|
184
|
-
sendContactVcard(to: string, contactsId: string
|
|
206
|
+
sendContactVcard(to: string, contactsId: string, name?: string): Promise<void>;
|
|
185
207
|
/**
|
|
186
208
|
* Send a list of contact cards
|
|
187
209
|
* @category Chat
|
|
@@ -191,7 +213,7 @@ export declare class SenderLayer extends ListenerLayer {
|
|
|
191
213
|
sendContactVcardList(to: string, contacts: (string | {
|
|
192
214
|
id: string;
|
|
193
215
|
name: string;
|
|
194
|
-
})[]): Promise<
|
|
216
|
+
})[]): Promise<import("@wppconnect/wa-js/dist/chat").SendMessageReturn>;
|
|
195
217
|
/**
|
|
196
218
|
* Forwards array of messages (could be ids or message objects)
|
|
197
219
|
* @category Chat
|
|
@@ -230,19 +252,34 @@ export declare class SenderLayer extends ListenerLayer {
|
|
|
230
252
|
* @category Chat
|
|
231
253
|
* @param chatId chat id: xxxxx@us.c
|
|
232
254
|
*/
|
|
233
|
-
sendSeen(chatId: string): Promise<
|
|
255
|
+
sendSeen(chatId: string): Promise<{
|
|
256
|
+
wid: import("@wppconnect/wa-js/dist/whatsapp").Wid;
|
|
257
|
+
unreadCount: number;
|
|
258
|
+
}>;
|
|
234
259
|
/**
|
|
235
260
|
* Starts typing ('Typing...' state)
|
|
236
261
|
* @category Chat
|
|
237
262
|
* @param chatId
|
|
238
263
|
*/
|
|
239
|
-
startTyping(to: string): Promise<void>;
|
|
264
|
+
startTyping(to: string, duration?: number): Promise<void>;
|
|
240
265
|
/**
|
|
241
266
|
* Stops typing ('Typing...' state)
|
|
242
267
|
* @category Chat
|
|
243
268
|
* @param chatId
|
|
244
269
|
*/
|
|
245
270
|
stopTyping(to: string): Promise<void>;
|
|
271
|
+
/**
|
|
272
|
+
* Starts recording ('Recording...' state)
|
|
273
|
+
* @category Chat
|
|
274
|
+
* @param chatId
|
|
275
|
+
*/
|
|
276
|
+
startRecording(to: string, duration?: number): Promise<void>;
|
|
277
|
+
/**
|
|
278
|
+
* Stops recording ('Recording...' state)
|
|
279
|
+
* @category Chat
|
|
280
|
+
* @param chatId
|
|
281
|
+
*/
|
|
282
|
+
stopRecoring(to: string): Promise<void>;
|
|
246
283
|
/**
|
|
247
284
|
* Update your online presence
|
|
248
285
|
* @category Chat
|
|
@@ -253,7 +290,7 @@ export declare class SenderLayer extends ListenerLayer {
|
|
|
253
290
|
* Sends text with tags
|
|
254
291
|
* @category Chat
|
|
255
292
|
*/
|
|
256
|
-
sendMentioned(to: string, message: string, mentioned: string[]): Promise<
|
|
293
|
+
sendMentioned(to: string, message: string, mentioned: string[]): Promise<import("@wppconnect/wa-js/dist/chat").SendMessageReturn>;
|
|
257
294
|
/**
|
|
258
295
|
* Sends a list message
|
|
259
296
|
*
|
|
@@ -287,9 +324,11 @@ export declare class SenderLayer extends ListenerLayer {
|
|
|
287
324
|
sendListMessage(to: string, options: ListMessageOptions): Promise<void>;
|
|
288
325
|
/**
|
|
289
326
|
* Sets the chat state
|
|
327
|
+
* Deprecated in favor of Use startTyping or startRecording functions
|
|
290
328
|
* @category Chat
|
|
291
329
|
* @param chatState
|
|
292
330
|
* @param chatId
|
|
331
|
+
* @deprecated Deprecated in favor of Use startTyping or startRecording functions
|
|
293
332
|
*/
|
|
294
333
|
setChatState(chatId: string, chatState: ChatState): Promise<void>;
|
|
295
334
|
}
|
|
@@ -30,6 +30,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
30
30
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
31
|
};
|
|
32
32
|
})();
|
|
33
|
+
var __assign = (this && this.__assign) || function () {
|
|
34
|
+
__assign = Object.assign || function(t) {
|
|
35
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
36
|
+
s = arguments[i];
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
}
|
|
40
|
+
return t;
|
|
41
|
+
};
|
|
42
|
+
return __assign.apply(this, arguments);
|
|
43
|
+
};
|
|
33
44
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
34
45
|
if (k2 === undefined) k2 = k;
|
|
35
46
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -130,19 +141,56 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
130
141
|
* @category Chat
|
|
131
142
|
* @param to chat id: xxxxx@us.c
|
|
132
143
|
* @param content text message
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```javascript
|
|
147
|
+
* // Simple message
|
|
148
|
+
* client.sendText('<number>@c.us', 'A simple message');
|
|
149
|
+
*
|
|
150
|
+
* // With buttons
|
|
151
|
+
* client.sendText('<number>@c.us', 'A simple message with buttons', {
|
|
152
|
+
* buttons: [
|
|
153
|
+
* {
|
|
154
|
+
* id: 'your custom id 1',
|
|
155
|
+
* text: 'Some text'
|
|
156
|
+
* },
|
|
157
|
+
* {
|
|
158
|
+
* id: 'another id 2',
|
|
159
|
+
* text: 'Another text'
|
|
160
|
+
* }
|
|
161
|
+
* ],
|
|
162
|
+
* title: 'Title text' // Optional
|
|
163
|
+
* footer: 'Footer text' // Optional
|
|
164
|
+
* });
|
|
165
|
+
* ```
|
|
133
166
|
*/
|
|
134
|
-
SenderLayer.prototype.sendText = function (to, content) {
|
|
167
|
+
SenderLayer.prototype.sendText = function (to, content, options) {
|
|
135
168
|
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
-
var
|
|
169
|
+
var sendResult, result;
|
|
170
|
+
var _this = this;
|
|
137
171
|
return __generator(this, function (_a) {
|
|
138
172
|
switch (_a.label) {
|
|
139
173
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
140
|
-
var to = _a.to, content = _a.content;
|
|
141
|
-
return
|
|
142
|
-
}, { to: to, content: content })];
|
|
174
|
+
var to = _a.to, content = _a.content, options = _a.options;
|
|
175
|
+
return WPP.chat.sendTextMessage(to, content, __assign(__assign({}, options), { waitForAck: true }));
|
|
176
|
+
}, { to: to, content: content, options: options })];
|
|
143
177
|
case 1:
|
|
144
|
-
|
|
145
|
-
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (
|
|
178
|
+
sendResult = _a.sent();
|
|
179
|
+
return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
180
|
+
var messageId = _a.messageId;
|
|
181
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
182
|
+
var _b, _c, _d, _e;
|
|
183
|
+
return __generator(this, function (_f) {
|
|
184
|
+
switch (_f.label) {
|
|
185
|
+
case 0:
|
|
186
|
+
_c = (_b = JSON).parse;
|
|
187
|
+
_e = (_d = JSON).stringify;
|
|
188
|
+
return [4 /*yield*/, WAPI.getMessageById(messageId)];
|
|
189
|
+
case 1: return [2 /*return*/, _c.apply(_b, [_e.apply(_d, [_f.sent()])])];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
}, { messageId: sendResult.id })];
|
|
146
194
|
case 2:
|
|
147
195
|
result = (_a.sent());
|
|
148
196
|
if (result['erro'] == true) {
|
|
@@ -308,17 +356,34 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
308
356
|
*/
|
|
309
357
|
SenderLayer.prototype.sendMessageWithThumb = function (thumb, url, title, description, chatId) {
|
|
310
358
|
return __awaiter(this, void 0, void 0, function () {
|
|
359
|
+
var base64;
|
|
311
360
|
return __generator(this, function (_a) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
361
|
+
switch (_a.label) {
|
|
362
|
+
case 0: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(thumb, [
|
|
363
|
+
'image/gif',
|
|
364
|
+
'image/png',
|
|
365
|
+
'image/jpg',
|
|
366
|
+
'image/jpeg',
|
|
367
|
+
'image/webp',
|
|
368
|
+
])];
|
|
369
|
+
case 1:
|
|
370
|
+
base64 = _a.sent();
|
|
371
|
+
if (!!base64) return [3 /*break*/, 3];
|
|
372
|
+
return [4 /*yield*/, (0, helpers_1.fileToBase64)(thumb)];
|
|
373
|
+
case 2:
|
|
374
|
+
base64 = _a.sent();
|
|
375
|
+
_a.label = 3;
|
|
376
|
+
case 3: return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
377
|
+
var thumb = _a.thumb, url = _a.url, title = _a.title, description = _a.description, chatId = _a.chatId;
|
|
378
|
+
WAPI.sendMessageWithThumb(thumb, url, title, description, chatId);
|
|
379
|
+
}, {
|
|
380
|
+
base64: base64,
|
|
381
|
+
url: url,
|
|
382
|
+
title: title,
|
|
383
|
+
description: description,
|
|
384
|
+
chatId: chatId,
|
|
385
|
+
})];
|
|
386
|
+
}
|
|
322
387
|
});
|
|
323
388
|
});
|
|
324
389
|
};
|
|
@@ -693,13 +758,10 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
693
758
|
switch (_a.label) {
|
|
694
759
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
695
760
|
var to = _a.to, contactsId = _a.contactsId, name = _a.name;
|
|
696
|
-
|
|
761
|
+
WPP.chat.sendVCardContactMessage(to, { id: contactsId, name: name });
|
|
697
762
|
}, { to: to, contactsId: contactsId, name: name })];
|
|
698
763
|
case 1:
|
|
699
764
|
result = _a.sent();
|
|
700
|
-
if (result['erro'] == true) {
|
|
701
|
-
throw result;
|
|
702
|
-
}
|
|
703
765
|
return [2 /*return*/, result];
|
|
704
766
|
}
|
|
705
767
|
});
|
|
@@ -718,13 +780,10 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
718
780
|
switch (_a.label) {
|
|
719
781
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
720
782
|
var to = _a.to, contacts = _a.contacts;
|
|
721
|
-
return
|
|
783
|
+
return WPP.chat.sendVCardContactMessage(to, contacts);
|
|
722
784
|
}, { to: to, contacts: contacts })];
|
|
723
785
|
case 1:
|
|
724
786
|
result = _a.sent();
|
|
725
|
-
if (result['erro'] == true) {
|
|
726
|
-
throw result;
|
|
727
|
-
}
|
|
728
787
|
return [2 /*return*/, result];
|
|
729
788
|
}
|
|
730
789
|
});
|
|
@@ -899,7 +958,7 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
899
958
|
SenderLayer.prototype.sendSeen = function (chatId) {
|
|
900
959
|
return __awaiter(this, void 0, void 0, function () {
|
|
901
960
|
return __generator(this, function (_a) {
|
|
902
|
-
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (chatId) { return
|
|
961
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (chatId) { return WPP.chat.markIsRead(chatId); }, chatId)];
|
|
903
962
|
});
|
|
904
963
|
});
|
|
905
964
|
};
|
|
@@ -908,14 +967,15 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
908
967
|
* @category Chat
|
|
909
968
|
* @param chatId
|
|
910
969
|
*/
|
|
911
|
-
SenderLayer.prototype.startTyping = function (to) {
|
|
970
|
+
SenderLayer.prototype.startTyping = function (to, duration) {
|
|
912
971
|
return __awaiter(this, void 0, void 0, function () {
|
|
913
972
|
return __generator(this, function (_a) {
|
|
914
973
|
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
915
|
-
var to = _a.to;
|
|
916
|
-
return
|
|
974
|
+
var to = _a.to, duration = _a.duration;
|
|
975
|
+
return WPP.chat.markIsComposing(to, duration);
|
|
917
976
|
}, {
|
|
918
977
|
to: to,
|
|
978
|
+
duration: duration,
|
|
919
979
|
})];
|
|
920
980
|
});
|
|
921
981
|
});
|
|
@@ -930,7 +990,42 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
930
990
|
return __generator(this, function (_a) {
|
|
931
991
|
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
932
992
|
var to = _a.to;
|
|
933
|
-
return
|
|
993
|
+
return WPP.chat.markIsPaused(to);
|
|
994
|
+
}, {
|
|
995
|
+
to: to,
|
|
996
|
+
})];
|
|
997
|
+
});
|
|
998
|
+
});
|
|
999
|
+
};
|
|
1000
|
+
/**
|
|
1001
|
+
* Starts recording ('Recording...' state)
|
|
1002
|
+
* @category Chat
|
|
1003
|
+
* @param chatId
|
|
1004
|
+
*/
|
|
1005
|
+
SenderLayer.prototype.startRecording = function (to, duration) {
|
|
1006
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1007
|
+
return __generator(this, function (_a) {
|
|
1008
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
1009
|
+
var to = _a.to, duration = _a.duration;
|
|
1010
|
+
return WPP.chat.markIsRecording(to, duration);
|
|
1011
|
+
}, {
|
|
1012
|
+
to: to,
|
|
1013
|
+
duration: duration,
|
|
1014
|
+
})];
|
|
1015
|
+
});
|
|
1016
|
+
});
|
|
1017
|
+
};
|
|
1018
|
+
/**
|
|
1019
|
+
* Stops recording ('Recording...' state)
|
|
1020
|
+
* @category Chat
|
|
1021
|
+
* @param chatId
|
|
1022
|
+
*/
|
|
1023
|
+
SenderLayer.prototype.stopRecoring = function (to) {
|
|
1024
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1025
|
+
return __generator(this, function (_a) {
|
|
1026
|
+
return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
1027
|
+
var to = _a.to;
|
|
1028
|
+
return WPP.chat.markIsPaused(to);
|
|
934
1029
|
}, {
|
|
935
1030
|
to: to,
|
|
936
1031
|
})];
|
|
@@ -965,7 +1060,10 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
965
1060
|
switch (_a.label) {
|
|
966
1061
|
case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
|
|
967
1062
|
var to = _a.to, message = _a.message, mentioned = _a.mentioned;
|
|
968
|
-
|
|
1063
|
+
return WPP.chat.sendTextMessage(to, message, {
|
|
1064
|
+
detectMentioned: true,
|
|
1065
|
+
mentionedList: mentioned,
|
|
1066
|
+
});
|
|
969
1067
|
}, { to: to, message: message, mentioned: mentioned })];
|
|
970
1068
|
case 1: return [2 /*return*/, _a.sent()];
|
|
971
1069
|
}
|
|
@@ -1017,9 +1115,11 @@ var SenderLayer = /** @class */ (function (_super) {
|
|
|
1017
1115
|
};
|
|
1018
1116
|
/**
|
|
1019
1117
|
* Sets the chat state
|
|
1118
|
+
* Deprecated in favor of Use startTyping or startRecording functions
|
|
1020
1119
|
* @category Chat
|
|
1021
1120
|
* @param chatState
|
|
1022
1121
|
* @param chatId
|
|
1122
|
+
* @deprecated Deprecated in favor of Use startTyping or startRecording functions
|
|
1023
1123
|
*/
|
|
1024
1124
|
SenderLayer.prototype.setChatState = function (chatId, chatState) {
|
|
1025
1125
|
return __awaiter(this, void 0, void 0, function () {
|