@open-wa/wa-automate 4.52.1 → 4.54.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -184,6 +184,13 @@ export declare class Client {
184
184
  * @fires [[Message]]
185
185
  */
186
186
  onButton(fn: (message: Message) => void): Promise<Listener | boolean>;
187
+ /**
188
+ * Listens to poll vote events
189
+ * @event
190
+ * @param fn callback
191
+ * @fires [[PollData]]
192
+ */
193
+ onPollVote(fn: (pollDate: PollData) => void): Promise<Listener | boolean>;
187
194
  /**
188
195
  * Listens to broadcast messages
189
196
  * @event
@@ -1731,7 +1738,7 @@ export declare class Client {
1731
1738
  * @deprecated
1732
1739
  * Alias for deleteStory
1733
1740
  */
1734
- deleteStatus: (statusesToDelete: string | string[]) => Promise<boolean>;
1741
+ deleteStatus(statusesToDelete: string | string[]): Promise<boolean>;
1735
1742
  /**
1736
1743
  * {@license:restricted@}
1737
1744
  *
@@ -1743,7 +1750,7 @@ export declare class Client {
1743
1750
  * @deprecated
1744
1751
  * Alias for deleteStory
1745
1752
  */
1746
- deleteAllStatus: () => Promise<boolean>;
1753
+ deleteAllStatus(): Promise<boolean>;
1747
1754
  /**
1748
1755
  * {@license:restricted@}
1749
1756
  *
@@ -1756,7 +1763,7 @@ export declare class Client {
1756
1763
  * @deprecated
1757
1764
  * Alias for deleteStory
1758
1765
  */
1759
- getMyStatusArray: () => Promise<Message[]>;
1766
+ getMyStatusArray(): Promise<Message[]>;
1760
1767
  /**
1761
1768
  * {@license:restricted@}
1762
1769
  *
@@ -112,21 +112,6 @@ class Client {
112
112
  * Note: This would be much simpler if eventMode was the default (and only) listener strategy.
113
113
  */
114
114
  this._registeredWebhookListeners = {};
115
- /**
116
- * @deprecated
117
- * Alias for deleteStory
118
- */
119
- this.deleteStatus = this.deleteStory;
120
- /**
121
- * @deprecated
122
- * Alias for deleteStory
123
- */
124
- this.deleteAllStatus = this.deleteAllStories;
125
- /**
126
- * @deprecated
127
- * Alias for deleteStory
128
- */
129
- this.getMyStatusArray = this.getMyStoryArray;
130
115
  /**
131
116
  * This exposes a simple express middlware that will allow users to quickly boot up an api based off this client. Checkout demo/index.ts for an example
132
117
  * How to use the middleware:
@@ -824,6 +809,17 @@ class Client {
824
809
  return this.registerListener(events_2.SimpleListener.Button, fn);
825
810
  });
826
811
  }
812
+ /**
813
+ * Listens to poll vote events
814
+ * @event
815
+ * @param fn callback
816
+ * @fires [[PollData]]
817
+ */
818
+ onPollVote(fn) {
819
+ return __awaiter(this, void 0, void 0, function* () {
820
+ return this.registerListener(events_2.SimpleListener.PollVote, fn);
821
+ });
822
+ }
827
823
  /**
828
824
  * Listens to broadcast messages
829
825
  * @event
@@ -1266,8 +1262,8 @@ class Client {
1266
1262
  if (this._currentlyBeingKilled)
1267
1263
  return;
1268
1264
  this._currentlyBeingKilled = true;
1269
- console.log('Killing client. Shutting Down');
1270
- logging_1.log.info('Killing client. Shutting Down');
1265
+ console.log(`Killing client. Shutting Down: ${reason}`);
1266
+ logging_1.log.info(`Killing client. Shutting Down: ${reason}`);
1271
1267
  const browser = yield ((_a = this === null || this === void 0 ? void 0 : this._page) === null || _a === void 0 ? void 0 : _a.browser());
1272
1268
  const pid = (browser === null || browser === void 0 ? void 0 : browser.process()) ? (_b = browser === null || browser === void 0 ? void 0 : browser.process()) === null || _b === void 0 ? void 0 : _b.pid : null;
1273
1269
  try {
@@ -1680,6 +1676,7 @@ class Client {
1680
1676
  }))(),
1681
1677
  (0, tools_1.assertFile)(file, filename, tools_1.FileOutputTypes.TEMP_FILE_PATH, requestConfig || {})
1682
1678
  ]);
1679
+ //@ts-ignore
1683
1680
  yield inputElement.uploadFile(fileAsLocalTemp);
1684
1681
  file = inputElementId;
1685
1682
  /**
@@ -2250,7 +2247,8 @@ class Client {
2250
2247
  */
2251
2248
  getTunnelCode() {
2252
2249
  return __awaiter(this, void 0, void 0, function* () {
2253
- return yield this.pup(() => WAPI.getTunnelCode());
2250
+ const sessionId = this.getSessionId();
2251
+ return yield this.pup(sessionId => WAPI.getTunnelCode(sessionId), sessionId);
2254
2252
  });
2255
2253
  }
2256
2254
  /**
@@ -3594,6 +3592,15 @@ class Client {
3594
3592
  return yield this.pup(({ statusesToDelete }) => WAPI.deleteStatus(statusesToDelete), { statusesToDelete });
3595
3593
  });
3596
3594
  }
3595
+ /**
3596
+ * @deprecated
3597
+ * Alias for deleteStory
3598
+ */
3599
+ deleteStatus(statusesToDelete) {
3600
+ return __awaiter(this, void 0, void 0, function* () {
3601
+ return yield this.deleteStory(statusesToDelete);
3602
+ });
3603
+ }
3597
3604
  /**
3598
3605
  * {@license:restricted@}
3599
3606
  *
@@ -3605,6 +3612,15 @@ class Client {
3605
3612
  return yield this.pup(() => WAPI.deleteAllStatus());
3606
3613
  });
3607
3614
  }
3615
+ /**
3616
+ * @deprecated
3617
+ * Alias for deleteStory
3618
+ */
3619
+ deleteAllStatus() {
3620
+ return __awaiter(this, void 0, void 0, function* () {
3621
+ return yield this.deleteAllStories();
3622
+ });
3623
+ }
3608
3624
  /**
3609
3625
  * {@license:restricted@}
3610
3626
  *
@@ -3617,6 +3633,15 @@ class Client {
3617
3633
  return yield this.pup(() => WAPI.getMyStatusArray());
3618
3634
  });
3619
3635
  }
3636
+ /**
3637
+ * @deprecated
3638
+ * Alias for deleteStory
3639
+ */
3640
+ getMyStatusArray() {
3641
+ return __awaiter(this, void 0, void 0, function* () {
3642
+ return yield this.getMyStoryArray();
3643
+ });
3644
+ }
3620
3645
  /**
3621
3646
  * {@license:restricted@}
3622
3647
  *
@@ -66,6 +66,10 @@ export declare enum SimpleListener {
66
66
  * Represents [[onButton]]
67
67
  */
68
68
  Button = "onButton",
69
+ /**
70
+ * Represents [[onButton]]
71
+ */
72
+ PollVote = "onPollVote",
69
73
  /**
70
74
  * Represents [[onBroadcast]]
71
75
  */
@@ -73,6 +73,10 @@ var SimpleListener;
73
73
  * Represents [[onButton]]
74
74
  */
75
75
  SimpleListener["Button"] = "onButton";
76
+ /**
77
+ * Represents [[onButton]]
78
+ */
79
+ SimpleListener["PollVote"] = "onPollVote";
76
80
  /**
77
81
  * Represents [[onBroadcast]]
78
82
  */
package/dist/cli/index.js CHANGED
@@ -42,6 +42,8 @@ function start() {
42
42
  const { cliConfig, createConfig, PORT, spinner } = yield (0, setup_1.cli)();
43
43
  process.env.OWA_CLI = "true";
44
44
  spinner.start("Launching EASY API");
45
+ if (cliConfig.verbose)
46
+ index_1.log.info(`config: `, { cliConfig, createConfig, PORT });
45
47
  (0, server_1.setUpExpressApp)();
46
48
  if (cliConfig.cors)
47
49
  yield (0, server_1.enableCORSRequests)(cliConfig);
@@ -201,7 +203,7 @@ function start() {
201
203
  spinner.info(`\n• Setting up external tunnel`);
202
204
  const tunnel = yield (0, localtunnel_1.default)({
203
205
  port: PORT,
204
- host: "https://public.openwa.cloud",
206
+ host: process.env.WA_TUNNEL_SERVER || "https://public.openwa.cloud",
205
207
  subdomain: yield client.getTunnelCode()
206
208
  });
207
209
  cliConfig.apiHost = cliConfig.tunnel = tunnel.url;
@@ -311,6 +311,7 @@ const setupChatwootOutgoingMessageHandler = (cliConfig, client) => __awaiter(voi
311
311
  }
312
312
  });
313
313
  const sendConversationMessage = (content, contactId, message) => __awaiter(void 0, void 0, void 0, function* () {
314
+ __1.log.info(`INCOMING MESSAGE ${contactId}: ${content} ${message.id}`);
314
315
  try {
315
316
  const { data } = yield cwReq('post', `conversations/${convoReg[contactId]}/messages`, {
316
317
  content,
@@ -326,6 +327,7 @@ const setupChatwootOutgoingMessageHandler = (cliConfig, client) => __awaiter(voi
326
327
  const sendAttachmentMessage = (content, contactId, message) => __awaiter(void 0, void 0, void 0, function* () {
327
328
  // decrypt message
328
329
  const file = yield client.decryptMedia(message);
330
+ __1.log.info(`INCOMING MESSAGE ATTACHMENT ${contactId}: ${content} ${message.id}`);
329
331
  let formData = new form_data_1.default();
330
332
  formData.append('attachments[]', Buffer.from(file.split(',')[1], 'base64'), {
331
333
  knownLength: 1,
@@ -231,7 +231,7 @@ class QRManager {
231
231
  }
232
232
  if (!gotResult && (qrData === 'QR_CODE_SUCCESS' || qrData === md)) {
233
233
  gotResult = true;
234
- spinner === null || spinner === void 0 ? void 0 : spinner.succeed(qrData === md ? "Multi device support for this project is EXPERIMENTAL. Some things may not work...." : "QR code scanned. Loading session...");
234
+ spinner === null || spinner === void 0 ? void 0 : spinner.succeed("QR code scanned. Loading session...");
235
235
  return resolve(yield isInsideChat(waPage).toPromise());
236
236
  }
237
237
  if (!gotResult)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.52.1",
3
+ "version": "4.54.0",
4
4
  "licenseCheckUrl": "https://funcs.openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://funcs.openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",
@@ -76,7 +76,7 @@
76
76
  "@types/marked": "^4.0.2",
77
77
  "@types/mime": "^3.0.1",
78
78
  "@types/node": "^18.7.6",
79
- "@types/puppeteer": "^5.4.0",
79
+ "@types/puppeteer": "^7.0.4",
80
80
  "@types/shelljs": "^0.8.5",
81
81
  "@types/winston-syslog": "^2.4.0",
82
82
  "@typescript-eslint/eslint-plugin": "^5.8.0",
@@ -154,17 +154,17 @@
154
154
  "pidtree": "^0.6.0",
155
155
  "pidusage": "^3.0.0",
156
156
  "postman-2-swagger": "^0.5.0",
157
- "puppeteer": "15.0.0",
158
- "puppeteer-extra": "^3.2.3",
159
- "puppeteer-extra-plugin-block-resources": "^2.4.0",
160
- "puppeteer-extra-plugin-devtools": "^2.4.0",
161
- "puppeteer-extra-plugin-stealth": "^2.10.1",
157
+ "puppeteer": "^19.4.1",
158
+ "puppeteer-extra": "^3.3.4",
159
+ "puppeteer-extra-plugin-block-resources": "^2.4.2",
160
+ "puppeteer-extra-plugin-devtools": "^2.4.4",
161
+ "puppeteer-extra-plugin-stealth": "^2.11.1",
162
162
  "qrcode-terminal": "^0.12.0",
163
163
  "qs": "^6.10.1",
164
164
  "rxjs": "^7.0.0",
165
165
  "smashah-puppeteer-page-proxy": "^1.2.8",
166
- "socket.io": "^4.4.1",
167
- "socket.io-client": "^4.1.1",
166
+ "socket.io": "^4.5.4",
167
+ "socket.io-client": "^4.5.4",
168
168
  "spinnies": "^0.5.1",
169
169
  "swagger-stats": "^0.99.1",
170
170
  "swagger-ui-dist": "^4.1.3",