@wppconnect-team/wppconnect 1.13.1 → 1.14.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.
@@ -116,25 +116,29 @@ var SenderLayer = /** @class */ (function (_super) {
116
116
  }
117
117
  /**
118
118
  * Automatically sends a link with the auto generated link preview. You can also add a custom message to be added.
119
+ *
120
+ * Deprecated: please use {@link sendText}
121
+ *
119
122
  * @category Chat
123
+ * @deprecated
120
124
  * @param chatId
121
125
  * @param url string A link, for example for youtube. e.g https://www.youtube.com/watch?v=Zi_XLOBDo_Y&list=RDEMe12_MlgO8mGFdeeftZ2nOQ&start_radio=1
122
- * @param title custom text as the message body, this includes the link or will be attached after the link
126
+ * @param text custom text as the message body, this includes the link or will be attached after the link
123
127
  */
124
- SenderLayer.prototype.sendLinkPreview = function (chatId, url, title) {
128
+ SenderLayer.prototype.sendLinkPreview = function (chatId, url, text) {
129
+ if (text === void 0) { text = ''; }
125
130
  return __awaiter(this, void 0, void 0, function () {
126
- var result;
131
+ var message, result;
127
132
  return __generator(this, function (_a) {
128
133
  switch (_a.label) {
129
- case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
130
- var chatId = _a.chatId, url = _a.url, title = _a.title;
131
- return WAPI.sendLinkPreview(chatId, url, title);
132
- }, { chatId: chatId, url: url, title: title })];
134
+ case 0:
135
+ message = text.includes(url) ? text : "".concat(url, "\n").concat(text);
136
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
137
+ var chatId = _a.chatId, message = _a.message;
138
+ return WPP.chat.sendTextMessage(chatId, message, { linkPreview: true });
139
+ }, { chatId: chatId, message: message })];
133
140
  case 1:
134
141
  result = _a.sent();
135
- if (result['erro'] == true) {
136
- throw result;
137
- }
138
142
  return [2 /*return*/, result];
139
143
  }
140
144
  });
