@open-wa/wa-automate 4.36.6 → 4.37.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/Client.d.ts +11 -1
- package/dist/api/Client.js +27 -4
- package/dist/api/model/events.d.ts +4 -0
- package/dist/api/model/events.js +4 -0
- package/dist/api/model/index.d.ts +1 -0
- package/dist/api/model/index.js +1 -0
- package/dist/api/model/label.d.ts +24 -0
- package/dist/api/model/label.js +2 -0
- package/dist/api/model/product.d.ts +0 -24
- package/package.json +1 -1
package/dist/api/Client.d.ts
CHANGED
@@ -9,7 +9,8 @@ import { ConfigObject, STATE, LicenseType, Webhook, EventPayload } from './model
|
|
9
9
|
import PQueue, { DefaultAddOptions, Options } from 'p-queue';
|
10
10
|
import { HealthCheck, SessionInfo } from './model/sessionInfo';
|
11
11
|
import { ChatId, GroupChatId, Content, Base64, MessageId, ContactId, DataURL, FilePath } from './model/aliases';
|
12
|
-
import { CustomProduct,
|
12
|
+
import { CustomProduct, Order, Product } from './model/product';
|
13
|
+
import { Label } from './model/label';
|
13
14
|
import { Mp4StickerConversionProcessOptions, StickerMetadata } from './model/media';
|
14
15
|
import { SimpleListener } from './model/events';
|
15
16
|
import { AwaitMessagesOptions, Collection, CollectorFilter, CollectorOptions } from '../structures/Collector';
|
@@ -46,6 +47,7 @@ export declare class Client {
|
|
46
47
|
private _autoEmojiSet;
|
47
48
|
private _autoEmojiQ;
|
48
49
|
private _onLogoutSet;
|
50
|
+
private _preprocIdempotencyCheck;
|
49
51
|
/**
|
50
52
|
* This is used to track if a listener is already used via webhook. Before, webhooks used to be set once per listener. Now a listener can be set via multiple webhooks, or revoked from a specific webhook.
|
51
53
|
* For this reason, listeners assigned to a webhook are only set once and map through all possible webhooks to and fire only if the specific listener is assigned.
|
@@ -221,6 +223,14 @@ export declare class Client {
|
|
221
223
|
* @returns Observable stream of call request objects
|
222
224
|
*/
|
223
225
|
onIncomingCall(fn: (call: Call) => void): Promise<Listener | boolean>;
|
226
|
+
/**
|
227
|
+
* Listens to label change events
|
228
|
+
*
|
229
|
+
* @event
|
230
|
+
* @param fn callback
|
231
|
+
* @fires [[Label]]
|
232
|
+
*/
|
233
|
+
onLabel(fn: (label: Label) => void): Promise<Listener | boolean>;
|
224
234
|
/**
|
225
235
|
*[REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
|
226
236
|
*
|
package/dist/api/Client.js
CHANGED
@@ -98,6 +98,7 @@ class Client {
|
|
98
98
|
carryoverConcurrencyCount: true
|
99
99
|
});
|
100
100
|
this._onLogoutSet = false;
|
101
|
+
this._preprocIdempotencyCheck = {};
|
101
102
|
/**
|
102
103
|
* This is used to track if a listener is already used via webhook. Before, webhooks used to be set once per listener. Now a listener can be set via multiple webhooks, or revoked from a specific webhook.
|
103
104
|
* For this reason, listeners assigned to a webhook are only set once and map through all possible webhooks to and fire only if the specific listener is assigned.
|
@@ -664,6 +665,11 @@ class Client {
|
|
664
665
|
// STANDARD SIMPLE LISTENERS
|
665
666
|
preprocessMessage(message) {
|
666
667
|
return __awaiter(this, void 0, void 0, function* () {
|
668
|
+
if (this._preprocIdempotencyCheck[message.id]) {
|
669
|
+
logging_1.log.info(`preprocessMessage: ${message.id} already being processed`);
|
670
|
+
return message;
|
671
|
+
}
|
672
|
+
this._preprocIdempotencyCheck[message.id] = true;
|
667
673
|
let fil = "";
|
668
674
|
try {
|
669
675
|
fil = typeof this._createConfig.preprocFilter == "function" ? this._createConfig.preprocFilter : typeof this._createConfig.preprocFilter == "string" ? eval(this._createConfig.preprocFilter || "undefined") : undefined;
|
@@ -671,10 +677,15 @@ class Client {
|
|
671
677
|
catch (error) {
|
672
678
|
//do nothing
|
673
679
|
}
|
674
|
-
const m = fil
|
680
|
+
const m = fil ? [message].filter(typeof fil == "function" ? fil : x => x)[0] : message;
|
681
|
+
logging_1.log.info(`Preproc START: ${this._createConfig.messagePreprocessor} ${fil} ${message.id} ${m.id}`);
|
675
682
|
if (m && this._createConfig.messagePreprocessor && preProcessors_1.MessagePreprocessors[this._createConfig.messagePreprocessor]) {
|
676
|
-
|
683
|
+
logging_1.log.info(`Preproccessing message: ${this._createConfig.messagePreprocessor}`);
|
684
|
+
const preprocres = ((yield preProcessors_1.MessagePreprocessors[this._createConfig.messagePreprocessor](m, this)) || message);
|
685
|
+
delete this._preprocIdempotencyCheck[message.id];
|
686
|
+
return preprocres;
|
677
687
|
}
|
688
|
+
delete this._preprocIdempotencyCheck[message.id];
|
678
689
|
return message;
|
679
690
|
});
|
680
691
|
}
|
@@ -689,8 +700,8 @@ class Client {
|
|
689
700
|
onMessage(fn, queueOptions) {
|
690
701
|
var _a;
|
691
702
|
return __awaiter(this, void 0, void 0, function* () {
|
692
|
-
|
693
|
-
return this.registerListener(events_2.SimpleListener.Message,
|
703
|
+
const _fn = (message) => __awaiter(this, void 0, void 0, function* () { return fn(yield this.preprocessMessage(message)); });
|
704
|
+
return this.registerListener(events_2.SimpleListener.Message, _fn, ((_a = this === null || this === void 0 ? void 0 : this._createConfig) === null || _a === void 0 ? void 0 : _a.pQueueDefault) || queueOptions);
|
694
705
|
});
|
695
706
|
}
|
696
707
|
/**
|
@@ -807,6 +818,18 @@ class Client {
|
|
807
818
|
return this.registerListener(events_2.SimpleListener.IncomingCall, fn);
|
808
819
|
});
|
809
820
|
}
|
821
|
+
/**
|
822
|
+
* Listens to label change events
|
823
|
+
*
|
824
|
+
* @event
|
825
|
+
* @param fn callback
|
826
|
+
* @fires [[Label]]
|
827
|
+
*/
|
828
|
+
onLabel(fn) {
|
829
|
+
return __awaiter(this, void 0, void 0, function* () {
|
830
|
+
return this.registerListener(events_2.SimpleListener.Label, fn);
|
831
|
+
});
|
832
|
+
}
|
810
833
|
/**
|
811
834
|
*[REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
|
812
835
|
*
|
package/dist/api/model/events.js
CHANGED
package/dist/api/model/index.js
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
import { ContactId, ChatId, MessageId } from "./aliases";
|
2
|
+
export interface Label {
|
3
|
+
/**
|
4
|
+
* The internal ID of the label. Usually a number represented as a string e.g "1"
|
5
|
+
*/
|
6
|
+
id: string;
|
7
|
+
/**
|
8
|
+
* The text contents of the label
|
9
|
+
*/
|
10
|
+
name: string;
|
11
|
+
/**
|
12
|
+
* The items that are tagged with this label
|
13
|
+
*/
|
14
|
+
items: {
|
15
|
+
/**
|
16
|
+
* Labels can be applied to chats, contacts or individual messages. This represents the type of object the label is attached to.
|
17
|
+
*/
|
18
|
+
type: "Chat" | "Contact" | "Message";
|
19
|
+
/**
|
20
|
+
* The ID of the object that the label is atteched to.
|
21
|
+
*/
|
22
|
+
id: ContactId | ChatId | MessageId;
|
23
|
+
}[];
|
24
|
+
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { ChatId, ContactId, MessageId } from "./aliases";
|
2
1
|
import { Message } from "./message";
|
3
2
|
export interface CustomProduct {
|
4
3
|
/**
|
@@ -140,26 +139,3 @@ export interface Order {
|
|
140
139
|
*/
|
141
140
|
message?: Message;
|
142
141
|
}
|
143
|
-
export interface Label {
|
144
|
-
/**
|
145
|
-
* The internal ID of the label. Usually a number represented as a string e.g "1"
|
146
|
-
*/
|
147
|
-
id: string;
|
148
|
-
/**
|
149
|
-
* The text contents of the label
|
150
|
-
*/
|
151
|
-
name: string;
|
152
|
-
/**
|
153
|
-
* The items that are tagged with this label
|
154
|
-
*/
|
155
|
-
items: {
|
156
|
-
/**
|
157
|
-
* Labels can be applied to chats, contacts or individual messages. This represents the type of object the label is attached to.
|
158
|
-
*/
|
159
|
-
type: "Chat" | "Contact" | "Message";
|
160
|
-
/**
|
161
|
-
* The ID of the object that the label is atteched to.
|
162
|
-
*/
|
163
|
-
id: ContactId | ChatId | MessageId;
|
164
|
-
}[];
|
165
|
-
}
|
package/package.json
CHANGED