@hdriel/whatsapp-socket 1.2.7 → 1.2.9
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/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +302 -124
- package/dist/index.d.ts +302 -124
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Stream from 'node:stream';
|
|
2
|
+
import { WASocket, UserFacingSocketConfig, WAMessage, Contact, GroupMetadata } from '@fadzzzslebew/baileys';
|
|
2
3
|
import { StringValue } from 'ms';
|
|
3
4
|
import { Logger } from 'stack-trace-logger';
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
type ButtonURL = {
|
|
7
|
+
label: string;
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
10
|
+
type ButtonCopy = {
|
|
11
|
+
label: string;
|
|
12
|
+
copy: string;
|
|
13
|
+
};
|
|
14
|
+
type ButtonPhone = {
|
|
15
|
+
label: string;
|
|
16
|
+
tel: string;
|
|
17
|
+
};
|
|
18
|
+
type CallToActionButtons = Array<ButtonURL | ButtonCopy | ButtonPhone>;
|
|
19
|
+
type MessageOptions = {
|
|
20
|
+
mentions?: string[];
|
|
21
|
+
replyToMessageId?: string;
|
|
22
|
+
};
|
|
23
|
+
type CreateGroupOptions = {
|
|
24
|
+
name: string;
|
|
25
|
+
participants?: string[];
|
|
26
|
+
description?: string;
|
|
27
|
+
};
|
|
28
|
+
type GroupSettingsType = 'announcement' | 'not_announcement' | 'locked' | 'unlocked';
|
|
29
|
+
type MessageReceivedCB = (remoteJid: string, messageId: string, options: any) => void | Promise<void>;
|
|
5
30
|
|
|
6
31
|
type WhatsappSocketBaseProps = ({
|
|
7
32
|
mongoURL: string;
|
|
@@ -16,7 +41,6 @@ type WhatsappSocketBaseProps = ({
|
|
|
16
41
|
onOpen?: () => Promise<void> | void;
|
|
17
42
|
onClose?: () => Promise<void> | void;
|
|
18
43
|
onConnectionStatusChange?: (connectionStatus: 'connecting' | 'close' | 'open') => Promise<void> | void;
|
|
19
|
-
onReceiveMessages?: (messages: WAMessage[], type: MessageUpsertType) => Promise<void> | void;
|
|
20
44
|
onPreConnectionSendMessageFailed?: (error: Error | string) => Promise<void> | void;
|
|
21
45
|
onQR?: (qr: string, code?: string | null) => Promise<void> | void;
|
|
22
46
|
debug?: boolean;
|
|
@@ -31,6 +55,7 @@ declare class WhatsappSocketBase {
|
|
|
31
55
|
protected readonly logger?: Logger;
|
|
32
56
|
protected readonly debug?: boolean;
|
|
33
57
|
protected readonly printQRInTerminal?: boolean;
|
|
58
|
+
protected readonly messageReceivedCBs: Record<string, MessageReceivedCB[]>;
|
|
34
59
|
protected readonly pairingPhone?: string;
|
|
35
60
|
protected readonly customPairingCode?: string;
|
|
36
61
|
protected readonly appName?: string;
|
|
@@ -39,7 +64,6 @@ declare class WhatsappSocketBase {
|
|
|
39
64
|
private onClose?;
|
|
40
65
|
private onQR?;
|
|
41
66
|
private onConnectionStatusChange?;
|
|
42
|
-
private readonly onReceiveMessages?;
|
|
43
67
|
static DEFAULT_COUNTRY_CODE: string;
|
|
44
68
|
static CONNECTION_TIMEOUT: StringValue;
|
|
45
69
|
static formatPhoneNumber(phone: string, countryCode?: string): string;
|
|
@@ -89,7 +113,7 @@ declare class WhatsappSocketBase {
|
|
|
89
113
|
autoConnect?: boolean;
|
|
90
114
|
}): Promise<void>;
|
|
91
115
|
isConnected(): boolean;
|
|
92
|
-
|
|
116
|
+
myJID(): string | null;
|
|
93
117
|
/**
|
|
94
118
|
* Delete a message for everyone (if within time limit) or just for yourself
|
|
95
119
|
* @param messageId - The message ID to delete
|
|
@@ -109,34 +133,197 @@ declare class WhatsappSocketBase {
|
|
|
109
133
|
chatJid: string;
|
|
110
134
|
}>, deleteForEveryone?: true): Promise<any[]>;
|
|
111
135
|
loadRecentMessages(chatJid: string, messageId: string): Promise<WAMessage | null>;
|
|
136
|
+
getContactByJid(remoteJid: string): Promise<Contact | undefined>;
|
|
137
|
+
getContacts(username?: string, byWords?: boolean): Promise<Contact[]>;
|
|
138
|
+
areRegisteredOnWhatsApp(phone: string | string[]): Promise<Array<{
|
|
139
|
+
phone: string;
|
|
140
|
+
exists: boolean;
|
|
141
|
+
jid?: string;
|
|
142
|
+
contact: Contact | undefined;
|
|
143
|
+
}>>;
|
|
112
144
|
}
|
|
113
145
|
|
|
114
|
-
type
|
|
115
|
-
|
|
116
|
-
|
|
146
|
+
type MenuMessageProps = {
|
|
147
|
+
title: string;
|
|
148
|
+
subtitle?: string;
|
|
149
|
+
buttonText: string;
|
|
150
|
+
sections: Array<{
|
|
151
|
+
title: string;
|
|
152
|
+
rows: Array<{
|
|
153
|
+
id: string;
|
|
154
|
+
title: string;
|
|
155
|
+
description?: string;
|
|
156
|
+
}>;
|
|
157
|
+
}>;
|
|
117
158
|
};
|
|
118
|
-
type
|
|
119
|
-
|
|
120
|
-
|
|
159
|
+
type AudioMessageProps = {
|
|
160
|
+
filename?: string;
|
|
161
|
+
replyToMessageId?: string;
|
|
162
|
+
mimetype?: string;
|
|
163
|
+
seconds?: number;
|
|
164
|
+
ptt?: boolean;
|
|
165
|
+
mentions?: string[];
|
|
121
166
|
};
|
|
122
|
-
type
|
|
123
|
-
|
|
124
|
-
|
|
167
|
+
type ButtonsMessageProps = {
|
|
168
|
+
title: string;
|
|
169
|
+
subtitle?: string;
|
|
170
|
+
buttons: CallToActionButtons;
|
|
125
171
|
};
|
|
126
|
-
type
|
|
127
|
-
|
|
172
|
+
type DocumentMessageProps = {
|
|
173
|
+
filename?: string;
|
|
174
|
+
caption?: string;
|
|
175
|
+
mimetype?: string;
|
|
128
176
|
mentions?: string[];
|
|
129
|
-
|
|
177
|
+
jpegThumbnail?: Buffer | string;
|
|
130
178
|
};
|
|
131
|
-
type
|
|
132
|
-
|
|
133
|
-
|
|
179
|
+
type ImageMessageProps = {
|
|
180
|
+
caption?: string;
|
|
181
|
+
filename?: string;
|
|
182
|
+
mentions?: string[];
|
|
183
|
+
};
|
|
184
|
+
type ReplyMessageProps = {
|
|
185
|
+
title: string;
|
|
186
|
+
subtitle?: string;
|
|
187
|
+
buttons: Array<string | {
|
|
188
|
+
id: number | string;
|
|
189
|
+
label: string;
|
|
190
|
+
}>;
|
|
191
|
+
};
|
|
192
|
+
type SurveyMessageProps = {
|
|
193
|
+
question: string;
|
|
194
|
+
options: string[];
|
|
195
|
+
allowMultipleAnswers?: boolean;
|
|
196
|
+
};
|
|
197
|
+
type TextMessageProps = {
|
|
198
|
+
text: string;
|
|
199
|
+
};
|
|
200
|
+
type VideoMessageProps = {
|
|
201
|
+
caption?: string;
|
|
202
|
+
sendAsGifPlayback?: boolean;
|
|
203
|
+
filename?: string;
|
|
204
|
+
mentions?: string[];
|
|
205
|
+
};
|
|
206
|
+
type LocationMessageProps = {
|
|
207
|
+
latitude: number;
|
|
208
|
+
longitude: number;
|
|
209
|
+
name?: string;
|
|
210
|
+
address?: string;
|
|
211
|
+
};
|
|
212
|
+
type StickerMessageProps = {
|
|
213
|
+
mentions?: string[];
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
type ReplyMessage = Omit<ReplyMessageProps, 'buttons'> & {
|
|
217
|
+
buttons: Array<{
|
|
218
|
+
id: number | string;
|
|
219
|
+
label: string;
|
|
220
|
+
}>;
|
|
221
|
+
};
|
|
222
|
+
type Message = {
|
|
223
|
+
timeout?: StringValue | number;
|
|
224
|
+
forceExit?: boolean;
|
|
225
|
+
text: TextMessageProps;
|
|
226
|
+
} | {
|
|
227
|
+
timeout?: StringValue | number;
|
|
228
|
+
forceExit?: boolean;
|
|
229
|
+
menu: MenuMessageProps;
|
|
230
|
+
} | {
|
|
231
|
+
timeout?: StringValue | number;
|
|
232
|
+
forceExit?: boolean;
|
|
233
|
+
reply: ReplyMessage;
|
|
234
|
+
} | {
|
|
235
|
+
timeout?: StringValue | number;
|
|
236
|
+
forceExit?: boolean;
|
|
237
|
+
buttons: ButtonsMessageProps;
|
|
238
|
+
} | {
|
|
239
|
+
timeout?: StringValue | number;
|
|
240
|
+
forceExit?: boolean;
|
|
241
|
+
survey: SurveyMessageProps;
|
|
242
|
+
} | {
|
|
243
|
+
timeout?: StringValue | number;
|
|
244
|
+
forceExit?: boolean;
|
|
245
|
+
image: ImageMessageProps;
|
|
246
|
+
} | {
|
|
247
|
+
timeout?: StringValue | number;
|
|
248
|
+
forceExit?: boolean;
|
|
249
|
+
video: VideoMessageProps;
|
|
250
|
+
} | {
|
|
251
|
+
timeout?: StringValue | number;
|
|
252
|
+
forceExit?: boolean;
|
|
253
|
+
sticker: StickerMessageProps;
|
|
254
|
+
} | {
|
|
255
|
+
timeout?: StringValue | number;
|
|
256
|
+
forceExit?: boolean;
|
|
257
|
+
audio: AudioMessageProps;
|
|
258
|
+
} | {
|
|
259
|
+
timeout?: StringValue | number;
|
|
260
|
+
forceExit?: boolean;
|
|
261
|
+
document: DocumentMessageProps;
|
|
262
|
+
} | {
|
|
263
|
+
timeout?: StringValue | number;
|
|
264
|
+
forceExit?: boolean;
|
|
265
|
+
location: LocationMessageProps;
|
|
266
|
+
};
|
|
267
|
+
type ScenarioResponse = {
|
|
268
|
+
field?: string;
|
|
269
|
+
onSubmit?: (values: {
|
|
270
|
+
messageId: string;
|
|
271
|
+
options?: any;
|
|
272
|
+
data?: any;
|
|
273
|
+
remoteJid: string;
|
|
274
|
+
}) => void | Promise<void>;
|
|
275
|
+
next?: Scenario;
|
|
276
|
+
};
|
|
277
|
+
type MessageCB = (remoteJid: string, dataFlow: any) => Message | Promise<Message>;
|
|
278
|
+
type MessageItem = MessageCB | Message;
|
|
279
|
+
type Scenario = {
|
|
280
|
+
field?: string;
|
|
281
|
+
messages: MessageItem[];
|
|
282
|
+
response?: Record<string, // input or buttonId
|
|
283
|
+
// input or buttonId
|
|
284
|
+
ScenarioResponse | undefined>;
|
|
285
|
+
};
|
|
286
|
+
type FieldSchema = {
|
|
287
|
+
parseFieldData?: (input: string) => any;
|
|
288
|
+
validate?: (input: string) => boolean;
|
|
289
|
+
validationError?: string | ((input?: string) => string);
|
|
290
|
+
};
|
|
291
|
+
type BotSchema = {
|
|
292
|
+
name?: string;
|
|
134
293
|
description?: string;
|
|
294
|
+
exitCode?: string;
|
|
295
|
+
exitMsg?: Message;
|
|
296
|
+
unknownInputMsg?: Message;
|
|
297
|
+
idleTimeout?: StringValue | number;
|
|
298
|
+
timeoutMsg?: Message;
|
|
299
|
+
backCode?: string;
|
|
300
|
+
matches?: (string | RegExp | ((remoteJid: string, textMsg: string, fromMe?: boolean) => boolean | Promise<boolean>))[];
|
|
301
|
+
flow?: Scenario;
|
|
302
|
+
fields?: Record<string, FieldSchema>;
|
|
135
303
|
};
|
|
136
|
-
type GroupSettingsType = 'announcement' | 'not_announcement' | 'locked' | 'unlocked';
|
|
137
304
|
|
|
305
|
+
type MessageType = 'text' | 'reply' | 'menu' | 'buttons' | 'image' | 'video' | 'audio' | 'location';
|
|
138
306
|
declare class WhatsappSocketPrivateMessages extends WhatsappSocketBase {
|
|
307
|
+
protected timers: Record<string, Record<number, {
|
|
308
|
+
timeoutId: number;
|
|
309
|
+
date: Date;
|
|
310
|
+
data: Message;
|
|
311
|
+
messageType: MessageType;
|
|
312
|
+
}>>;
|
|
139
313
|
constructor(props: WhatsappSocketBaseProps);
|
|
314
|
+
protected sendMessageByType(remoteJid: string | null, messageType: MessageType, message: any): Promise<void>;
|
|
315
|
+
setTimer(remoteJid: string, messageType: MessageType, message: any, timeout: number, autoSelfNotificationFormat?: string | null): Promise<NodeJS.Timeout>;
|
|
316
|
+
getTimers(remoteJid: string): {
|
|
317
|
+
code: string;
|
|
318
|
+
message: {
|
|
319
|
+
timeoutId: number;
|
|
320
|
+
date: Date;
|
|
321
|
+
data: Message;
|
|
322
|
+
messageType: MessageType;
|
|
323
|
+
};
|
|
324
|
+
}[];
|
|
325
|
+
removeTimerId(remoteJid: string, timerId: number): void;
|
|
326
|
+
resetTimers(remoteJid?: string): void;
|
|
140
327
|
/**
|
|
141
328
|
* Delete a sent message
|
|
142
329
|
* @param messageId - The message ID to delete
|
|
@@ -144,13 +331,13 @@ declare class WhatsappSocketPrivateMessages extends WhatsappSocketBase {
|
|
|
144
331
|
* @returns Promise with the result
|
|
145
332
|
*/
|
|
146
333
|
deleteMessageById(messageId: string, chatJid: string): Promise<any>;
|
|
147
|
-
sendTextMessage(to: string, text: string): Promise<any>;
|
|
148
|
-
sendButtonsMessage(to: string, { subtitle, title, buttons }: {
|
|
334
|
+
sendTextMessage(to: string | null, text: string): Promise<any>;
|
|
335
|
+
sendButtonsMessage(to: string | null, { subtitle, title, buttons }: {
|
|
149
336
|
title: string;
|
|
150
337
|
subtitle?: string;
|
|
151
338
|
buttons: CallToActionButtons;
|
|
152
339
|
}): Promise<any>;
|
|
153
|
-
|
|
340
|
+
sendMenuMessage(to: string | null, { title, subtitle, buttonText, sections, }: {
|
|
154
341
|
title: string;
|
|
155
342
|
subtitle?: string;
|
|
156
343
|
buttonText: string;
|
|
@@ -163,7 +350,7 @@ declare class WhatsappSocketPrivateMessages extends WhatsappSocketBase {
|
|
|
163
350
|
}>;
|
|
164
351
|
}>;
|
|
165
352
|
}): Promise<any>;
|
|
166
|
-
sendReplyButtonsMessage(to: string, { title, subtitle, buttons, }: {
|
|
353
|
+
sendReplyButtonsMessage(to: string | null, { title, subtitle, buttons, }: {
|
|
167
354
|
title: string;
|
|
168
355
|
subtitle?: string;
|
|
169
356
|
buttons: Array<string | {
|
|
@@ -171,79 +358,28 @@ declare class WhatsappSocketPrivateMessages extends WhatsappSocketBase {
|
|
|
171
358
|
label: string;
|
|
172
359
|
}>;
|
|
173
360
|
}): Promise<any>;
|
|
174
|
-
|
|
361
|
+
sendLocationMessage(to: string | null, { latitude, longitude, name, address, }: {
|
|
175
362
|
latitude: number;
|
|
176
363
|
longitude: number;
|
|
177
364
|
name?: string;
|
|
178
365
|
address?: string;
|
|
179
366
|
}): Promise<any>;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
sendSurveyMessage(to: string, question: string, options: string[], allowMultipleAnswers?: boolean): Promise<any>;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
declare class WhatsappSocketPrivateStream extends WhatsappSocketPrivateMessages {
|
|
188
|
-
constructor(props: WhatsappSocketBaseProps);
|
|
189
|
-
protected sendFileFromStream(to: string, stream: Stream | Buffer, options: {
|
|
190
|
-
filename: string;
|
|
191
|
-
mimetype?: string;
|
|
192
|
-
caption?: string;
|
|
193
|
-
replyToMessageId?: string;
|
|
194
|
-
ptt?: boolean;
|
|
195
|
-
seconds?: number;
|
|
196
|
-
gifPlayback?: boolean;
|
|
197
|
-
jpegThumbnail?: Buffer | string;
|
|
198
|
-
}): Promise<any>;
|
|
199
|
-
private streamToBuffer;
|
|
200
|
-
private createFileMessage;
|
|
201
|
-
protected sendImage(to: string, imageBuffer: Buffer | Stream, options?: {
|
|
202
|
-
caption?: string;
|
|
203
|
-
filename?: string;
|
|
204
|
-
replyToMessageId?: string;
|
|
205
|
-
}): Promise<any>;
|
|
206
|
-
protected sendVideo(to: string, videoBuffer: Buffer | Stream, options?: {
|
|
207
|
-
caption?: string;
|
|
208
|
-
filename?: string;
|
|
209
|
-
gifPlayback?: boolean;
|
|
210
|
-
replyToMessageId?: string;
|
|
211
|
-
jpegThumbnail?: Buffer;
|
|
212
|
-
}): Promise<any>;
|
|
213
|
-
protected sendAudio(to: string, audioBuffer: Buffer | Stream, options?: {
|
|
214
|
-
filename?: string;
|
|
215
|
-
ptt?: boolean;
|
|
216
|
-
seconds?: number;
|
|
217
|
-
replyToMessageId?: string;
|
|
218
|
-
}): Promise<any>;
|
|
219
|
-
protected sendDocument(to: string, documentBuffer: Buffer | Stream, options: {
|
|
220
|
-
filename: string;
|
|
221
|
-
caption?: string;
|
|
222
|
-
mimetype?: string;
|
|
223
|
-
replyToMessageId?: string;
|
|
224
|
-
jpegThumbnail?: Buffer;
|
|
225
|
-
}): Promise<any>;
|
|
226
|
-
protected sendVoiceNote(to: string, audioBuffer: Buffer | Stream, options?: {
|
|
227
|
-
seconds?: number;
|
|
228
|
-
replyToMessageId?: string;
|
|
229
|
-
}): Promise<any>;
|
|
230
|
-
protected sendSticker(to: string, stickerBuffer: Buffer | Stream, options?: {
|
|
231
|
-
replyToMessageId?: string;
|
|
367
|
+
sendSurveyMessage(to: string | null, { question, options, allowMultipleAnswers, }: {
|
|
368
|
+
question: string;
|
|
369
|
+
options: string[];
|
|
370
|
+
allowMultipleAnswers?: boolean;
|
|
232
371
|
}): Promise<any>;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
declare class WhatsappSocketPrivateFiles extends WhatsappSocketPrivateStream {
|
|
236
|
-
constructor(props: WhatsappSocketBaseProps);
|
|
237
|
-
sendImageMessage(to: string, imageSrc: string | Buffer<any> | Stream, { caption, filename }?: {
|
|
372
|
+
sendReactionMessage(to: string | null, messageId: string, emoji: string): Promise<any>;
|
|
373
|
+
sendImageMessage(to: string | null, imageSrc: string | Buffer<any> | Stream, { caption, filename }?: {
|
|
238
374
|
caption?: string;
|
|
239
375
|
filename?: string;
|
|
240
376
|
}): Promise<any>;
|
|
241
|
-
sendVideoMessage(to: string, videoSrc: string | Buffer<any> | Stream, { caption, filename, sendAsGifPlayback
|
|
377
|
+
sendVideoMessage(to: string | null, videoSrc: string | Buffer<any> | Stream, { caption, filename, sendAsGifPlayback, }?: {
|
|
242
378
|
caption?: string;
|
|
243
379
|
sendAsGifPlayback?: boolean;
|
|
244
380
|
filename?: string;
|
|
245
381
|
}): Promise<any>;
|
|
246
|
-
sendAudioMessage(to: string, audioSrc: string | Buffer<any> | Stream, { filename, replyToMessageId, mimetype, seconds, }?: {
|
|
382
|
+
sendAudioMessage(to: string | null, audioSrc: string | Buffer<any> | Stream, { filename, replyToMessageId, mimetype, seconds, }?: {
|
|
247
383
|
filename?: string;
|
|
248
384
|
replyToMessageId?: string;
|
|
249
385
|
mimetype?: string;
|
|
@@ -258,17 +394,25 @@ declare class WhatsappSocketPrivateFiles extends WhatsappSocketPrivateStream {
|
|
|
258
394
|
* @param to
|
|
259
395
|
* @param imageSrc
|
|
260
396
|
*/
|
|
261
|
-
sendStickerMessage(to: string, imageSrc: string | Buffer<any> | Stream): Promise<any>;
|
|
262
|
-
sendFileMessage(to: string, fileSrc: string | Buffer<any> | Stream, { caption, mimetype,
|
|
397
|
+
sendStickerMessage(to: string | null, imageSrc: string | Buffer<any> | Stream): Promise<any>;
|
|
398
|
+
sendFileMessage(to: string | null, fileSrc: string | Buffer<any> | Stream, { caption, mimetype, jpegThumbnailSrc, autoMessageClassification, filename, }: {
|
|
263
399
|
caption?: string;
|
|
264
400
|
mimetype?: string;
|
|
265
401
|
filename: string;
|
|
266
402
|
autoMessageClassification?: boolean;
|
|
267
|
-
replyToMessageId?: string;
|
|
268
403
|
jpegThumbnailSrc?: string | Buffer<any> | Stream;
|
|
269
404
|
}): Promise<any>;
|
|
270
405
|
}
|
|
271
406
|
|
|
407
|
+
type WhatsappSocketProps = WhatsappSocketBaseProps;
|
|
408
|
+
declare class WhatsappSocket extends WhatsappSocketPrivateMessages {
|
|
409
|
+
constructor(props: WhatsappSocketProps);
|
|
410
|
+
onAnyMessageReceived(cb: MessageReceivedCB): void;
|
|
411
|
+
offAnyMessageReceived(cb: MessageReceivedCB): void;
|
|
412
|
+
onPhoneMessageReceived(phone: string, cb: MessageReceivedCB): void;
|
|
413
|
+
offPhoneMessageReceived(phone: string, cb?: MessageReceivedCB): void;
|
|
414
|
+
}
|
|
415
|
+
|
|
272
416
|
declare class WhatsappSocketGroups extends WhatsappSocketBase {
|
|
273
417
|
/**
|
|
274
418
|
* פורמט Group ID לתבנית WhatsApp
|
|
@@ -360,10 +504,22 @@ declare class WhatsappSocketGroups extends WhatsappSocketBase {
|
|
|
360
504
|
|
|
361
505
|
declare class WhatsappSocketGroupMessages extends WhatsappSocketGroups {
|
|
362
506
|
constructor(props: WhatsappSocketBaseProps);
|
|
507
|
+
/**
|
|
508
|
+
* Send message mentioning all group participants
|
|
509
|
+
*/
|
|
510
|
+
sendMentionAll(groupId: string, text: string): Promise<any>;
|
|
511
|
+
/**
|
|
512
|
+
* Send reaction to a message in group
|
|
513
|
+
*/
|
|
514
|
+
sendReactionMessage(groupId: string, messageId: string, emoji: string): Promise<any>;
|
|
515
|
+
/**
|
|
516
|
+
* Delete a message in group (only works for own messages)
|
|
517
|
+
*/
|
|
518
|
+
deleteGroupMessage(groupId: string, messageId: string): Promise<any>;
|
|
363
519
|
/**
|
|
364
520
|
* Send text message to group
|
|
365
521
|
*/
|
|
366
|
-
sendTextMessage(groupId: string, text: string
|
|
522
|
+
sendTextMessage(groupId: string, text: string): Promise<any>;
|
|
367
523
|
/**
|
|
368
524
|
* Send buttons message to group
|
|
369
525
|
*/
|
|
@@ -384,7 +540,7 @@ declare class WhatsappSocketGroupMessages extends WhatsappSocketGroups {
|
|
|
384
540
|
}>;
|
|
385
541
|
mentions?: string[];
|
|
386
542
|
}): Promise<any>;
|
|
387
|
-
|
|
543
|
+
sendMenuMessage(groupId: string, { title, subtitle, buttonText, sections, }: {
|
|
388
544
|
title: string;
|
|
389
545
|
subtitle?: string;
|
|
390
546
|
buttonText: string;
|
|
@@ -397,17 +553,31 @@ declare class WhatsappSocketGroupMessages extends WhatsappSocketGroups {
|
|
|
397
553
|
}>;
|
|
398
554
|
}>;
|
|
399
555
|
}): Promise<any>;
|
|
556
|
+
/**
|
|
557
|
+
* Send location to group
|
|
558
|
+
*/
|
|
559
|
+
sendLocationMessage(groupId: string, { latitude, longitude, name, address, }: {
|
|
560
|
+
latitude: number;
|
|
561
|
+
longitude: number;
|
|
562
|
+
name?: string;
|
|
563
|
+
address?: string;
|
|
564
|
+
}): Promise<any>;
|
|
565
|
+
sendSurveyMessage(groupId: string, { question, options, allowMultipleAnswers, }: {
|
|
566
|
+
question: string;
|
|
567
|
+
options: string[];
|
|
568
|
+
allowMultipleAnswers?: boolean;
|
|
569
|
+
}): Promise<any>;
|
|
400
570
|
/**
|
|
401
571
|
* Send image to group
|
|
402
572
|
*/
|
|
403
|
-
sendImageMessage(groupId: string, imageSrc: string | Buffer | Stream, { caption, filename, mentions }?:
|
|
573
|
+
sendImageMessage(groupId: string, imageSrc: string | Buffer | Stream, { caption, filename, mentions }?: MessageOptions & {
|
|
404
574
|
caption?: string;
|
|
405
575
|
filename?: string;
|
|
406
576
|
}): Promise<any>;
|
|
407
577
|
/**
|
|
408
578
|
* Send video to group
|
|
409
579
|
*/
|
|
410
|
-
sendVideoMessage(groupId: string, videoSrc: string | Buffer | Stream, { caption, filename, sendAsGifPlayback
|
|
580
|
+
sendVideoMessage(groupId: string, videoSrc: string | Buffer | Stream, { caption, filename, sendAsGifPlayback, mentions, }?: MessageOptions & {
|
|
411
581
|
caption?: string;
|
|
412
582
|
filename?: string;
|
|
413
583
|
sendAsGifPlayback?: boolean;
|
|
@@ -415,7 +585,7 @@ declare class WhatsappSocketGroupMessages extends WhatsappSocketGroups {
|
|
|
415
585
|
/**
|
|
416
586
|
* Send audio to group
|
|
417
587
|
*/
|
|
418
|
-
sendAudioMessage(groupId: string, audioSrc: string | Buffer | Stream, { filename,
|
|
588
|
+
sendAudioMessage(groupId: string, audioSrc: string | Buffer | Stream, { filename, mimetype, seconds, ptt, mentions, }?: {
|
|
419
589
|
filename?: string;
|
|
420
590
|
replyToMessageId?: string;
|
|
421
591
|
mimetype?: string;
|
|
@@ -426,34 +596,13 @@ declare class WhatsappSocketGroupMessages extends WhatsappSocketGroups {
|
|
|
426
596
|
/**
|
|
427
597
|
* Send document to group
|
|
428
598
|
*/
|
|
429
|
-
sendDocumentMessage(groupId: string, documentSrc: string | Buffer | Stream, { fileName, caption, mimetype,
|
|
599
|
+
sendDocumentMessage(groupId: string, documentSrc: string | Buffer | Stream, { fileName, caption, mimetype, jpegThumbnail, mentions, }: {
|
|
430
600
|
fileName: string;
|
|
431
601
|
caption?: string;
|
|
432
602
|
mimetype?: string;
|
|
433
|
-
replyToMessageId?: string;
|
|
434
603
|
jpegThumbnail?: Buffer;
|
|
435
604
|
mentions?: string[];
|
|
436
605
|
}): Promise<any>;
|
|
437
|
-
/**
|
|
438
|
-
* Send location to group
|
|
439
|
-
*/
|
|
440
|
-
sendLocationMessage(groupId: string, position: {
|
|
441
|
-
latitude: number;
|
|
442
|
-
longitude: number;
|
|
443
|
-
}, name?: string, address?: string): Promise<any>;
|
|
444
|
-
/**
|
|
445
|
-
* Send message mentioning all group participants
|
|
446
|
-
*/
|
|
447
|
-
sendMentionAll(groupId: string, text: string): Promise<any>;
|
|
448
|
-
/**
|
|
449
|
-
* Send reaction to a message in group
|
|
450
|
-
*/
|
|
451
|
-
sendReactionMessage(groupId: string, messageId: string, emoji: string): Promise<any>;
|
|
452
|
-
/**
|
|
453
|
-
* Delete a message in group (only works for own messages)
|
|
454
|
-
*/
|
|
455
|
-
deleteGroupMessage(groupId: string, messageId: string): Promise<any>;
|
|
456
|
-
sendSurveyMessage(groupId: string, question: string, options: string[], allowMultipleAnswers?: boolean): Promise<any>;
|
|
457
606
|
/**
|
|
458
607
|
* Send sticker to group
|
|
459
608
|
* Requirements:
|
|
@@ -462,25 +611,54 @@ declare class WhatsappSocketGroupMessages extends WhatsappSocketGroups {
|
|
|
462
611
|
* * maxSize: 100kb
|
|
463
612
|
* * transparent background
|
|
464
613
|
*/
|
|
465
|
-
sendStickerMessage(groupId: string, imageSrc: string | Buffer | Stream
|
|
466
|
-
|
|
614
|
+
sendStickerMessage(groupId: string, imageSrc: string | Buffer | Stream, { mentions }?: {
|
|
615
|
+
mentions?: string[];
|
|
616
|
+
}): Promise<any>;
|
|
617
|
+
sendFileMessage(groupId: string, fileSrc: string | Buffer | Stream, { caption, mimetype, jpegThumbnailSrc, autoMessageClassification, filename, mentions, }: {
|
|
467
618
|
caption?: string;
|
|
468
619
|
mimetype?: string;
|
|
469
620
|
filename: string;
|
|
470
621
|
autoMessageClassification?: boolean;
|
|
471
|
-
replyToMessageId?: string;
|
|
472
622
|
jpegThumbnailSrc?: string | Buffer | Stream;
|
|
623
|
+
mentions?: string[];
|
|
473
624
|
}): Promise<any>;
|
|
474
625
|
}
|
|
475
626
|
|
|
476
|
-
type WhatsappSocketProps = WhatsappSocketBaseProps;
|
|
477
|
-
declare class WhatsappSocket extends WhatsappSocketPrivateFiles {
|
|
478
|
-
constructor(props: WhatsappSocketProps);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
627
|
type WhatsappSocketGroupProps = WhatsappSocketBaseProps;
|
|
482
628
|
declare class WhatsappSocketGroup extends WhatsappSocketGroupMessages {
|
|
483
629
|
constructor(props: WhatsappSocketGroupProps);
|
|
630
|
+
onAnyGroupMessageReceived(cb: MessageReceivedCB): void;
|
|
631
|
+
offAnyGroupMessageReceived(cb: MessageReceivedCB): void;
|
|
632
|
+
onGroupMessageReceived(groupId: string, cb: MessageReceivedCB): void;
|
|
633
|
+
offGroupMessageReceived(groupId: string, cb: MessageReceivedCB): void;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
declare class WhatsappSocketBot {
|
|
637
|
+
protected schema: BotSchema;
|
|
638
|
+
protected phone?: string;
|
|
639
|
+
protected client?: WhatsappSocket;
|
|
640
|
+
private schemaRefs;
|
|
641
|
+
private remoteFlow;
|
|
642
|
+
private dataFlow;
|
|
643
|
+
private timeoutFlow;
|
|
644
|
+
private lastMessages;
|
|
645
|
+
constructor(schema: BotSchema, phone?: string);
|
|
646
|
+
updateSchemaRefs(flow: undefined | Scenario): void;
|
|
647
|
+
set socket(socket: WhatsappSocket);
|
|
648
|
+
get socket(): WhatsappSocket;
|
|
649
|
+
private sendMessageList;
|
|
650
|
+
private getFlow;
|
|
651
|
+
private setFlow;
|
|
652
|
+
private resetFlow;
|
|
653
|
+
private getDataFlow;
|
|
654
|
+
private getLastMessages;
|
|
655
|
+
private setDataFlow;
|
|
656
|
+
private resetDataFlow;
|
|
657
|
+
private setTimeoutFlow;
|
|
658
|
+
private resetTimeoutFlow;
|
|
659
|
+
private getResponseId;
|
|
660
|
+
private onMessageReceivedCB;
|
|
661
|
+
onMessageReceived(): void;
|
|
484
662
|
}
|
|
485
663
|
|
|
486
|
-
export { WhatsappSocket, WhatsappSocketGroup, type WhatsappSocketGroupProps, type WhatsappSocketProps };
|
|
664
|
+
export { type BotSchema, WhatsappSocket, WhatsappSocketBot, WhatsappSocketGroup, type WhatsappSocketGroupProps, type WhatsappSocketProps };
|