@@ -352,48 +356,94 @@ var SenderLayer = /** @class */ (function (_super) {
352
356
  };
353
357
  /**
354
358
  * Sends message with thumbnail
359
+ *
360
+ * @deprecated: please use {@link sendText} with options
361
+ *
362
+ * @deprecated
355
363
  * @category Chat
356
- * @param thumb
364
+ * @param pathOrBase64
357
365
  * @param url
358
366
  * @param title
359
367
  * @param description
360
368
  * @param chatId
361
369
  */
362
- SenderLayer.prototype.sendMessageWithThumb = function (thumb, url, title, description, chatId) {
370
+ SenderLayer.prototype.sendMessageWithThumb = function (pathOrBase64, url, title, description, chatId) {
363
371
  return __awaiter(this, void 0, void 0, function () {
364
- var base64;
372
+ var base64, fileContent, error, mimeInfo, error, thumbnail;
365
373
  return __generator(this, function (_a) {
366
374
  switch (_a.label) {
367
- case 0: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(thumb, [
375
+ case 0:
376
+ base64 = '';
377
+ if (!pathOrBase64.startsWith('data:')) return [3 /*break*/, 1];
378
+ base64 = pathOrBase64;
379
+ return [3 /*break*/, 5];
380
+ case 1: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(pathOrBase64, [
368
381
  'image/gif',
369
382
  'image/png',
370
383
  'image/jpg',
371
384
  'image/jpeg',
372
385
  'image/webp',
373
386
  ])];
374
- case 1:
375
- base64 = _a.sent();
376
- if (!!base64) return [3 /*break*/, 3];
377
- return [4 /*yield*/, (0, helpers_1.fileToBase64)(thumb)];
378
387
  case 2:
379
- base64 = _a.sent();
380
- _a.label = 3;
381
- case 3: return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
382
- var thumb = _a.thumb, url = _a.url, title = _a.title, description = _a.description, chatId = _a.chatId;
383
- WAPI.sendMessageWithThumb(thumb, url, title, description, chatId);
384
- }, {
385
- base64: base64,
386
- url: url,
387
- title: title,
388
- description: description,
389
- chatId: chatId,
390
- })];
388
+ fileContent = _a.sent();
389
+ if (!!fileContent) return [3 /*break*/, 4];
390
+ return [4 /*yield*/, (0, helpers_1.fileToBase64)(pathOrBase64)];
391
+ case 3:
392
+ fileContent = _a.sent();
393
+ _a.label = 4;
394
+ case 4:
395
+ if (fileContent) {
396
+ base64 = fileContent;
397
+ }
398
+ _a.label = 5;
399
+ case 5:
400
+ if (!base64) {
401
+ error = new Error('Empty or invalid file or base64');
402
+ Object.assign(error, {
403
+ code: 'empty_file',
404
+ });
405
+ throw error;
406
+ }
407
+ mimeInfo = (0, helpers_1.base64MimeType)(base64);
408
+ if (!mimeInfo || !mimeInfo.includes('image')) {
409
+ error = new Error('Not an image, allowed formats png, jpeg, webp and gif');
410
+ Object.assign(error, {
411
+ code: 'invalid_image',
412
+ });
413
+ throw error;
414
+ }
415
+ thumbnail = base64.replace(/^data:image\/(png|jpe?g|webp|gif);base64,/, '');
416
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
417
+ var thumbnail = _a.thumbnail, url = _a.url, title = _a.title, description = _a.description, chatId = _a.chatId;
418
+ return WPP.chat.sendTextMessage(chatId, url, {
419
+ linkPreview: {
420
+ thumbnail: thumbnail,
421
+ canonicalUrl: url,
422
+ description: description,
423
+ matchedText: url,
424
+ title: title,
425
+ richPreviewType: 0,
426
+ doNotPlayInline: true,
427
+ },
428
+ });
429
+ }, {
430
+ thumbnail: thumbnail,
431
+ url: url,
432
+ title: title,
433
+ description: description,
434
+ chatId: chatId,
435
+ })];
391
436
  }
392
437
  });
393
438
  });
394
439
  };
395
440
  /**
396
441
  * Replies to given mesage id of given chat id
442
+ *
443
+ * Deprecated: Please, use sendText with quotedMsg option
444
+ *
445
+ * @deprecated
446
+ *
397
447
  * @category Chat
398
448
  * @param to Chat id
399
449
  * @param content Message body
@@ -521,86 +571,86 @@ var SenderLayer = /** @class */ (function (_super) {
521
571
  /**
522
572
  * Sends file
523
573
  * base64 parameter should have mime type already defined
574
+ *
575
+ * Deprecated: please use sendFile with options: sendFile(to, content, options)
576
+ *
577
+ * @deprecated
578
+ *
524
579
  * @category Chat
525
- * @param to Chat id
580
+ * @param chatId Chat id
526
581
  * @param base64 base64 data
527
582
  * @param filename
528
583
  * @param caption
529
584
  */
530
- SenderLayer.prototype.sendFileFromBase64 = function (to, base64, filename, caption) {
585
+ SenderLayer.prototype.sendFileFromBase64 = function (chatId, base64, filename, caption) {
531
586
  return __awaiter(this, void 0, void 0, function () {
532
- var mimeType, obj, type, result;
533
587
  return __generator(this, function (_a) {
534
- switch (_a.label) {
535
- case 0:
536
- mimeType = (0, helpers_1.base64MimeType)(base64);
537
- if (!mimeType) {
538
- obj = {
539
- erro: true,
540
- to: to,
541
- text: 'Invalid base64!',
542
- };
543
- throw obj;
544
- }
545
- filename = (0, filename_from_mimetype_1.filenameFromMimeType)(filename, mimeType);
546
- type = 'FileFromBase64';
547
- return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
548
- var to = _a.to, base64 = _a.base64, filename = _a.filename, caption = _a.caption, type = _a.type;
549
- return WAPI.sendFile(base64, to, filename, caption, type);
550
- }, { to: to, base64: base64, filename: filename, caption: caption, type: type })];
551
- case 1:
552
- result = _a.sent();
553
- if (result['erro'] == true) {
554
- throw result;
555
- }
556
- return [2 /*return*/, result];
557
- }
588
+ return [2 /*return*/, this.sendFile(chatId, base64, filename, caption)];
558
589
  });
559
590
  });
560
591
  };
