@wppconnect-team/wppconnect 1.18.1 → 1.19.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,7 @@
1
+ # 1.19.0 (2022-11-02)
2
+
3
+
4
+
1
5
  ## 1.18.1 (2022-10-20)
2
6
 
3
7
 
@@ -98,7 +98,14 @@ export declare class GroupLayer extends RetrieverLayer {
98
98
  * @param groupId Chat id ('0000000000-00000000@g.us')
99
99
  * @param participantId Participant id'000000000000@c.us'
100
100
  */
101
- addParticipant(groupId: string, participantId: string | string[]): Promise<boolean>;
101
+ addParticipant(groupId: string, participantId: string | string[]): Promise<{
102
+ [key: `${number}@c.us`]: {
103
+ code: number;
104
+ message: string;
105
+ invite_code: string;
106
+ invite_code_exp: number;
107
+ };
108
+ }>;
102
109
  /**
103
110
  * Promotes participant as Admin in given group
104
111
  * @category Group
@@ -238,9 +238,7 @@ var GroupLayer = /** @class */ (function (_super) {
238
238
  var groupId = _a.groupId, participantId = _a.participantId;
239
239
  return WPP.group.addParticipants(groupId, participantId);
240
240
  }, { groupId: groupId, participantId: participantId })];
241
- case 1:
242
- _a.sent();
243
- return [2 /*return*/, true];
241
+ case 1: return [2 /*return*/, _a.sent()];
244
242
  }
245
243
  });
246
244
  });
@@ -1,4 +1,4 @@
1
- import type { FileMessageOptions, ListMessageOptions, LocationMessageOptions, SendMessageReturn, TextMessageOptions } from '@wppconnect/wa-js/dist/chat';
1
+ import type { FileMessageOptions, ListMessageOptions, LocationMessageOptions, SendMessageReturn, TextMessageOptions, PoolMessageOptions } from '@wppconnect/wa-js/dist/chat';
2
2
  import { Page } from 'puppeteer';
3
3
  import { CreateConfig } from '../../config/create-config';
4
4
  import { Message } from '../model';
@@ -425,6 +425,36 @@ export declare class SenderLayer extends ListenerLayer {
425
425
  * @category Chat
426
426
  */
427
427
  sendListMessage(to: string, options: ListMessageOptions): Promise<void>;
428
+ /**
429
+ * Send a create poll message
430
+ *
431
+ * Note: This only works for groups
432
+ *
433
+ * @example
434
+ * ```javascript
435
+ * // Single pool
436
+ * client.sendPollMessage(
437
+ * '[number]@g.us',
438
+ * 'A poll name',
439
+ * ['Option 1', 'Option 2', 'Option 3']
440
+ * );
441
+ * ```
442
+ * // Selectable Count
443
+ * ```javascript
444
+ * // Single pool
445
+ * client.sendPollMessage(
446
+ * '[number]@g.us',
447
+ * 'A poll name',
448
+ * ['Option 1', 'Option 2', 'Option 3'],
449
+ * {
450
+ * selectableCount: 1,
451
+ * }
452
+ * );
453
+ * ```
454
+ *
455
+ * @category Chat
456
+ */
457
+ sendPollMessage(chatId: string, name: string, choices: string[], options?: PoolMessageOptions): Promise<Message>;
428
458
  /**
429
459
  * Sets the chat state
430
460
  * Deprecated in favor of Use startTyping or startRecording functions
@@ -1255,6 +1255,77 @@ var SenderLayer = /** @class */ (function (_super) {
1255
1255
  });
1256
1256
  });
1257
1257
  };
1258
+ /**
1259
+ * Send a create poll message
1260
+ *
1261
+ * Note: This only works for groups
1262
+ *
1263
+ * @example
1264
+ * ```javascript
1265
+ * // Single pool
1266
+ * client.sendPollMessage(
1267
+ * '[number]@g.us',
1268
+ * 'A poll name',
1269
+ * ['Option 1', 'Option 2', 'Option 3']
1270
+ * );
1271
+ * ```
1272
+ * // Selectable Count
1273
+ * ```javascript
1274
+ * // Single pool
1275
+ * client.sendPollMessage(
1276
+ * '[number]@g.us',
1277
+ * 'A poll name',
1278
+ * ['Option 1', 'Option 2', 'Option 3'],
1279
+ * {
1280
+ * selectableCount: 1,
1281
+ * }
1282
+ * );
1283
+ * ```
1284
+ *
1285
+ * @category Chat
1286
+ */
1287
+ SenderLayer.prototype.sendPollMessage = function (chatId, name, choices, options) {
1288
+ return __awaiter(this, void 0, void 0, function () {
1289
+ var sendResult, result;
1290
+ var _this = this;
1291
+ return __generator(this, function (_a) {
1292
+ switch (_a.label) {
1293
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
1294
+ var chatId = _a.chatId, name = _a.name, choices = _a.choices, options = _a.options;
1295
+ return WPP.chat.sendCreatePollMessage(chatId, name, choices, options);
1296
+ }, {
1297
+ chatId: chatId,
1298
+ name: name,
1299
+ choices: choices,
1300
+ options: options,
1301
+ })];
1302
+ case 1:
1303
+ sendResult = _a.sent();
1304
+ return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (_a) {
1305
+ var messageId = _a.messageId;
1306
+ return __awaiter(_this, void 0, void 0, function () {
1307
+ var _b, _c, _d, _e;
1308
+ return __generator(this, function (_f) {
1309
+ switch (_f.label) {
1310
+ case 0:
1311
+ _c = (_b = JSON).parse;
1312
+ _e = (_d = JSON).stringify;
1313
+ return [4 /*yield*/, WAPI.getMessageById(messageId)];
1314
+ case 1: return [2 /*return*/, _c.apply(_b, [_e.apply(_d, [_f.sent()])])];
1315
+ }
1316
+ });
1317
+ });
1318
+ }, { messageId: sendResult.id })];
1319
+ case 2:
1320
+ result = (_a.sent());
1321
+ if (result['erro'] == true) {
1322
+ throw result;
1323
+ }
1324
+ return [2 /*return*/, result];
1325
+ }
1326
+ });
1327
+ });
1328
+ };
1258
1329
  /**
1259
1330
  * Sets the chat state
1260
1331
  * Deprecated in favor of Use startTyping or startRecording functions
@@ -63,7 +63,7 @@ export declare class FileTokenStore implements TokenStore {
63
63
  */
