@queenanya/baileys 6.6.6 → 6.7.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 +1 -5
- package/README.md +31 -93
- package/WAProto/WAProto.proto +473 -8
- package/WAProto/index.d.ts +4793 -22
- package/WAProto/index.js +32548 -19335
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +2 -2
- package/lib/Defaults/index.js +6 -2
- package/lib/Socket/business.d.ts +9 -0
- package/lib/Socket/chats.d.ts +4 -0
- package/lib/Socket/chats.js +13 -1
- package/lib/Socket/groups.d.ts +6 -0
- package/lib/Socket/groups.js +9 -2
- package/lib/Socket/index.d.ts +9 -0
- package/lib/Socket/messages-recv.d.ts +9 -0
- package/lib/Socket/messages-recv.js +29 -7
- package/lib/Socket/messages-send.d.ts +7 -0
- package/lib/Socket/messages-send.js +7 -4
- package/lib/Socket/registration.d.ts +9 -0
- package/lib/Socket/socket.js +3 -2
- package/lib/Store/make-cache-manager-store.d.ts +0 -1
- package/lib/Types/Call.d.ts +1 -0
- package/lib/Types/Contact.d.ts +1 -0
- package/lib/Types/Events.d.ts +5 -0
- package/lib/Types/GroupMetadata.d.ts +2 -0
- package/lib/Types/Message.d.ts +7 -1
- package/lib/Types/Socket.d.ts +2 -0
- package/lib/Types/index.d.ts +3 -1
- package/lib/Types/index.js +2 -0
- package/lib/Utils/chat-utils.js +14 -0
- package/lib/Utils/decode-wa-message.d.ts +2 -2
- package/lib/Utils/decode-wa-message.js +18 -4
- package/lib/Utils/generics.d.ts +1 -0
- package/lib/Utils/generics.js +1 -0
- package/lib/Utils/messages-media.js +1 -1
- package/lib/Utils/messages.d.ts +1 -1
- package/lib/Utils/messages.js +11 -5
- package/lib/Utils/process-message.js +27 -4
- package/lib/Utils/validate-connection.js +33 -2
- package/lib/WABinary/decode.js +1 -1
- package/lib/WABinary/encode.js +3 -3
- package/lib/WABinary/jid-utils.d.ts +4 -2
- package/lib/WABinary/jid-utils.js +6 -3
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -134,6 +134,8 @@ type SocketConfig = {
|
|
|
134
134
|
customUploadHosts: MediaConnInfo['hosts']
|
|
135
135
|
/** time to wait between sending new retry requests */
|
|
136
136
|
retryRequestDelayMs: number
|
|
137
|
+
/** max msg retry count */
|
|
138
|
+
maxMsgRetryCount: number
|
|
137
139
|
/** time to wait for the generation of the next QR in ms */
|
|
138
140
|
qrTimeout?: number;
|
|
139
141
|
/** provide an auth state object to maintain the auth state */
|
|
@@ -376,65 +378,6 @@ const sentMsg = await sock.sendMessage(
|
|
|
376
378
|
}
|
|
377
379
|
)
|
|
378
380
|
|
|
379
|
-
// send a buttons message!
|
|
380
|
-
const buttons = [
|
|
381
|
-
{buttonId: 'id1', buttonText: {displayText: 'Button 1'}, type: 1},
|
|
382
|
-
{buttonId: 'id2', buttonText: {displayText: 'Button 2'}, type: 1},
|
|
383
|
-
{buttonId: 'id3', buttonText: {displayText: 'Button 3'}, type: 1}
|
|
384
|
-
]
|
|
385
|
-
|
|
386
|
-
const buttonMessage = {
|
|
387
|
-
text: "Hi it's button message",
|
|
388
|
-
footer: 'Hello World',
|
|
389
|
-
buttons: buttons,
|
|
390
|
-
headerType: 1
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
const sendMsg = await sock.sendMessage(id, buttonMessage)
|
|
394
|
-
|
|
395
|
-
//send a template message!
|
|
396
|
-
const templateButtons = [
|
|
397
|
-
{index: 1, urlButton: {displayText: '⭐ Star Baileys on GitHub!', url: 'https://github.com/adiwajshing/Baileys'}},
|
|
398
|
-
{index: 2, callButton: {displayText: 'Call me!', phoneNumber: '+1 (234) 5678-901'}},
|
|
399
|
-
{index: 3, quickReplyButton: {displayText: 'This is a reply, just like normal buttons!', id: 'id-like-buttons-message'}},
|
|
400
|
-
]
|
|
401
|
-
|
|
402
|
-
const templateMessage = {
|
|
403
|
-
text: "Hi it's a template message",
|
|
404
|
-
footer: 'Hello World',
|
|
405
|
-
templateButtons: templateButtons
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
const sendMsg = await sock.sendMessage(id, templateMessage)
|
|
409
|
-
|
|
410
|
-
// send a list message!
|
|
411
|
-
const sections = [
|
|
412
|
-
{
|
|
413
|
-
title: "Section 1",
|
|
414
|
-
rows: [
|
|
415
|
-
{title: "Option 1", rowId: "option1"},
|
|
416
|
-
{title: "Option 2", rowId: "option2", description: "This is a description"}
|
|
417
|
-
]
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
title: "Section 2",
|
|
421
|
-
rows: [
|
|
422
|
-
{title: "Option 3", rowId: "option3"},
|
|
423
|
-
{title: "Option 4", rowId: "option4", description: "This is a description V2"}
|
|
424
|
-
]
|
|
425
|
-
},
|
|
426
|
-
]
|
|
427
|
-
|
|
428
|
-
const listMessage = {
|
|
429
|
-
text: "This is a list",
|
|
430
|
-
footer: "nice footer, link: https://google.com",
|
|
431
|
-
title: "Amazing boldfaced list title",
|
|
432
|
-
buttonText: "Required, text on the button to view the list",
|
|
433
|
-
sections
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
const sendMsg = await sock.sendMessage(id, listMessage)
|
|
437
|
-
|
|
438
381
|
const reactionMessage = {
|
|
439
382
|
react: {
|
|
440
383
|
text: "💖", // use an empty string to remove the reaction
|
|
@@ -489,39 +432,6 @@ await sock.sendMessage(
|
|
|
489
432
|
{ audio: { url: "./Media/audio.mp3" }, mimetype: 'audio/mp4' }
|
|
490
433
|
{ url: "Media/audio.mp3" }, // can send mp3, mp4, & ogg
|
|
491
434
|
)
|
|
492
|
-
|
|
493
|
-
// send a buttons message with image header!
|
|
494
|
-
const buttons = [
|
|
495
|
-
{buttonId: 'id1', buttonText: {displayText: 'Button 1'}, type: 1},
|
|
496
|
-
{buttonId: 'id2', buttonText: {displayText: 'Button 2'}, type: 1},
|
|
497
|
-
{buttonId: 'id3', buttonText: {displayText: 'Button 3'}, type: 1}
|
|
498
|
-
]
|
|
499
|
-
|
|
500
|
-
const buttonMessage = {
|
|
501
|
-
image: {url: 'https://example.com/image.jpeg'},
|
|
502
|
-
caption: "Hi it's button message",
|
|
503
|
-
footer: 'Hello World',
|
|
504
|
-
buttons: buttons,
|
|
505
|
-
headerType: 4
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
const sendMsg = await sock.sendMessage(id, buttonMessage)
|
|
509
|
-
|
|
510
|
-
//send a template message with an image **attached**!
|
|
511
|
-
const templateButtons = [
|
|
512
|
-
{index: 1, urlButton: {displayText: '⭐ Star Baileys on GitHub!', url: 'https://github.com/adiwajshing/Baileys'}},
|
|
513
|
-
{index: 2, callButton: {displayText: 'Call me!', phoneNumber: '+1 (234) 5678-901'}},
|
|
514
|
-
{index: 3, quickReplyButton: {displayText: 'This is a reply, just like normal buttons!', id: 'id-like-buttons-message'}},
|
|
515
|
-
]
|
|
516
|
-
|
|
517
|
-
const buttonMessage = {
|
|
518
|
-
text: "Hi it's a template message",
|
|
519
|
-
footer: 'Hello World',
|
|
520
|
-
templateButtons: templateButtons,
|
|
521
|
-
image: {url: 'https://example.com/image.jpeg'}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
const sendMsg = await sock.sendMessage(id, templateMessage)
|
|
525
435
|
```
|
|
526
436
|
|
|
527
437
|
### Notes
|
|
@@ -648,6 +558,17 @@ await sock.sendMessage(jid, { delete: response.key })
|
|
|
648
558
|
|
|
649
559
|
**Note:** deleting for oneself is supported via `chatModify` (next section)
|
|
650
560
|
|
|
561
|
+
## Updating Messages
|
|
562
|
+
|
|
563
|
+
``` ts
|
|
564
|
+
const jid = '1234@s.whatsapp.net'
|
|
565
|
+
|
|
566
|
+
await sock.sendMessage(jid, {
|
|
567
|
+
text: 'updated text goes here',
|
|
568
|
+
edit: response.key,
|
|
569
|
+
});
|
|
570
|
+
```
|
|
571
|
+
|
|
651
572
|
## Modifying Chats
|
|
652
573
|
|
|
653
574
|
WA uses an encrypted form of communication to send chat/app updates. This has been implemented mostly and you can send the following updates:
|
|
@@ -698,6 +619,15 @@ WA uses an encrypted form of communication to send chat/app updates. This has be
|
|
|
698
619
|
},
|
|
699
620
|
'123456@s.whatsapp.net')
|
|
700
621
|
```
|
|
622
|
+
|
|
623
|
+
- Star/unstar a message
|
|
624
|
+
``` ts
|
|
625
|
+
await sock.chatModify({
|
|
626
|
+
star: {
|
|
627
|
+
messages: [{ id: 'messageID', fromMe: true // or `false` }],
|
|
628
|
+
star: true // - true: Star Message; false: Unstar Message
|
|
629
|
+
}},'123456@s.whatsapp.net');
|
|
630
|
+
```
|
|
701
631
|
|
|
702
632
|
**Note:** if you mess up one of your updates, WA can log you out of all your devices and you'll have to log in again.
|
|
703
633
|
|
|
@@ -914,7 +844,15 @@ Of course, replace ``` xyz ``` with an actual ID.
|
|
|
914
844
|
```
|
|
915
845
|
## Broadcast Lists & Stories
|
|
916
846
|
|
|
917
|
-
|
|
847
|
+
Messages can be sent to broadcasts & stories.
|
|
848
|
+
you need to add the following message options in sendMessage, like this:
|
|
849
|
+
```ts
|
|
850
|
+
sock.sendMessage(jid, {image: {url: url}, caption: caption}, {backgroundColor : backgroundColor, font : font, statusJidList: statusJidList, broadcast : true})
|
|
851
|
+
```
|
|
852
|
+
- the message body can be a extendedTextMessage or imageMessage or videoMessage or voiceMessage
|
|
853
|
+
- You can add backgroundColor and other options in the message options
|
|
854
|
+
- broadcast: true enables broadcast mode
|
|
855
|
+
- statusJidList: a list of people that you can get which you need to provide, which are the people who will get this status message.
|
|
918
856
|
|
|
919
857
|
- You can send messages to broadcast lists the same way you send messages to groups & individual chats.
|
|
920
858
|
- Right now, WA Web does not support creating broadcast lists, but you can still delete them.
|