561
- /**
562
- * Sends file from path
563
- * @category Chat
564
- * @param to Chat id
565
- * @param filePath File path
566
- * @param filename
567
- * @param caption
568
- */
569
- SenderLayer.prototype.sendFile = function (to, filePath, filename, caption) {
592
+ SenderLayer.prototype.sendFile = function (to, pathOrBase64, nameOrOptions, caption) {
570
593
  return __awaiter(this, void 0, void 0, function () {
594
+ var options, base64, fileContent, error;
571
595
  var _this = this;
572
596
  return __generator(this, function (_a) {
573
- return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
574
- var base64, obj;
575
- return __generator(this, function (_a) {
576
- switch (_a.label) {
577
- case 0: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(filePath)];
578
- case 1:
579
- base64 = _a.sent();
580
- if (!!base64) return [3 /*break*/, 3];
581
- return [4 /*yield*/, (0, helpers_1.fileToBase64)(filePath)];
582
- case 2:
583
- base64 = _a.sent();
584
- _a.label = 3;
585
- case 3:
586
- if (!base64) {
587
- obj = {
588
- erro: true,
589
- to: to,
590
- text: 'No such file or directory, open "' + filePath + '"',
591
- };
592
- return [2 /*return*/, reject(obj)];
593
- }
594
- if (!filename) {
595
- filename = path.basename(filePath);
596
- }
597
- this.sendFileFromBase64(to, base64, filename, caption)
598
- .then(resolve)
599
- .catch(reject);
600
- return [2 /*return*/];
601
- }
602
- });
603
- }); })];
597
+ switch (_a.label) {
598
+ case 0:
599
+ options = { type: 'auto-detect' };
600
+ if (typeof nameOrOptions === 'string') {
601
+ options.filename = nameOrOptions;
602
+ options.caption = caption;
603
+ }
604
+ else if (typeof nameOrOptions === 'object') {
605
+ options = nameOrOptions;
606
+ }
607
+ base64 = '';
608
+ if (!pathOrBase64.startsWith('data:')) return [3 /*break*/, 1];
609
+ base64 = pathOrBase64;
610
+ return [3 /*break*/, 5];
611
+ case 1: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(pathOrBase64)];
612
+ case 2:
613
+ fileContent = _a.sent();
614
+ if (!!fileContent) return [3 /*break*/, 4];
615
+ return [4 /*yield*/, (0, helpers_1.fileToBase64)(pathOrBase64)];
616
+ case 3:
617
+ fileContent = _a.sent();
618
+ _a.label = 4;
619
+ case 4:
620
+ if (fileContent) {
621
+ base64 = fileContent;
622
+ }
623
+ _a.label = 5;
624
+ case 5:
625
+ if (!base64) {
626
+ error = new Error('Empty or invalid file or base64');
627
+ Object.assign(error, {
628
+ code: 'empty_file',
629
+ });
630
+ throw error;
631
+ }
632
+ return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
633
+ var to = _a.to, base64 = _a.base64, options = _a.options;
634
+ return __awaiter(_this, void 0, void 0, function () {
635
+ var result;
636
+ var _b;
637
+ return __generator(this, function (_c) {
638
+ switch (_c.label) {
639
+ case 0: return [4 /*yield*/, WPP.chat.sendFileMessage(to, base64, options)];
640
+ case 1:
641
+ result = _c.sent();
642
+ _b = {
643
+ ack: result.ack,
644
+ id: result.id
645
+ };
646
+ return [4 /*yield*/, result.sendMsgResult];
647
+ case 2: return [2 /*return*/, (_b.sendMsgResult = _c.sent(),
648
+ _b)];
649
+ }
650
+ });
651
+ });
652
+ }, { to: to, base64: base64, options: options })];
653
+ }
604
654
  });
