@open-wa/wa-automate 4.33.2 → 4.33.5

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.
@@ -20,6 +20,7 @@ import { NextFunction, Request, Response } from 'express';
20
20
  import { Call } from './model/call';
21
21
  import { Button, Section } from './model/button';
22
22
  import { JsonObject } from 'type-fest';
23
+ import { ReactionEvent } from './model/reactions';
23
24
  export declare enum namespace {
24
25
  Chat = "Chat",
25
26
  Msg = "Msg",
@@ -231,6 +232,16 @@ export declare class Client {
231
232
  * Listens to new orders. Only works on business accounts
232
233
  */
233
234
  onNewProduct(fn: (product: Product) => void): Promise<Listener | boolean>;
235
+ /**
236
+ * [REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
237
+ *
238
+ * Listens to reaction add and change events
239
+ *
240
+ * @event
241
+ * @param fn callback
242
+ * @fires [[ReactionEvent]]
243
+ */
244
+ onReaction(fn: (reactionEvent: ReactionEvent) => void): Promise<Listener | boolean>;
234
245
  /**
235
246
  * [REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
236
247
  *
@@ -810,6 +810,20 @@ class Client {
810
810
  return this.registerListener(events_2.SimpleListener.NewProduct, fn);
811
811
  });
812
812
  }
813
+ /**
814
+ * [REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
815
+ *
816
+ * Listens to reaction add and change events
817
+ *
818
+ * @event
819
+ * @param fn callback
820
+ * @fires [[ReactionEvent]]
821
+ */
822
+ onReaction(fn) {
823
+ return __awaiter(this, void 0, void 0, function* () {
824
+ return this.registerListener(events_2.SimpleListener.Reaction, fn);
825
+ });
826
+ }
813
827
  /**
814
828
  * [REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
815
829
  *
@@ -86,5 +86,10 @@ export declare enum SimpleListener {
86
86
  * Requires licence
87
87
  * Represents [[onNewProduct]]
88
88
  */
89
- NewProduct = "onNewProduct"
89
+ NewProduct = "onNewProduct",
90
+ /**
91
+ * Requires licence
92
+ * Represents [[onReaction]]
93
+ */
94
+ Reaction = "onReaction"
90
95
  }
@@ -94,4 +94,9 @@ var SimpleListener;
94
94
  * Represents [[onNewProduct]]
95
95
  */
96
96
  SimpleListener["NewProduct"] = "onNewProduct";
97
+ /**
98
+ * Requires licence
99
+ * Represents [[onReaction]]
100
+ */
101
+ SimpleListener["Reaction"] = "onReaction";
97
102
  })(SimpleListener = exports.SimpleListener || (exports.SimpleListener = {}));
@@ -4,6 +4,7 @@ export * from './message';
4
4
  export * from './errors';
5
5
  export * from './events';
6
6
  export * from './product';
7
+ export * from './reactions';
7
8
  /**
8
9
  * Client status
9
10
  * @readonly
@@ -17,6 +17,7 @@ __exportStar(require("./message"), exports);
17
17
  __exportStar(require("./errors"), exports);
18
18
  __exportStar(require("./events"), exports);
19
19
  __exportStar(require("./product"), exports);
20
+ __exportStar(require("./reactions"), exports);
20
21
  /**
21
22
  * Client status
22
23
  * @readonly
@@ -0,0 +1,76 @@
1
+ import { ContactId } from "./aliases";
2
+ import { Message, MessageAck } from "./message";
3
+ /**
4
+ * A reaction is identified the specific emoji.
5
+ */
6
+ export declare type Reaction = {
7
+ /**
8
+ * The aggregate emoji used for the reaction.
9
+ */
10
+ aggregateEmoji: string;
11
+ /**
12
+ * The identifier of the reaction
13
+ */
14
+ id: string;
15
+ /**
16
+ * If the reaction is also sent by the host account
17
+ */
18
+ hasReactionByMe: boolean;
19
+ /**
20
+ * The senders of this spefcific reaction
21
+ */
22
+ senders: ReactionRecord[];
23
+ };
24
+ /**
25
+ * The specific reaction by a user
26
+ */
27
+ export declare type ReactionRecord = {
28
+ /**
29
+ * The acknowledgement of the reaction
30
+ */
31
+ ack: MessageAck;
32
+ /**
33
+ * The ID of the reaction
34
+ */
35
+ id: string;
36
+ msgKey: string;
37
+ parentMsgKey: string;
38
+ orphan: number;
39
+ /**
40
+ * The text of the reaction
41
+ */
42
+ reactionText: string;
43
+ /**
44
+ * If the reaction has been read
45
+ */
46
+ read: boolean;
47
+ /**
48
+ * The ID of the reaction sender
49
+ */
50
+ senderUserJid: ContactId;
51
+ /**
52
+ * The timestamp of the reaction
53
+ */
54
+ timestamp: number;
55
+ };
56
+ /**
57
+ * Emitted by onReaction
58
+ */
59
+ export declare type ReactionEvent = {
60
+ /**
61
+ * The message being reacted to
62
+ */
63
+ message: Message;
64
+ /**
65
+ * The reaction sent by the host account
66
+ */
67
+ reactionByMe: Reaction;
68
+ /**
69
+ * An array of all reactions
70
+ */
71
+ reactions: Reaction[];
72
+ /**
73
+ * The type of the reaction event.
74
+ */
75
+ type: 'add' | 'change';
76
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -59,7 +59,7 @@ const UPLOAD_CLOUD = (message, client) => __awaiter(void 0, void 0, void 0, func
59
59
  if (!uploadQueue) {
60
60
  uploadQueue = new p_queue_1.default({ concurrency: 2, interval: 1000, carryoverConcurrencyCount: true, intervalCap: 2 });
61
61
  }
62
- const filename = `${message.id.split("_").slice(-1)[0]}.${mime_1.default.extension(message.mimetype)}`;
62
+ const filename = `${message.id.split("_").find(x => !x.includes("@") && x.length > 6) || `${Date.now()}`}.${mime_1.default.extension(message.mimetype)}`;
63
63
  const mediaData = yield client.decryptMedia(message);
64
64
  if (!cloudUploadOptions)
65
65
  return message;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.33.2",
3
+ "version": "4.33.5",
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",