innovators-bot2 2.0.5 → 2.0.6

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.
Files changed (5) hide show
  1. package/README.md +161 -10
  2. package/example.js +405 -202
  3. package/example.mp4 +0 -0
  4. package/index.js +176 -34
  5. package/package.json +3 -3
package/README.md CHANGED
@@ -66,6 +66,11 @@ const client = new WhatsAppClient({
66
66
  authmethod: authMethod
67
67
  });
68
68
 
69
+ // Handle pairing code event
70
+ client.on('pairing-code', (code) => {
71
+ console.log('Pairing Code:', code)
72
+ })
73
+
69
74
  // Handle ready event
70
75
  client.on('connected', () => {
71
76
  console.log('Client is ready!')
@@ -80,22 +85,45 @@ client.connect()
80
85
  ### 1. Basic Messaging
81
86
 
82
87
  ```javascript
88
+ // Determine the correct reply target (group JID for groups, sender JID for DMs)
89
+ const isGroupMsg = msg.isGroup;
90
+ const msgFrom = isGroupMsg ? msg.from : msg.sender;
91
+
83
92
  // Send a text message
84
- await client.sendMessage('1234567890@s.whatsapp.net', 'Hello world!')
93
+ await client.sendMessage(msgFrom, 'Hello world!')
85
94
 
86
95
  // Send a reply
87
- await client.reply('1234567890@s.whatsapp.net', 'This is a reply', {
88
- quoted: originalMessage
96
+ await msg.reply('This is a reply message')
97
+
98
+ // Mention a specific user
99
+ // Use msg.sender (the person's JID), NOT msg.from (which is the group JID in groups)
100
+ const number = msg.sender.split('@')[0]
101
+ await client.sendMessage(msgFrom, {
102
+ type: 'text',
103
+ text: `Hey @${number}! How are you?`,
104
+ mentions: [number]
89
105
  })
90
106
 
91
- // Send with mentions
92
- await client.sendMessage('1234567890@s.whatsapp.net', {
107
+ // Mention all members in a group (only works in groups)
108
+ await client.sendMessage(msgFrom, {
93
109
  type: 'text',
94
- text: 'Hey @user!',
95
- mentions: ['user@s.whatsapp.net']
110
+ text: 'Hey @all! How are you?',
111
+ mentions: ['@all']
112
+ })
113
+
114
+ // You can also use the explicit mentionAll flag
115
+ await client.sendMessage(msgFrom, {
116
+ type: 'text',
117
+ text: 'Attention everyone!',
118
+ mentionAll: true
96
119
  })
97
120
  ```
98
121
 
122
+ > **Note on `msg.from` vs `msg.sender`:**
123
+ > - `msg.from` — The chat JID. For groups this is the group ID (e.g. `120363...@g.us`), for DMs it's the person's JID.
124
+ > - `msg.sender` — The actual person who sent the message (always a user JID like `923001234567@s.whatsapp.net`).
125
+ > - When mentioning a user, always use `msg.sender` (not `msg.from`) to get the correct user JID.
126
+
99
127
  ### Call Methods
100
128
 
101
129
  ```javascript
@@ -409,6 +437,56 @@ await client.SendList('1234567890@s.whatsapp.net', {
409
437
  });
410
438
  ```
411
439
 
440
+ #### Cards Messages
441
+ ```javascript
442
+ // Send interactive cards
443
+ await client.sendcards('1234567890@s.whatsapp.net', {
444
+ text: 'Body Message',
445
+ title: 'Title Message',
446
+ subtile: 'Subtitle Message',
447
+ footer: 'Footer Message',
448
+ cards: [
449
+ {
450
+ image: { url: 'https://example.com/image1.jpg' }, // or buffer
451
+ title: 'Title Card 1',
452
+ body: 'Body Card 1',
453
+ footer: 'Footer Card 1',
454
+ buttons: [
455
+ {
456
+ name: 'quick_reply',
457
+ buttonParamsJson: JSON.stringify({
458
+ display_text: 'Button 1',
459
+ id: 'id1'
460
+ })
461
+ },
462
+ {
463
+ name: 'cta_url',
464
+ buttonParamsJson: JSON.stringify({
465
+ display_text: 'Open Link',
466
+ url: 'https://www.example.com'
467
+ })
468
+ }
469
+ ]
470
+ },
471
+ {
472
+ video: { url: 'https://example.com/video1.mp4' }, // or buffer
473
+ title: 'Title Card 2',
474
+ body: 'Body Card 2',
475
+ footer: 'Footer Card 2',
476
+ buttons: [
477
+ {
478
+ name: 'quick_reply',
479
+ buttonParamsJson: JSON.stringify({
480
+ display_text: 'Button 2',
481
+ id: 'id2'
482
+ })
483
+ }
484
+ ]
485
+ }
486
+ ]
487
+ });
488
+ ```
489
+
412
490
  #### Interactive Messages (V2)
413
491
 
414
492
  Modern interactive message generation with simplified API.
@@ -553,8 +631,64 @@ client.on('store-loaded', (info) => {
553
631
  console.log(`Loaded ${info.messageCount} messages from file`);
554
632
  });
555
633
  ```
634
+
635
+ ### 10. Status / Story Posting
636
+
637
+ Post text, image, video, and voice note statuses easily using the `sendStatus` method.
638
+
639
+ | Feature | Description |
640
+ |---------|-------------|
641
+ | **Multi-Device Support** | Automatically handles `statusJidList` for correct visibility |
642
+ | **All Media Types** | Supports Text, Image, Video, GIF, and Voice Note statuses |
643
+ | **Rich Customization** | Supports backgrounds, fonts, and colors for text status |
644
+
645
+ #### Sending Text Status
646
+ ```javascript
647
+ await client.sendStatus({
648
+ text: 'Hello from Innovators Soft! 🌍',
649
+ backgroundColor: '#34B7F1', // Hex color
650
+ font: 2, // Norican font (0-9)
651
+ textColor: '#FFFFFF'
652
+ }, ['1234567890@s.whatsapp.net']);
556
653
  ```
557
654
 
655
+ #### Sending Media Status
656
+ ```javascript
657
+ // Image Status
658
+ await client.sendStatus({
659
+ imagePath: './photo.jpg',
660
+ caption: 'Beautiful day! ☀️'
661
+ }, ['1234567890@s.whatsapp.net']);
662
+
663
+ // Video/GIF Status
664
+ await client.sendStatus({
665
+ videoPath: './video.mp4',
666
+ caption: 'Check this out! 🎬',
667
+ isGif: true
668
+ }, ['1234567890@s.whatsapp.net']);
669
+
670
+ // Voice Note Status
671
+ await client.sendStatus({
672
+ audioPath: './voice.ogg'
673
+ }, ['1234567890@s.whatsapp.net']);
674
+ ```
675
+
676
+ #### Status Visibility
677
+ > [!IMPORTANT]
678
+ > The second parameter of `sendStatus` is an array of JIDs (contacts) who should be able to see this status. On Multi-Device WhatsApp, statuses are NOT visible to anyone unless you explicitly include them in this list.
679
+
680
+ #### Helper Utilities
681
+ You can also access the underlying `StatusHelper` directly:
682
+ ```javascript
683
+ const { StatusHelper, STATUS_BACKGROUNDS, STATUS_FONTS } = require('@innovatorssoft/baileys');
684
+
685
+ // Generate raw status content
686
+ const status = StatusHelper.text('Direct usage', STATUS_BACKGROUNDS.solid.purple);
687
+ await StatusHelper.send(client.sock, status, ['1234567890@s.whatsapp.net']);
688
+ ```
689
+
690
+ ---
691
+
558
692
  ## More Examples and Information
559
693
 
560
694
  For a complete working example with message handling, group management, and error handling, check out our [`example.js`](https://github.com/innovatorssoft/innovators-bot2/blob/main/example.js) file. This example includes:
@@ -577,7 +711,8 @@ The library includes example bot commands that you can use:
577
711
  - `!help` - Show all available commands
578
712
 
579
713
  ### Messaging
580
- - `!mention` - Mention you in a message
714
+ - `!mention` - Mention the sender in a message
715
+ - `!mentionall` - Mention all group members (groups only)
581
716
  - `!reply` - Reply to your message
582
717
  - `!react` - React to your message with ❤️
583
718
  - `!read` - Mark messages as read
@@ -633,6 +768,12 @@ The library includes example bot commands that you can use:
633
768
  ### Interactive Messages
634
769
  - `!buttons` - Show interactive buttons
635
770
  - `!list` - Display a scrollable list
771
+ - `!quickreplyv2` - Quick reply buttons V2
772
+ - `!urlbuttonv2` - URL button V2
773
+ - `!copycodev2` - Copy code button V2
774
+ - `!combinedv2` - Mixed buttons V2
775
+ - `!listv2` - Interactive list V2
776
+ - `!cards` - Show interactive cards message
636
777
  - `!logout` - Logout from current session
637
778
 
638
779
  ### 💾 Message Store
@@ -694,12 +835,22 @@ client.on('contacts-update', (updates) => {
694
835
  ```javascript
695
836
  // When a new message is received
696
837
  client.on('message', async msg => {
697
- console.log('Message from:', msg.from)
698
- console.log('Message content:', msg.body)
838
+ console.log('Message from:', msg.from) // Chat JID (group or DM)
839
+ console.log('Sender:', msg.sender) // Person who sent it
840
+ console.log('Sender Name:', msg.raw.pushName) // Display name
841
+ console.log('Message:', msg.body)
842
+ console.log('Is Group:', msg.isGroup)
843
+
844
+ // Determine reply target: group JID for groups, sender JID for DMs
845
+ const isGroupMsg = msg.isGroup;
846
+ const msgFrom = isGroupMsg ? msg.from : msg.sender;
699
847
 
700
848
  // Mark message as read
701
849
  await client.readMessage(msg.raw.key)
702
850
 
851
+ // Reply back
852
+ await msg.reply('Got your message!')
853
+
703
854
  // Handle different message types
704
855
  if (msg.hasMedia) {
705
856
  console.log('Message contains media')