605
655
  });
606
656
  };
@@ -818,52 +868,70 @@ var SenderLayer = /** @class */ (function (_super) {
818
868
  /**
819
869
  * Generates sticker from the provided animated gif image and sends it (Send image as animated sticker)
820
870
  * @category Chat
821
- * @param path image path imageBase64 A valid gif image is required. You can also send via http/https (http://www.website.com/img.gif)
822
- * @param to chatId '000000000000@c.us'
871
+ * @param pathOrBase64 image path imageBase64 A valid gif image is required. You can also send via http/https (http://www.website.com/img.gif)
872
+ * @param to chatId '000000000000@c.us'
823
873
  */
824
- SenderLayer.prototype.sendImageAsStickerGif = function (to, path) {
874
+ SenderLayer.prototype.sendImageAsStickerGif = function (to, pathOrBase64) {
825
875
  return __awaiter(this, void 0, void 0, function () {
826
- var b64, buff, mimeInfo, obj, _webb64, _met, result;
876
+ var base64, fileContent, error, mimeInfo, error, buff, obj, error, webpBase64;
827
877
  return __generator(this, function (_a) {
828
878
  switch (_a.label) {
829
- case 0: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(path, ['image/gif', 'image/webp'])];
830
- case 1:
831
- b64 = _a.sent();
832
- if (!!b64) return [3 /*break*/, 3];
833
- return [4 /*yield*/, (0, helpers_1.fileToBase64)(path)];
879
+ case 0:
880
+ base64 = '';
881
+ if (!pathOrBase64.startsWith('data:')) return [3 /*break*/, 1];
882
+ base64 = pathOrBase64;
883
+ return [3 /*break*/, 5];
884
+ case 1: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(pathOrBase64, [
885
+ 'image/gif',
886
+ 'image/webp',
887
+ ])];
834
888
  case 2:
835
- b64 = _a.sent();
836
- _a.label = 3;
889
+ fileContent = _a.sent();
890
+ if (!!fileContent) return [3 /*break*/, 4];
891
+ return [4 /*yield*/, (0, helpers_1.fileToBase64)(pathOrBase64)];
837
892
  case 3:
838
- if (!b64) return [3 /*break*/, 9];
839
- buff = Buffer.from(b64.replace(/^data:image\/(gif|webp);base64,/, ''), 'base64');
840
- mimeInfo = (0, helpers_1.base64MimeType)(b64);
841
- if (!(!mimeInfo || mimeInfo.includes('image'))) return [3 /*break*/, 8];
842
- return [4 /*yield*/, (0, helpers_1.stickerSelect)(buff, 1)];
893
+ fileContent = _a.sent();
894
+ _a.label = 4;
843
895
  case 4:
844
- obj = _a.sent();
845
- if (!(typeof obj == 'object')) return [3 /*break*/, 6];
846
- _webb64 = obj['webpBase64'];
847
- _met = obj['metadata'];
848
- return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
849
- var _webb64 = _a._webb64, to = _a.to, _met = _a._met;
850
- return WAPI.sendImageAsSticker(_webb64, to, _met, 'StickerGif');
851
- }, { _webb64: _webb64, to: to, _met: _met })];
896
+ if (fileContent) {
897
+ base64 = fileContent;
898
+ }
899
+ _a.label = 5;
852
900
  case 5:
853
- result = _a.sent();
854
- if (result['erro'] == true) {
855
- throw result;
901
+ if (!base64) {
902
+ error = new Error('Empty or invalid file or base64');
903
+ Object.assign(error, {
904
+ code: 'empty_file',
905
+ });
906
+ throw error;
856
907
  }
857
- return [2 /*return*/, result];
858
- case 6: throw {
859
- error: true,
860
- message: 'Error with sharp library, check the console log',
861
- };
862
- case 7: return [3 /*break*/, 9];
863
- case 8:
864
- console.log('Not an image, allowed format gif');
865
- return [2 /*return*/, false];
866
- case 9: return [2 /*return*/];
908
+ mimeInfo = (0, helpers_1.base64MimeType)(base64);
909
+ if (!mimeInfo || !mimeInfo.includes('image')) {
910
+ error = new Error('Not an image, allowed formats gig and webp');
911
+ Object.assign(error, {
912
+ code: 'invalid_image',
913
+ });
914
+ throw error;
915
+ }
916
+ buff = Buffer.from(base64.replace(/^data:image\/(gif|webp);base64,/, ''), 'base64');
917
+ return [4 /*yield*/, (0, helpers_1.stickerSelect)(buff, 1)];
918
+ case 6:
919
+ obj = _a.sent();
920
+ if (!obj) {
921
+ error = new Error('Error with sharp library, check the console log');
922
+ Object.assign(error, {
923
+ code: 'sharp_error',
924
+ });
925
+ throw error;
926
+ }
927
+ webpBase64 = obj.webpBase64;
928
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
929
+ var to = _a.to, webpBase64 = _a.webpBase64;
930
+ return WPP.chat.sendFileMessage(to, webpBase64, {
931
+ type: 'sticker',
932
+ });
933
+ }, { to: to, webpBase64: webpBase64 })];
934
+ case 7: return [2 /*return*/, _a.sent()];
867
935
  }
868
936
  });