64
64
  protected resolverPath(sessionName: string): string;
65
65
  getToken(sessionName: string): Promise<SessionToken | undefined>;
66
- setToken(sessionName: string, tokenData: SessionToken | void): Promise<boolean>;
66
+ setToken(sessionName: string, tokenData: SessionToken | null): Promise<boolean>;
67
67
  removeToken(sessionName: string): Promise<boolean>;
68
68
  listTokens(): Promise<string[]>;
69
69
  }
@@ -24,7 +24,7 @@ export declare class MemoryTokenStore implements TokenStore {
24
24
  [key: string]: any;
25
25
  };
26
26
  getToken(sessionName: string): SessionToken | undefined;
27
- setToken(sessionName: string, tokenData: SessionToken | void): boolean;
27
+ setToken(sessionName: string, tokenData: SessionToken | null): boolean;
28
28
  removeToken(sessionName: string): boolean;
29
29
  listTokens(): string[];
30
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wppconnect-team/wppconnect",
3
- "version": "1.18.1",
3
+ "version": "1.19.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",
@@ -54,49 +54,49 @@
54
54
  },
55
55
  "homepage": "https://github.com/wppconnect-team/wppconnect#readme",
56
56
  "devDependencies": {
57
- "@babel/core": "^7.19.3",
57
+ "@babel/core": "^7.19.6",
58
58
  "@babel/eslint-parser": "^7.19.1",
59
59
  "@babel/eslint-plugin": "^7.19.1",
60
60
  "@babel/preset-env": "^7.19.4",
61
- "@commitlint/cli": "^17.1.2",
62
- "@commitlint/config-conventional": "^17.1.0",
63
- "@commitlint/cz-commitlint": "^17.1.2",
61
+ "@commitlint/cli": "^17.2.0",
62
+ "@commitlint/config-conventional": "^17.2.0",
63
+ "@commitlint/cz-commitlint": "^17.2.0",
64
64
  "@knodes/typedoc-plugin-pages": "^0.23.1",
65
65
  "@types/atob": "^2.1.2",
66
66
  "@types/mime-types": "^2.1.1",
67
- "@types/mocha": "^9.1.1",
68
- "@types/node": "^16.11.66",
67
+ "@types/mocha": "^10.0.0",
68
+ "@types/node": "^16.18.3",
69
69
  "@types/rimraf": "^3.0.2",
70
70
  "@types/sharp": "^0.31.0",
71
71
  "@types/shelljs": "^0.8.11",
72
72
  "@types/tmp": "^0.2.3",
73
73
  "@types/ws": "^8.5.3",
74
- "@typescript-eslint/eslint-plugin": "^5.39.0",
75
- "@typescript-eslint/parser": "^5.39.0",
74
+ "@typescript-eslint/eslint-plugin": "^5.42.0",
75
+ "@typescript-eslint/parser": "^5.42.0",
76
76
  "babel-loader": "^8.2.5",
77
77
  "commitizen": "^4.2.5",
78
- "concurrently": "^7.4.0",
78
+ "concurrently": "^7.5.0",
79
79
  "conventional-changelog-cli": "^2.2.2",
80
- "eslint": "^8.25.0",
80
+ "eslint": "^8.26.0",
81
81
  "eslint-config-prettier": "^8.5.0",
82
82
  "eslint-plugin-header": "^3.1.1",
83
83
  "eslint-plugin-prettier": "^4.2.1",
84
84
  "husky": "^8.0.1",
85
- "mocha": "^10.0.0",
85
+ "mocha": "^10.1.0",
86
86
  "prettier": "^2.7.1",
87
87
  "pretty-quick": "^3.1.3",
88
88
  "regenerator-runtime": "^0.13.10",
89
89
  "release-it": "^15.5.0",
90
90
  "shx": "^0.3.4",
91
91
  "ts-node": "^10.9.1",
92
- "typedoc": "^0.23.16",
92
+ "typedoc": "^0.23.19",
93
93
  "typescript": "^4.8.4",
94
94
  "webpack": "^5.74.0",
95
95
  "webpack-cli": "^4.10.0"
96
96
  },
97
97
  "dependencies": {
98
- "@wppconnect/wa-js": "^2.13.3",
99
- "@wppconnect/wa-version": "^1.1.175",
98
+ "@wppconnect/wa-js": "^2.14.1",
99
+ "@wppconnect/wa-version": "^1.1.183",
100
100
  "atob": "^2.1.2",
101
101
  "axios": "^0.27.2",
102
102
  "boxen": "^5.1.2",
@@ -123,7 +123,7 @@
123
123
  "tmp": "^0.2.1",
124
124
  "tree-kill": "^1.2.2",
125
125
  "winston": "^3.8.2",
126
- "ws": "^8.9.0"
126
+ "ws": "^8.10.0"
127
127
  },
128
128
  "optionalDependencies": {
129
129
  "fsevents": "^2.3.2"