@wppconnect-team/wppconnect 1.19.2 → 1.20.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,12 @@
1
+ # 1.20.0 (2022-12-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * Added getVotes and getReactions functions ([49bb58f](https://github.com/wppconnect-team/wppconnect/commit/49bb58f9c0db9271a36cea4d650857f2ddbde74a))
7
+
8
+
9
+
1
10
  ## 1.19.2 (2022-12-11)
2
11
 
3
12
 
@@ -79,11 +79,13 @@ export declare class GroupLayer extends RetrieverLayer {
79
79
  createGroup(groupName: string, contacts: string | string[]): Promise<{
80
80
  gid: import("@wppconnect/wa-js/dist/whatsapp").Wid;
81
81
  participants: {
82
- [key: string]: {
83
- code: string;
82
+ [key: `${number}@c.us`]: {
83
+ wid: string;
84
+ code: number;
85
+ invite_code: string;
86
+ invite_code_exp: number;
84
87
  };
85
- }[];
86
- status: number;
88
+ };
87
89
  }>;
88
90
  /**
89
91
  * Removes participant from group
@@ -100,6 +102,7 @@ export declare class GroupLayer extends RetrieverLayer {
100
102
  */
101
103
  addParticipant(groupId: string, participantId: string | string[]): Promise<{
102
104
  [key: `${number}@c.us`]: {
105
+ wid: string;
103
106
  code: number;
104
107
  message: string;
105
108
  invite_code: string;
@@ -1,6 +1,6 @@
1
1
  import { Page } from 'puppeteer';
2
2
  import { CreateConfig } from '../../config/create-config';
3
- import { Ack, Chat, LiveLocation, Message, ParticipantEvent, PresenceEvent } from '../model';
3
+ import { Ack, Chat, LiveLocation, Message, ParticipantEvent, PresenceEvent, Wid } from '../model';
4
4
  import { SocketState, SocketStream } from '../model/enum';
5
5
  import { InterfaceMode } from '../model/enum/interface-mode';
6
6
  import { InterfaceState } from '../model/enum/interface-state';
@@ -212,4 +212,17 @@ export declare class ListenerLayer extends ProfileLayer {
212
212
  }) => any): {
213
213
  dispose: () => void;
214
214
  };
215
+ /**
216
+ * @event Listens to poll response messages
217
+ * @returns Disposable object to stop the listening
218
+ */
219
+ onPollResponse(callback: (data: {
220
+ msgId: string;
221
+ chatId: Wid;
222
+ selectedOptions: any;
223
+ timestamp: number;
224
+ sender: Wid;
225
+ }) => any): {
226
+ dispose: () => void;
227
+ };
215
228
  }
@@ -124,6 +124,7 @@ var ListenerLayer = /** @class */ (function (_super) {
124
124
  'onIncomingCall',
125
125
  'onRevokedMessage',
126
126
  'onReactionMessage',
127
+ 'onPollResponse',
127
128
  ], false);