869
937
  });
@@ -871,89 +939,113 @@ var SenderLayer = /** @class */ (function (_super) {
871
939
  /**
872
940
  * Generates sticker from given image and sends it (Send Image As Sticker)
873
941
  * @category Chat
874
- * @param path image path imageBase64 A valid png, jpg and webp image is required. You can also send via http/https (http://www.website.com/img.gif)
942
+ * @param pathOrBase64 image path imageBase64 A valid png, jpg and webp image is required. You can also send via http/https (http://www.website.com/img.gif)
875
943
  * @param to chatId '000000000000@c.us'
876
944
  */
877
- SenderLayer.prototype.sendImageAsSticker = function (to, path) {
945
+ SenderLayer.prototype.sendImageAsSticker = function (to, pathOrBase64) {
878
946
  return __awaiter(this, void 0, void 0, function () {
879
- var b64, buff, mimeInfo, obj, _webb64, _met, result;
947
+ var base64, fileContent, error, mimeInfo, error, buff, obj, error, webpBase64;
880
948
  return __generator(this, function (_a) {
881
949
  switch (_a.label) {
882
- case 0: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(path, [
950
+ case 0:
951
+ base64 = '';
952
+ if (!pathOrBase64.startsWith('data:')) return [3 /*break*/, 1];
953
+ base64 = pathOrBase64;
954
+ return [3 /*break*/, 5];
955
+ case 1: return [4 /*yield*/, (0, helpers_1.downloadFileToBase64)(pathOrBase64, [
883
956
  'image/gif',
884
957
  'image/png',
885
958
  'image/jpg',
886
959
  'image/jpeg',
887
960
  'image/webp',
888
961
  ])];
889
- case 1:
890
- b64 = _a.sent();
891
- if (!!b64) return [3 /*break*/, 3];
892
- return [4 /*yield*/, (0, helpers_1.fileToBase64)(path)];
893
962
  case 2:
894
- b64 = _a.sent();
895
- _a.label = 3;
963
+ fileContent = _a.sent();
964
+ if (!!fileContent) return [3 /*break*/, 4];
965
+ return [4 /*yield*/, (0, helpers_1.fileToBase64)(pathOrBase64)];
896
966
  case 3:
897
- if (!b64) return [3 /*break*/, 9];
898
- buff = Buffer.from(b64.replace(/^data:image\/(png|jpe?g|webp|gif);base64,/, ''), 'base64');
899
- mimeInfo = (0, helpers_1.base64MimeType)(b64);
900
- if (!(!mimeInfo || mimeInfo.includes('image'))) return [3 /*break*/, 8];
901
- return [4 /*yield*/, (0, helpers_1.stickerSelect)(buff, 0)];
967
+ fileContent = _a.sent();
968
+ _a.label = 4;
902
969
  case 4:
903
- obj = _a.sent();
904
- if (!(typeof obj == 'object')) return [3 /*break*/, 6];
905
- _webb64 = obj['webpBase64'];
906
- _met = obj['metadata'];
907
- return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
908
- var _webb64 = _a._webb64, to = _a.to, _met = _a._met;
909
- return WAPI.sendImageAsSticker(_webb64, to, _met, 'Sticker');
910
- }, { _webb64: _webb64, to: to, _met: _met })];
970
+ if (fileContent) {
971
+ base64 = fileContent;
972
+ }
973
+ _a.label = 5;
911
974
  case 5:
912
- result = _a.sent();
913
- if (result['erro'] == true) {
914
- throw result;
975
+ if (!base64) {
976
+ error = new Error('Empty or invalid file or base64');
977
+ Object.assign(error, {
978
+ code: 'empty_file',
979
+ });
980
+ throw error;
915
981
  }
916
- return [2 /*return*/, result];
917
- case 6: throw {
918
- error: true,
919
- message: 'Error with sharp library, check the console log',
920
- };
921
- case 7: return [3 /*break*/, 9];
922
- case 8:
923
- console.log('Not an image, allowed formats png, jpeg and webp');
924
- return [2 /*return*/, false];
925
- case 9: return [2 /*return*/];
982
+ mimeInfo = (0, helpers_1.base64MimeType)(base64);
983
+ if (!mimeInfo || !mimeInfo.includes('image')) {
984
+ error = new Error('Not an image, allowed formats png, jpeg, webp and gif');
985
+ Object.assign(error, {
986
+ code: 'invalid_image',
987
+ });
988
+ throw error;
989
+ }
990
+ buff = Buffer.from(base64.replace(/^data:image\/(png|jpe?g|webp|gif);base64,/, ''), 'base64');
991
+ return [4 /*yield*/, (0, helpers_1.stickerSelect)(buff, 0)];
992
+ case 6:
993
+ obj = _a.sent();
994
+ if (!obj) {
995
+ error = new Error('Error with sharp library, check the console log');
996
+ Object.assign(error, {
997
+ code: 'sharp_error',
998
+ });
999
+ throw error;
1000
+ }
1001
+ webpBase64 = obj.webpBase64;
1002
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
1003
+ var to = _a.to, webpBase64 = _a.webpBase64;
1004
+ return WPP.chat.sendFileMessage(to, webpBase64, {
1005
+ type: 'sticker',
1006
+ });
1007
+ }, { to: to, webpBase64: webpBase64 })];
1008
+ case 7: return [2 /*return*/, _a.sent()];
926
1009
  }
927
1010
  });
928
1011
  });
929
1012
  };
