@nexustechpro/baileys 1.0.1 → 1.0.3-rc.1
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/lib/Signal/libsignal.js +391 -329
- package/lib/Socket/messages-recv.js +1313 -1199
- package/lib/Socket/messages-send.js +6 -3
- package/lib/Socket/nexus-handler.js +78 -6
- package/lib/Socket/socket.js +1000 -841
- package/lib/Store/index.js +8 -1
- package/lib/Utils/decode-wa-message.js +273 -254
- package/lib/Utils/event-buffer.js +522 -523
- package/lib/index.js +0 -2
- package/package.json +2 -2
|
@@ -1271,10 +1271,13 @@ export const makeMessagesSocket = (config) => {
|
|
|
1271
1271
|
return await nexus.handlePollResult(content, jid, quoted)
|
|
1272
1272
|
|
|
1273
1273
|
case 'CAROUSEL':
|
|
1274
|
-
|
|
1275
|
-
|
|
1274
|
+
return await nexus.handleCarousel(content, jid, quoted);
|
|
1275
|
+
|
|
1276
|
+
case 'CAROUSEL_PROTO':
|
|
1277
|
+
return await nexus.handleCarouselProto(content, jid, quoted);
|
|
1278
|
+
|
|
1276
1279
|
case 'OLD_BUTTON':
|
|
1277
|
-
|
|
1280
|
+
return await nexus.handleOldButtons(content, jid, quoted);
|
|
1278
1281
|
}
|
|
1279
1282
|
}
|
|
1280
1283
|
if (typeof content === 'object' &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @nexus/baileys - Advanced Message Handler
|
|
3
|
-
*
|
|
3
|
+
* Built on WhiskeySockets/Baileys with Kelvdra's enhanced message types
|
|
4
4
|
*
|
|
5
5
|
* Supported message types:
|
|
6
6
|
* - PAYMENT (Request Payment)
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* - STATUS_MENTION (Status Mentions)
|
|
13
13
|
* - ORDER (Order Messages)
|
|
14
14
|
* - GROUP_STATUS (Group Stories)
|
|
15
|
-
* - CAROUSEL (Product Carousels)
|
|
15
|
+
* - CAROUSEL (Product/Image Carousels)
|
|
16
|
+
* - CAROUSEL_PROTO (Proto-based Carousels)
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
import axios from 'axios'
|
|
@@ -39,6 +40,7 @@ class NexusHandler {
|
|
|
39
40
|
if (content.orderMessage) return 'ORDER'
|
|
40
41
|
if (content.groupStatus) return 'GROUP_STATUS'
|
|
41
42
|
if (content.carouselMessage || content.carousel) return 'CAROUSEL'
|
|
43
|
+
if (content.carouselProto) return 'CAROUSEL_PROTO'
|
|
42
44
|
return null
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -559,16 +561,16 @@ class NexusHandler {
|
|
|
559
561
|
|
|
560
562
|
/**
|
|
561
563
|
* Handle Carousel Messages (Product/Image Carousels)
|
|
564
|
+
* Supports both wrapper format and native format
|
|
562
565
|
*/
|
|
563
566
|
async handleCarousel(content, jid, quoted) {
|
|
564
|
-
// Support carouselMessage (native) & carousel (wrapper)
|
|
565
567
|
const root = content.carouselMessage || content.carousel || {}
|
|
566
568
|
const { caption = '', footer = '', cards = [] } = root
|
|
567
569
|
|
|
568
570
|
const carouselCards = await Promise.all(
|
|
569
571
|
cards.map(async (card) => {
|
|
570
572
|
if (card.productTitle) {
|
|
571
|
-
// Mode
|
|
573
|
+
// Product Card Mode
|
|
572
574
|
return {
|
|
573
575
|
header: {
|
|
574
576
|
title: card.headerTitle || '',
|
|
@@ -608,7 +610,7 @@ class NexusHandler {
|
|
|
608
610
|
}
|
|
609
611
|
}
|
|
610
612
|
} else {
|
|
611
|
-
// Mode
|
|
613
|
+
// Image Card Mode
|
|
612
614
|
const imageMedia = card.imageUrl
|
|
613
615
|
? await this.utils.prepareWAMessageMedia(
|
|
614
616
|
{ image: { url: card.imageUrl } },
|
|
@@ -662,6 +664,76 @@ class NexusHandler {
|
|
|
662
664
|
await this.relayMessage(jid, msg.message, { messageId: msg.key.id })
|
|
663
665
|
return msg
|
|
664
666
|
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Handle Proto-based Carousel Messages
|
|
670
|
+
* For advanced carousel with proto definitions
|
|
671
|
+
*/
|
|
672
|
+
async handleCarouselProto(content, jid, quoted) {
|
|
673
|
+
const { body = '', footer = '', cards = [] } = content.carouselProto
|
|
674
|
+
|
|
675
|
+
const proto = this.utils.WAProto?.proto
|
|
676
|
+
if (!proto) {
|
|
677
|
+
throw new Error('WAProto not available for carousel generation')
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// Build carousel cards with proto
|
|
681
|
+
const carouselCards = await Promise.all(
|
|
682
|
+
cards.map(async (card) => {
|
|
683
|
+
const headerConfig = {
|
|
684
|
+
title: card.title?.substring(0, 60) || '',
|
|
685
|
+
subtitle: card.subtitle || '',
|
|
686
|
+
hasMediaAttachment: false
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
const buttons = (card.buttons || []).map((btn) => ({
|
|
690
|
+
name: btn.name,
|
|
691
|
+
buttonParamsJson: JSON.stringify(btn.params || {})
|
|
692
|
+
}))
|
|
693
|
+
|
|
694
|
+
return {
|
|
695
|
+
header: proto.Message.InteractiveMessage.Header.create(headerConfig),
|
|
696
|
+
body: proto.Message.InteractiveMessage.Body.create({
|
|
697
|
+
text: card.bodyText || ''
|
|
698
|
+
}),
|
|
699
|
+
footer: proto.Message.InteractiveMessage.Footer.create({
|
|
700
|
+
text: card.footerText || ''
|
|
701
|
+
}),
|
|
702
|
+
nativeFlowMessage: proto.Message.InteractiveMessage.NativeFlowMessage.create({
|
|
703
|
+
buttons
|
|
704
|
+
})
|
|
705
|
+
}
|
|
706
|
+
})
|
|
707
|
+
)
|
|
708
|
+
|
|
709
|
+
const carouselMessage = this.utils.generateWAMessageFromContent(jid, {
|
|
710
|
+
viewOnceMessage: {
|
|
711
|
+
message: {
|
|
712
|
+
messageContextInfo: {
|
|
713
|
+
deviceListMetadata: {},
|
|
714
|
+
deviceListMetadataVersion: 2
|
|
715
|
+
},
|
|
716
|
+
interactiveMessage: proto.Message.InteractiveMessage.create({
|
|
717
|
+
body: proto.Message.InteractiveMessage.Body.create({
|
|
718
|
+
text: body
|
|
719
|
+
}),
|
|
720
|
+
footer: proto.Message.InteractiveMessage.Footer.create({
|
|
721
|
+
text: footer
|
|
722
|
+
}),
|
|
723
|
+
carouselMessage: proto.Message.InteractiveMessage.CarouselMessage.create({
|
|
724
|
+
cards: carouselCards
|
|
725
|
+
})
|
|
726
|
+
})
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}, {})
|
|
730
|
+
|
|
731
|
+
await this.relayMessage(jid, carouselMessage.message, {
|
|
732
|
+
messageId: carouselMessage.key.id
|
|
733
|
+
})
|
|
734
|
+
|
|
735
|
+
return carouselMessage
|
|
736
|
+
}
|
|
665
737
|
}
|
|
666
738
|
|
|
667
|
-
export default NexusHandler
|
|
739
|
+
export default NexusHandler
|