128
129
  _loop_1 = function (func) {
129
130
  var has;
@@ -321,6 +322,24 @@ var ListenerLayer = /** @class */ (function (_super) {
321
322
  catch (error) {
322
323
  console.error(error);
323
324
  }
325
+ try {
326
+ if (!window['onPollResponse'].exposed) {
327
+ WPP.on('chat.poll_response', function (data) {
328
+ var eventData = {
329
+ msgId: data.msgId,
330
+ chatId: data.chatId,
331
+ selectedOptions: data.selectedOptions,
332
+ timestamp: data.timestamp,
333
+ sender: data.sender,
334
+ };
335
+ window['onPollResponse'](eventData);
336
+ });
337
+ window['onPollResponse'].exposed = true;
338
+ }
339
+ }
340
+ catch (error) {
341
+ console.error(error);
342
+ }
324
343
  try {
325
344
  if (!window['onParticipantsChanged'].exposed) {
326
345
  WPP.on('group.participant_changed', function (participantChangedEvent) {
@@ -546,6 +565,13 @@ var ListenerLayer = /** @class */ (function (_super) {
546
565
  ListenerLayer.prototype.onReactionMessage = function (callback) {
547
566
  return this.registerEvent('onReactionMessage', callback);
548
567
  };
568
+ /**
569
+ * @event Listens to poll response messages
570
+ * @returns Disposable object to stop the listening
571
+ */
572
+ ListenerLayer.prototype.onPollResponse = function (callback) {
573
+ return this.registerEvent('onPollResponse', callback);
574
+ };
549
575
  return ListenerLayer;
550
576
  }(profile_layer_1.ProfileLayer));
551
577
  exports.ListenerLayer = ListenerLayer;
@@ -1,7 +1,7 @@
1
1
  import { Page } from 'puppeteer';
2
2
  import { CreateConfig } from '../../config/create-config';
3
3
  import { SessionToken } from '../../token-store';
4
- import { Chat, ContactStatus, ProfilePicThumbObj, WhatsappProfile } from '../model';
4
+ import { Chat, ContactStatus, ProfilePicThumbObj, WhatsappProfile, Wid } from '../model';
5
5
  import { SenderLayer } from './sender.layer';
6
6
  export declare class RetrieverLayer extends SenderLayer {
7
7
  page: Page;
@@ -196,4 +196,47 @@ export declare class RetrieverLayer extends SenderLayer {
196
196
  * @param chatId chat id: xxxxx@c.us
197
197
  */
198
198
  getPlatformFromMessage(msgId: string): Promise<string>;
199
+ /**
200
+ * Get the reactions of a message
201
+ *
202
+ * @category Chat
203
+ */
204
+ getReactions(msgId: string): Promise<{
205
+ reactionByMe: {
206
+ id: any;
207
+ orphan: number;
208
+ msgId: any;
209
+ reactionText: string;
210
+ read: boolean;
211
+ senderUserJid: string;
212
+ timestamp: number;
213
+ };
214
+ reactions: {
215
+ aggregateEmoji: string;
216
+ hasReactionByMe: boolean;
217
+ senders: {
218
+ id: any;
219
+ orphan: number;
220
+ msgId: any;
221
+ reactionText: string;
222
+ read: boolean;
223
+ senderUserJid: string;
224
+ timestamp: number;
225
+ }[];
226
+ }[];
227
+ }>;
228
+ /**
229
+ * Get the votes of a poll message
230
+ *
231
+ * @category Chat
232
+ */
233
+ getVotes(msgId: string): Promise<{
234
+ msgId: any;
235
+ chatId: Wid;
236
+ votes: {
237
+ selectedOptions: number[];
238
+ timestamp: number;
239
+ sender: Wid;
240
+ }[];
241
+ }>;
199
242
  }
@@ -564,6 +564,36 @@ var RetrieverLayer = /** @class */ (function (_super) {
564
564
  });
565
565
  });
566
566
  };
567
+ /**
568
+ * Get the reactions of a message
569
+ *
570
+ * @category Chat
571
+ */
572
+ RetrieverLayer.prototype.getReactions = function (msgId) {
573
+ return __awaiter(this, void 0, void 0, function () {
574
+ return __generator(this, function (_a) {
575
+ switch (_a.label) {
576
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (msgId) { return WPP.chat.getReactions(msgId); }, msgId)];
577
+ case 1: return [2 /*return*/, _a.sent()];
578
+ }
579
+ });
580
+ });
581
+ };
582
+ /**
583
+ * Get the votes of a poll message
584
+ *
585
+ * @category Chat
586
+ */
587
+ RetrieverLayer.prototype.getVotes = function (msgId) {
588
+ return __awaiter(this, void 0, void 0, function () {
589
+ return __generator(this, function (_a) {
590
+ switch (_a.label) {
591
+ case 0: return [4 /*yield*/, (0, helpers_1.evaluateAndReturn)(this.page, function (msgId) { return WPP.chat.getVotes(msgId); }, msgId)];
592
+ case 1: return [2 /*return*/, _a.sent()];
593
+ }
594
+ });
595
+ });
596
+ };
567
597
  return RetrieverLayer;
568
598
  }(sender_layer_1.SenderLayer));
569
599
  exports.RetrieverLayer = RetrieverLayer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wppconnect-team/wppconnect",
3
- "version": "1.19.2",
3
+ "version": "1.20.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",
@@ -65,14 +65,14 @@
65
65
  "@types/atob": "^2.1.2",
66
66
  "@types/mime-types": "^2.1.1",
67
67
  "@types/mocha": "^10.0.1",
68
- "@types/node": "^18.11.13",
68
+ "@types/node": "^18.11.15",
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.46.0",
75
- "@typescript-eslint/parser": "^5.46.0",
74
+ "@typescript-eslint/eslint-plugin": "^5.46.1",
75
+ "@typescript-eslint/parser": "^5.46.1",
76
76
  "babel-loader": "^9.1.0",
77
77
  "commitizen": "^4.2.6",
78
78
  "concurrently": "^7.6.0",
@@ -95,8 +95,8 @@
95
95
  "webpack-cli": "^4.10.0"
96
96
  },
97
97
  "dependencies": {
98
- "@wppconnect/wa-js": "^2.17.0",
99
- "@wppconnect/wa-version": "^1.1.208",
98
+ "@wppconnect/wa-js": "^2.18.0",
99
+ "@wppconnect/wa-version": "^1.1.213",
100
100
  "atob": "^2.1.2",
101
101
  "axios": "^1.2.1",
102
102
  "boxen": "^5.1.2",