930
- /**
931
- * TODO: Fix message not being delivered
932
- * Sends location to given chat id
933
- * @category Chat
934
- * @param to Chat id
935
- * @param latitude Latitude
936
- * @param longitude Longitude
937
- * @param title Text caption
938
- */
939
- SenderLayer.prototype.sendLocation = function (to, latitude, longitude, title) {
1013
+ SenderLayer.prototype.sendLocation = function (to, latitudeOrOptions, longitude, title) {
940
1014
  return __awaiter(this, void 0, void 0, function () {
941
- var result;
1015
+ var options;
1016
+ var _this = this;
942
1017
  return __generator(this, function (_a) {
943
1018
  switch (_a.label) {
944
- case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
945
- var to = _a.to, latitude = _a.latitude, longitude = _a.longitude, title = _a.title;
946
- return WAPI.sendLocation(to, latitude, longitude, title);
947
- }, { to: to, latitude: latitude, longitude: longitude, title: title })];
948
- case 1:
949
- result = _a.sent();
950
- if (result['erro'] == true) {
951
- throw result;
952
- }
953
- else {
954
- return [2 /*return*/, result];
955
- }
956
- return [2 /*return*/];
1019
+ case 0:
1020
+ options = typeof latitudeOrOptions === 'string'
1021
+ ? {
1022
+ lat: latitudeOrOptions,
1023
+ lng: longitude,
1024
+ title: title,
1025
+ }
1026
+ : latitudeOrOptions;
1027
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
1028
+ var to = _a.to, options = _a.options;
1029
+ return __awaiter(_this, void 0, void 0, function () {
1030
+ var result;
1031
+ var _b;
1032
+ return __generator(this, function (_c) {
1033
+ switch (_c.label) {
1034
+ case 0: return [4 /*yield*/, WPP.chat.sendLocationMessage(to, options)];
1035
+ case 1:
1036
+ result = _c.sent();
1037
+ _b = {
1038
+ ack: result.ack,
1039
+ id: result.id
1040
+ };
1041
+ return [4 /*yield*/, result.sendMsgResult];
1042
+ case 2: return [2 /*return*/, (_b.sendMsgResult = _c.sent(),
1043
+ _b)];
1044
+ }
1045
+ });
1046
+ });
1047
+ }, { to: to, options: options })];
1048
+ case 1: return [2 /*return*/, _a.sent()];
957
1049
  }
