@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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ # 1.14.0 (2022-06-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @wppconnect/wa-js to ^2.6.0 ([27d5a52](https://github.com/wppconnect-team/wppconnect/commit/27d5a523c1dfa1a22c8be08cd7ff6d03af1fc0b1))
7
+
8
+
9
+
10
+ ## 1.13.3 (2022-06-01)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Clear all token data when disconnected (fix [#1147](https://github.com/wppconnect-team/wppconnect/issues/1147)) ([4abcfed](https://github.com/wppconnect-team/wppconnect/commit/4abcfed97778ddb619df65fec0b1c3d0dc4debac))
16
+
17
+
18
+
19
+ ## 1.13.2 (2022-05-28)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * Migrate archiveChat and pinChat methods to WA-JS ([cee7e1c](https://github.com/wppconnect-team/wppconnect/commit/cee7e1ced23409d66365e42a35602265e0c09536))
25
+
26
+
27
+
1
28
  ## 1.13.1 (2022-05-10)
2
29
 
3
30
 
@@ -71,7 +71,7 @@ exports.mediaTypes = {
71
71
  };
72
72
  var processUA = function (userAgent) {
73
73
  var ua = userAgent ||
74
- 'WhatsApp/2.16.352 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36';
74
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36';
75
75
  if (!ua.includes('WhatsApp'))
76
76
  ua = 'WhatsApp/2.16.352 ' + ua;
77
77
  return ua;
@@ -39,7 +39,10 @@ export declare class ControlsLayer extends UILayer {
39
39
  * @param option {boolean} true or false
40
40
  * @returns boolean
41
41
  */
42
- archiveChat(chatId: string, option?: boolean): Promise<boolean>;
42
+ archiveChat(chatId: string, option?: boolean): Promise<{
43
+ wid: import("@wppconnect/wa-js/dist/whatsapp").Wid;
44
+ archive: boolean;
45
+ }>;
43
46
  /**
44
47
  * Pin and Unpin chat messages with true or false
45
48
  * @category Chat
@@ -48,7 +51,10 @@ export declare class ControlsLayer extends UILayer {
48
51
  * @param nonExistent {boolean} Pin chat, non-existent (optional)
49
52
  * @returns object
50
53
  */
51
- pinChat(chatId: string, option: boolean, nonExistent?: boolean): Promise<object>;
54
+ pinChat(chatId: string, option: boolean, nonExistent?: boolean): Promise<{
55
+ wid: import("@wppconnect/wa-js/dist/whatsapp").Wid;
56
+ pin: boolean;
57
+ }>;
52
58
  /**
53
59
  * Deletes all messages of given chat
54
60
  * @category Chat
@@ -163,7 +163,7 @@ var ControlsLayer = /** @class */ (function (_super) {
163
163
  return __generator(this, function (_a) {
164
164
  return [2 /*return*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
165
165
  var chatId = _a.chatId, option = _a.option;
166
- return WAPI.archiveChat(chatId, option);
166
+ return WPP.chat.archive(chatId, option);
167
167
  }, { chatId: chatId, option: option })];
168
168
  });
169
169
  });
@@ -178,19 +178,22 @@ var ControlsLayer = /** @class */ (function (_super) {
178
178
  */
179
179
  ControlsLayer.prototype.pinChat = function (chatId, option, nonExistent) {
180
180
  return __awaiter(this, void 0, void 0, function () {
181
- var result;
182
181
  return __generator(this, function (_a) {
183
182
  switch (_a.label) {
184
- case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
185
- var chatId = _a.chatId, option = _a.option, nonExistent = _a.nonExistent;
186
- return WAPI.pinChat(chatId, option, nonExistent);
187
- }, { chatId: chatId, option: option, nonExistent: nonExistent })];
183
+ case 0:
184
+ if (!nonExistent) return [3 /*break*/, 2];
185
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
186
+ var chatId = _a.chatId;
187
+ return WPP.chat.find(chatId);
188
+ }, { chatId: chatId })];
188
189
  case 1:
189
- result = _a.sent();
190
- if (result['erro'] == true) {
191
- throw result;
192
- }
193
- return [2 /*return*/, result];
190
+ _a.sent();
191
+ _a.label = 2;
192
+ case 2: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
193
+ var chatId = _a.chatId, option = _a.option;
194
+ return WPP.chat.pin(chatId, option);
195
+ }, { chatId: chatId, option: option })];
196
+ case 3: return [2 /*return*/, _a.sent()];
194
197
  }
195
198
  });
196
199
  });
@@ -1,7 +1,7 @@
1
- import type { ListMessageOptions, TextMessageOptions } from '@wppconnect/wa-js/dist/chat';
1
+ import type { FileMessageOptions, ListMessageOptions, LocationMessageOptions, SendMessageReturn, TextMessageOptions } from '@wppconnect/wa-js/dist/chat';
2
2
  import { Page } from 'puppeteer';
3
3
  import { CreateConfig } from '../../config/create-config';
4
- import { Message, SendFileResult, SendLinkResult, SendStickerResult } from '../model';
4
+ import { Message } from '../model';
5
5
  import { ChatState } from '../model/enum';
6
6
  import { ListenerLayer } from './listener.layer';
7
7
  export declare class SenderLayer extends ListenerLayer {
@@ -9,12 +9,16 @@ export declare class SenderLayer extends ListenerLayer {
9
9
  constructor(page: Page, session?: string, options?: CreateConfig);
10
10
  /**
11
11
  * Automatically sends a link with the auto generated link preview. You can also add a custom message to be added.
12
+ *
13
+ * Deprecated: please use {@link sendText}
14
+ *
12
15
  * @category Chat
16
+ * @deprecated
13
17
  * @param chatId
14
18
  * @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
15
- * @param title custom text as the message body, this includes the link or will be attached after the link
19
+ * @param text custom text as the message body, this includes the link or will be attached after the link
16
20
  */
17
- sendLinkPreview(chatId: string, url: string, title: string): Promise<SendLinkResult>;
21
+ sendLinkPreview(chatId: string, url: string, text?: string): Promise<SendMessageReturn>;
18
22
  /**
19
23
  * Sends a text message to given chat
20
24
  * @category Chat
@@ -86,16 +90,25 @@ export declare class SenderLayer extends ListenerLayer {
86
90
  }>;
87
91
  /**
88
92
  * Sends message with thumbnail
93
+ *
94
+ * @deprecated: please use {@link sendText} with options
95
+ *
96
+ * @deprecated
89
97
  * @category Chat
90
- * @param thumb
98
+ * @param pathOrBase64
91
99
  * @param url
92
100
  * @param title
93
101
  * @param description
94
102
  * @param chatId
95
103
  */
96
- sendMessageWithThumb(thumb: string, url: string, title: string, description: string, chatId: string): Promise<void>;
104
+ sendMessageWithThumb(pathOrBase64: string, url: string, title: string, description: string, chatId: string): Promise<SendMessageReturn>;
97
105
  /**
98
106
  * Replies to given mesage id of given chat id
107
+ *
108
+ * Deprecated: Please, use sendText with quotedMsg option
109
+ *
110
+ * @deprecated
111
+ *
99
112
  * @category Chat
100
113
  * @param to Chat id
101
114
  * @param content Message body
@@ -130,22 +143,40 @@ export declare class SenderLayer extends ListenerLayer {
130
143
  /**
131
144
  * Sends file
132
145
  * base64 parameter should have mime type already defined
146
+ *
147
+ * Deprecated: please use sendFile with options: sendFile(to, content, options)
148
+ *
149
+ * @deprecated
150
+ *
133
151
  * @category Chat
134
- * @param to Chat id
152
+ * @param chatId Chat id
135
153
  * @param base64 base64 data
136
154
  * @param filename
137
155
  * @param caption
138
156
  */
139
- sendFileFromBase64(to: string, base64: string, filename: string, caption?: string): Promise<SendFileResult>;
157
+ sendFileFromBase64(chatId: string, base64: string, filename: string, caption?: string): Promise<any>;
140
158
  /**
141
- * Sends file from path
159
+ * Sends file from path or base64
142
160
  * @category Chat
143
161
  * @param to Chat id
144
- * @param filePath File path
145
- * @param filename
146
- * @param caption
162
+ * @param pathOrBase64 File path
163
+ * @param options
147
164
  */
148
- sendFile(to: string, filePath: string, filename?: string, caption?: string): Promise<SendFileResult>;
165
+ sendFile(to: string, pathOrBase64: string, options?: FileMessageOptions): any;
166
+ /**
167
+ * Sends file from path or base64
168
+ *
169
+ * Deprecated: please use sendFile with options: sendFile(to, content, options)
170
+ *
171
+ * @deprecated
172
+ *
173
+ * @category Chat
174
+ * @param to Chat id
175
+ * @param pathOrBase64 File path or base64
176
+ * @param filename The file name
177
+ * @param caption Caption for the filename
178
+ */
179
+ sendFile(to: string, pathOrBase64: string, filename?: string, caption?: string): any;
149
180
  /**
150
181
  * Sends a video to given chat as a gif, with caption or not
151
182
  * @category Chat
@@ -204,7 +235,7 @@ export declare class SenderLayer extends ListenerLayer {
204
235
  * @param to Chat id
205
236
  * @param contactsId Example: 0000@c.us | [000@c.us, 1111@c.us]
206
237
  */
207
- sendContactVcard(to: string, contactsId: string, name?: string): Promise<import("@wppconnect/wa-js/dist/chat").SendMessageReturn>;
238
+ sendContactVcard(to: string, contactsId: string, name?: string): Promise<SendMessageReturn>;
208
239
  /**
209
240
  * Send a list of contact cards
210
241
  * @category Chat
@@ -214,7 +245,7 @@ export declare class SenderLayer extends ListenerLayer {
214
245
  sendContactVcardList(to: string, contacts: (string | {
215
246
  id: string;
216
247
  name: string;
217
- })[]): Promise<import("@wppconnect/wa-js/dist/chat").SendMessageReturn>;
248
+ })[]): Promise<SendMessageReturn>;
218
249
  /**
219
250
  * Forwards array of messages (could be ids or message objects)
220
251
  * @category Chat
@@ -227,19 +258,25 @@ export declare class SenderLayer extends ListenerLayer {
227
258
  /**
228
259
  * Generates sticker from the provided animated gif image and sends it (Send image as animated sticker)
229
260
  * @category Chat
230
- * @param path image path imageBase64 A valid gif image is required. You can also send via http/https (http://www.website.com/img.gif)
231
- * @param to chatId '000000000000@c.us'
261
+ * @param pathOrBase64 image path imageBase64 A valid gif image is required. You can also send via http/https (http://www.website.com/img.gif)
262
+ * @param to chatId '000000000000@c.us'
232
263
  */
233
- sendImageAsStickerGif(to: string, path: string): Promise<SendStickerResult | false>;
264
+ sendImageAsStickerGif(to: string, pathOrBase64: string): Promise<SendMessageReturn>;
234
265
  /**
235
266
  * Generates sticker from given image and sends it (Send Image As Sticker)
236
267
  * @category Chat
237
- * @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)
268
+ * @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)
238
269
  * @param to chatId '000000000000@c.us'
239
270
  */
240
- sendImageAsSticker(to: string, path: string): Promise<SendStickerResult | false>;
271
+ sendImageAsSticker(to: string, pathOrBase64: string): Promise<SendMessageReturn>;
272
+ /**
273
+ * Sends location to given chat id
274
+ * @category Chat
275
+ * @param to Chat id
276
+ * @param options location options
277
+ */
278
+ sendLocation(to: string, options: LocationMessageOptions): any;
241
279
  /**
242
- * TODO: Fix message not being delivered
243
280
  * Sends location to given chat id
244
281
  * @category Chat
245
282
  * @param to Chat id
@@ -247,7 +284,7 @@ export declare class SenderLayer extends ListenerLayer {
247
284
  * @param longitude Longitude
248
285
  * @param title Text caption
249
286
  */
250
- sendLocation(to: string, latitude: string, longitude: string, title: string): Promise<object>;
287
+ sendLocation(to: string, latitude: string, longitude: string, title: string): any;
251
288
  /**
252
289
  * Sets a chat status to seen. Marks all messages as ack: 3
253
290
  * @category Chat
@@ -259,26 +296,45 @@ export declare class SenderLayer extends ListenerLayer {
259
296
  }>;
260
297
  /**
261
298
  * Starts typing ('Typing...' state)
299
+ *
300
+ * @example
301
+ * ```javascript
302
+ * // Keep sending typing state, use stopTyping to finish
303
+ * await client.startTyping('[number]@c.us');
304
+ *
305
+ * // Keep sending typing state for 5 seconds
306
+ * await client.startTyping('[number]@c.us', 5000);
307
+ * ```
262
308
  * @category Chat
263
- * @param chatId
309
+ * @param to Chat Id
310
+ * @param duration Duration um miliseconds
264
311
  */
265
312
  startTyping(to: string, duration?: number): Promise<void>;
266
313
  /**
267
314
  * Stops typing ('Typing...' state)
268
315
  * @category Chat
269
- * @param chatId
316
+ * @param to Chat Id
270
317
  */
271
318
  stopTyping(to: string): Promise<void>;
272
319
  /**
273
320
  * Starts recording ('Recording...' state)
321
+ * @example
322
+ * ```javascript
323
+ * // Keep sending recording state, use stopRecoring to finish
324
+ * await client.startRecording('[number]@c.us');
325
+ *
326
+ * // Keep sending typing state for 5 seconds
327
+ * await client.startRecording('[number]@c.us', 5000);
328
+ * ```
274
329
  * @category Chat
275
- * @param chatId
330
+ * @param to Chat Id
331
+ * @param duration Duration um miliseconds
276
332
  */
277
333
  startRecording(to: string, duration?: number): Promise<void>;
278
334
  /**
279
335
  * Stops recording ('Recording...' state)
280
336
  * @category Chat
281
- * @param chatId
337
+ * @param to Chat Id
282
338
  */
283
339
  stopRecoring(to: string): Promise<void>;
284
340
  /**
@@ -291,7 +347,7 @@ export declare class SenderLayer extends ListenerLayer {
291
347
  * Sends text with tags
292
348
  * @category Chat
293
349
  */
294
- sendMentioned(to: string, message: string, mentioned: string[]): Promise<import("@wppconnect/wa-js/dist/chat").SendMessageReturn>;
350
+ sendMentioned(to: string, message: string, mentioned: string[]): Promise<SendMessageReturn>;
295
351
  /**
296
352
  * Sends a list message
297
353
  *