958
1050
  });
959
1051
  });
@@ -972,8 +1064,18 @@ var SenderLayer = /** @class */ (function (_super) {
972
1064
  };
973
1065
  /**
974
1066
  * Starts typing ('Typing...' state)
1067
+ *
1068
+ * @example
1069
+ * ```javascript
1070
+ * // Keep sending typing state, use stopTyping to finish
1071
+ * await client.startTyping('[number]@c.us');
1072
+ *
1073
+ * // Keep sending typing state for 5 seconds
1074
+ * await client.startTyping('[number]@c.us', 5000);
1075
+ * ```
975
1076
  * @category Chat
976
- * @param chatId
1077
+ * @param to Chat Id
1078
+ * @param duration Duration um miliseconds
977
1079
  */
978
1080
  SenderLayer.prototype.startTyping = function (to, duration) {
979
1081
  return __awaiter(this, void 0, void 0, function () {
@@ -991,7 +1093,7 @@ var SenderLayer = /** @class */ (function (_super) {
991
1093
  /**
992
1094
  * Stops typing ('Typing...' state)
993
1095
  * @category Chat
994
- * @param chatId
1096
+ * @param to Chat Id
995
1097
  */
996
1098
  SenderLayer.prototype.stopTyping = function (to) {
997
1099
  return __awaiter(this, void 0, void 0, function () {
@@ -1007,8 +1109,17 @@ var SenderLayer = /** @class */ (function (_super) {
1007
1109
  };
1008
1110
  /**
1009
1111
  * Starts recording ('Recording...' state)
1112
+ * @example
1113
+ * ```javascript
1114
+ * // Keep sending recording state, use stopRecoring to finish
1115
+ * await client.startRecording('[number]@c.us');
1116
+ *
1117
+ * // Keep sending typing state for 5 seconds
1118
+ * await client.startRecording('[number]@c.us', 5000);
1119
+ * ```
1010
1120
  * @category Chat
1011
- * @param chatId
1121
+ * @param to Chat Id
1122
+ * @param duration Duration um miliseconds
1012
1123
  */
1013
1124
  SenderLayer.prototype.startRecording = function (to, duration) {
1014
1125
  return __awaiter(this, void 0, void 0, function () {
@@ -1026,7 +1137,7 @@ var SenderLayer = /** @class */ (function (_super) {
1026
1137
  /**
1027
1138
  * Stops recording ('Recording...' state)
1028
1139
  * @category Chat
1029
- * @param chatId
1140
+ * @param to Chat Id
1030
1141
  */
1031
1142
  SenderLayer.prototype.stopRecoring = function (to) {
1032
1143
  return __awaiter(this, void 0, void 0, function () {