@crysnovax/baileys 2.6.6 → 2.6.7
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/README.md +100 -82
- package/lib/Socket/groups.js +7 -1
- package/lib/Socket/groups.js[old] +347 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://readme-typing-svg.demolab.com?font=Fira+Code&weight=700&size=32&duration=3000&pause=800&color=10B981¢er=true&vCenter=true&width=650&lines=%F0%9F%9A%80+%40crysnovax%
|
|
2
|
+
<img src="https://readme-typing-svg.demolab.com?font=Fira+Code&weight=700&size=32&duration=3000&pause=800&color=10B981¢er=true&vCenter=true&width=650&lines=%F0%9F%9A%80+%40crysnovax%2Fbaileys%3B+WhatsApp+API+for+Node.js%3B+Rich+Messages+%7C+Meta+AI+Style%3B+Production+Ready+%E2%9C%85" alt="Typing Animation" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<img src="https://img.shields.io/npm/v/@crysnovax/
|
|
6
|
+
<img src="https://img.shields.io/npm/v/@crysnovax/baileys?style=for-the-badge&logo=npm&color=10b981&labelColor=0a0f0a" />
|
|
7
7
|
<img src="https://img.shields.io/github/stars/crysnovax/baileys?style=for-the-badge&logo=github&color=10b981&labelColor=0a0f0a" />
|
|
8
8
|
<img src="https://img.shields.io/badge/License-MIT-10b981?style=for-the-badge&labelColor=0a0f0a" />
|
|
9
9
|
<img src="https://img.shields.io/badge/Node.js-%3E%3D18-10b981?style=for-the-badge&logo=node.js&labelColor=0a0f0a" />
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
|
|
51
51
|
## Overview
|
|
52
52
|
|
|
53
|
-
`@crysnovax/
|
|
53
|
+
`@crysnovax/baileys` is a powerful, production-ready WhatsApp API wrapper for Node.js, built on top of the Baileys protocol. It extends the core with rich messaging capabilities, Meta AI-style compositing, and a streamlined developer experience.
|
|
54
54
|
|
|
55
55
|
### What Sets It Apart
|
|
56
56
|
|
|
@@ -62,6 +62,9 @@
|
|
|
62
62
|
| Status Posting | ✅ | Text with colors/fonts, image, video, audio, mentions |
|
|
63
63
|
| Favorites Management | ✅ | Add/remove JIDs with local persistence |
|
|
64
64
|
| HD Profile Picture | ✅ | Full-size upload with no crop or resize via `{ hd: true }` (max 720px) |
|
|
65
|
+
| Rich Preview | 🆕 | Auto-fetch link preview (title, description, image) for any URL via `{ richPreview: true }` |
|
|
66
|
+
| Verified Badge | 🆕 | Image/video forward badge via `{ verifiedMe: true }` |
|
|
67
|
+
| Like This | 🆕 | Raw relay bypassing all processing via `{ likeThis: true }` |
|
|
65
68
|
| LID/PN Resolution | ✅ | Cross-resolve LID and phone number JIDs |
|
|
66
69
|
| Member Labels | ✅ | Group participant labels |
|
|
67
70
|
| No Obfuscation | ✅ | Fully readable, auditable source code |
|
|
@@ -76,7 +79,7 @@
|
|
|
76
79
|
|
|
77
80
|
```bash
|
|
78
81
|
# NPM
|
|
79
|
-
npm install @crysnovax/
|
|
82
|
+
npm install @crysnovax/baileys
|
|
80
83
|
|
|
81
84
|
# GitHub
|
|
82
85
|
npm install github:crysnovax/baileys
|
|
@@ -86,10 +89,10 @@ npm install github:crysnovax/baileys
|
|
|
86
89
|
|
|
87
90
|
```javascript
|
|
88
91
|
// ESM
|
|
89
|
-
import { makeWASocket } from '@crysnovax/
|
|
92
|
+
import { makeWASocket } from '@crysnovax/baileys'
|
|
90
93
|
|
|
91
94
|
// CJS (Node.js 24+)
|
|
92
|
-
const { makeWASocket } = require('@crysnovax/
|
|
95
|
+
const { makeWASocket } = require('@crysnovax/baileys')
|
|
93
96
|
```
|
|
94
97
|
|
|
95
98
|
---
|
|
@@ -97,7 +100,7 @@ const { makeWASocket } = require('@crysnovax/bailey')
|
|
|
97
100
|
## Quick Start
|
|
98
101
|
|
|
99
102
|
```javascript
|
|
100
|
-
import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@crysnovax/
|
|
103
|
+
import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@crysnovax/baileys'
|
|
101
104
|
import { Boom } from '@hapi/boom'
|
|
102
105
|
import pino from 'pino'
|
|
103
106
|
|
|
@@ -150,7 +153,7 @@ connectToWhatsApp()
|
|
|
150
153
|
### Multi-File Auth State (Recommended)
|
|
151
154
|
|
|
152
155
|
```javascript
|
|
153
|
-
import { useMultiFileAuthState } from '@crysnovax/
|
|
156
|
+
import { useMultiFileAuthState } from '@crysnovax/baileys'
|
|
154
157
|
|
|
155
158
|
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
156
159
|
```
|
|
@@ -158,7 +161,7 @@ const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
|
158
161
|
### Single-File Auth State (Experimental)
|
|
159
162
|
|
|
160
163
|
```javascript
|
|
161
|
-
import { useSingleFileAuthState } from '@crysnovax/
|
|
164
|
+
import { useSingleFileAuthState } from '@crysnovax/baileys'
|
|
162
165
|
|
|
163
166
|
const { state, saveCreds } = await useSingleFileAuthState('session.json')
|
|
164
167
|
// Already includes internal caching — no need for makeCacheableSignalKeyStore
|
|
@@ -167,7 +170,7 @@ const { state, saveCreds } = await useSingleFileAuthState('session.json')
|
|
|
167
170
|
### SQLite Auth State (Experimental)
|
|
168
171
|
|
|
169
172
|
```javascript
|
|
170
|
-
import { useSqliteAuthState } from '@crysnovax/
|
|
173
|
+
import { useSqliteAuthState } from '@crysnovax/baileys'
|
|
171
174
|
|
|
172
175
|
const { state, saveCreds } = await useSqliteAuthState('session.db')
|
|
173
176
|
```
|
|
@@ -193,12 +196,12 @@ console.log('Pairing code:', customCode)
|
|
|
193
196
|
sock.sendMessage(jid, { text: 'Hello!' }, { quoted: message })
|
|
194
197
|
|
|
195
198
|
// With link preview
|
|
196
|
-
const url = 'https://www.npmjs.com/package/@crysnovax/
|
|
199
|
+
const url = 'https://www.npmjs.com/package/@crysnovax/baileys'
|
|
197
200
|
sock.sendMessage(jid, {
|
|
198
201
|
text: url + ' Check it out!',
|
|
199
202
|
linkPreview: {
|
|
200
203
|
'matched-text': url,
|
|
201
|
-
title: '@crysnovax/
|
|
204
|
+
title: '@crysnovax/baileys',
|
|
202
205
|
description: 'WhatsApp API for Node.js',
|
|
203
206
|
previewType: 0,
|
|
204
207
|
jpegThumbnail: fs.readFileSync('./thumb.jpg')
|
|
@@ -206,7 +209,7 @@ sock.sendMessage(jid, {
|
|
|
206
209
|
})
|
|
207
210
|
|
|
208
211
|
// Large link preview with favicon
|
|
209
|
-
import { prepareWAMessageMedia } from '@crysnovax/
|
|
212
|
+
import { prepareWAMessageMedia } from '@crysnovax/baileys'
|
|
210
213
|
|
|
211
214
|
const { imageMessage: image } = await prepareWAMessageMedia(
|
|
212
215
|
{ image: { url: './thumb.jpg' } },
|
|
@@ -220,7 +223,7 @@ sock.sendMessage(jid, {
|
|
|
220
223
|
text: url + ' Check it out!',
|
|
221
224
|
linkPreview: {
|
|
222
225
|
'matched-text': url,
|
|
223
|
-
title: '@crysnovax/
|
|
226
|
+
title: '@crysnovax/baileys',
|
|
224
227
|
description: 'WhatsApp API for Node.js',
|
|
225
228
|
previewType: 0,
|
|
226
229
|
jpegThumbnail: fs.readFileSync('./thumb.jpg'),
|
|
@@ -466,7 +469,7 @@ sock.sendMessage(jid, {
|
|
|
466
469
|
],
|
|
467
470
|
name: 'My Sticker Pack',
|
|
468
471
|
publisher: 'CRYSNOVA',
|
|
469
|
-
description: '@crysnovax/
|
|
472
|
+
description: '@crysnovax/baileys'
|
|
470
473
|
})
|
|
471
474
|
```
|
|
472
475
|
|
|
@@ -480,7 +483,7 @@ sock.sendMessage(jid, {
|
|
|
480
483
|
// Buttons
|
|
481
484
|
sock.sendMessage(jid, {
|
|
482
485
|
text: 'Choose an option!',
|
|
483
|
-
footer: '@crysnovax/
|
|
486
|
+
footer: '@crysnovax/baileys',
|
|
484
487
|
buttons: [
|
|
485
488
|
{ text: 'Sign Up', id: '#SignUp' }
|
|
486
489
|
]
|
|
@@ -490,7 +493,7 @@ sock.sendMessage(jid, {
|
|
|
490
493
|
sock.sendMessage(jid, {
|
|
491
494
|
image: { url: './image.jpg' },
|
|
492
495
|
caption: 'Interactive buttons!',
|
|
493
|
-
footer: '@crysnovax/
|
|
496
|
+
footer: '@crysnovax/baileys',
|
|
494
497
|
buttons: [
|
|
495
498
|
{ text: 'Rating', id: '#Rating' },
|
|
496
499
|
{
|
|
@@ -517,7 +520,7 @@ sock.sendMessage(jid, {
|
|
|
517
520
|
// List (private chat only)
|
|
518
521
|
sock.sendMessage(jid, {
|
|
519
522
|
text: 'List menu!',
|
|
520
|
-
footer: '@crysnovax/
|
|
523
|
+
footer: '@crysnovax/baileys',
|
|
521
524
|
buttonText: 'Select',
|
|
522
525
|
title: 'Hello',
|
|
523
526
|
sections: [
|
|
@@ -544,7 +547,7 @@ sock.sendMessage(jid, {
|
|
|
544
547
|
sock.sendMessage(jid, {
|
|
545
548
|
image: { url: './image.jpg' },
|
|
546
549
|
caption: 'Interactive!',
|
|
547
|
-
footer: '@crysnovax/
|
|
550
|
+
footer: '@crysnovax/baileys',
|
|
548
551
|
optionText: 'Select Options',
|
|
549
552
|
optionTitle: 'Select Options',
|
|
550
553
|
offerText: 'New Coupon!',
|
|
@@ -554,7 +557,7 @@ sock.sendMessage(jid, {
|
|
|
554
557
|
nativeFlow: [
|
|
555
558
|
{ text: 'Greeting', id: '#Greeting', icon: 'review' },
|
|
556
559
|
{ text: 'Call', call: '628123456789' },
|
|
557
|
-
{ text: 'Copy', copy: '@crysnovax/
|
|
560
|
+
{ text: 'Copy', copy: '@crysnovax/baileys' },
|
|
558
561
|
{ text: 'Source', url: 'https://example.com', useWebview: true },
|
|
559
562
|
{
|
|
560
563
|
text: 'Select',
|
|
@@ -575,7 +578,7 @@ sock.sendMessage(jid, {
|
|
|
575
578
|
// Carousel with cards
|
|
576
579
|
sock.sendMessage(jid, {
|
|
577
580
|
text: 'Carousel!',
|
|
578
|
-
footer: '@crysnovax/
|
|
581
|
+
footer: '@crysnovax/baileys',
|
|
579
582
|
cards: [
|
|
580
583
|
{
|
|
581
584
|
image: { url: './img1.jpg' },
|
|
@@ -618,7 +621,7 @@ sock.sendMessage(jid, {
|
|
|
618
621
|
title: 'Hello',
|
|
619
622
|
image: { url: './image.jpg' },
|
|
620
623
|
caption: 'Template!',
|
|
621
|
-
footer: '@crysnovax/
|
|
624
|
+
footer: '@crysnovax/baileys',
|
|
622
625
|
templateButtons: [
|
|
623
626
|
{ text: 'Tap Here', id: '#Order' },
|
|
624
627
|
{ text: 'Source', url: 'https://example.com' },
|
|
@@ -647,7 +650,7 @@ sock.sendMessage(jid, {
|
|
|
647
650
|
// Supported languages: css, html, javascript, typescript, python, golang, rust, c, c#, c++, bash, bat, powershell
|
|
648
651
|
|
|
649
652
|
// Manual tokenization
|
|
650
|
-
import { tokenizeCode } from '@crysnovax/
|
|
653
|
+
import { tokenizeCode } from '@crysnovax/baileys'
|
|
651
654
|
|
|
652
655
|
const language = 'javascript'
|
|
653
656
|
const code = 'console.log("Hello, World!")'
|
|
@@ -721,8 +724,23 @@ sock.sendMessage(jid, {
|
|
|
721
724
|
]
|
|
722
725
|
})
|
|
723
726
|
```
|
|
724
|
-
### Rich
|
|
725
|
-
|
|
727
|
+
### Rich Preview 🆕
|
|
728
|
+
Send any link with a large, reliable preview card — auto-fetches title, description and thumbnail from the URL. Works on any domain including Facebook, YouTube, and more. For `chat.whatsapp.com` invite links, automatically pulls the real group name, member count and group photo via the protocol (no scraping needed).
|
|
729
|
+
|
|
730
|
+
```javascript
|
|
731
|
+
// Fully automatic — fetches everything from the URL
|
|
732
|
+
await sock.sendMessage(jid, {
|
|
733
|
+
text: 'https://facebook.com/share/v/14i...',
|
|
734
|
+
richPreview: true
|
|
735
|
+
})
|
|
736
|
+
|
|
737
|
+
// WhatsApp group invite — auto-fetches group name, member count, photo
|
|
738
|
+
await sock.sendMessage(jid, {
|
|
739
|
+
text: 'https://chat.whatsapp.com/CODE',
|
|
740
|
+
richPreview: true
|
|
741
|
+
})
|
|
742
|
+
|
|
743
|
+
// Custom title + description (overrides auto-fetch)
|
|
726
744
|
await sock.sendMessage(jid, {
|
|
727
745
|
text: 'https://chat.whatsapp.com/CODE',
|
|
728
746
|
richPreview: true,
|
|
@@ -730,54 +748,33 @@ await sock.sendMessage(jid, {
|
|
|
730
748
|
previewDescription: '42 members · Tap to join',
|
|
731
749
|
previewImage: imageBufferOrUrl // Buffer, or a URL string
|
|
732
750
|
})
|
|
733
|
-
```
|
|
734
751
|
|
|
735
|
-
|
|
736
|
-
```
|
|
737
|
-
// Fully auto — fetches title, description, image from the URL
|
|
738
|
-
await sock.sendMessage(jid, {
|
|
739
|
-
text: 'https://facebook.com/share/v/14i...',
|
|
740
|
-
richPreview: true
|
|
741
|
-
})
|
|
742
|
-
|
|
743
|
-
// Group status with auto-fetched preview
|
|
752
|
+
// Rich preview inside a group status post
|
|
744
753
|
await sock.sendMessage(jid, {
|
|
745
754
|
text: 'https://chat.whatsapp.com/CODE',
|
|
746
755
|
richPreview: true,
|
|
747
756
|
groupStatus: true
|
|
748
757
|
})
|
|
749
758
|
```
|
|
750
|
-
### SEND MESSAGES EXACTLY AS IS NO PROCESSING
|
|
751
|
-
```
|
|
752
|
-
// Relay a received message exactly as-is
|
|
753
|
-
await sock.sendMessage(jid, {
|
|
754
|
-
likeThis: true,
|
|
755
|
-
...m.message // spread the captured message directly
|
|
756
|
-
})
|
|
757
759
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
likeThis: true,
|
|
761
|
-
imageMessage: { ...rawFields }
|
|
762
|
-
})
|
|
760
|
+
### WhatsApp Verified Badge ☑️ 🆕
|
|
761
|
+
Send image or video messages with a verified forward badge (✔️). Only applies to `image` and `video` — silently ignored on other types.
|
|
763
762
|
|
|
764
|
-
|
|
763
|
+
```javascript
|
|
764
|
+
// Image with verified badge
|
|
765
765
|
await sock.sendMessage(jid, {
|
|
766
|
-
|
|
767
|
-
|
|
766
|
+
image: buffer,
|
|
767
|
+
caption: 'Hello',
|
|
768
|
+
verifiedMe: true
|
|
768
769
|
})
|
|
769
|
-
```
|
|
770
770
|
|
|
771
|
-
|
|
772
|
-
send Media messages with verified WhatsApp check ✔️
|
|
773
|
-
```
|
|
771
|
+
// Video with verified badge
|
|
774
772
|
await sock.sendMessage(jid, {
|
|
775
|
-
|
|
773
|
+
video: buffer,
|
|
776
774
|
caption: 'Hello',
|
|
777
775
|
verifiedMe: true
|
|
778
776
|
})
|
|
779
777
|
```
|
|
780
|
-
|
|
781
778
|
---
|
|
782
779
|
|
|
783
780
|
## Meta AI Features
|
|
@@ -791,7 +788,7 @@ Meta AI-style thinking indicators and live reasoning feeds. Works on **all Whats
|
|
|
791
788
|
Show a live thinking indicator that you control. Delete it manually when ready — no "edited" badge ever appears.
|
|
792
789
|
|
|
793
790
|
```javascript
|
|
794
|
-
import { metaTyping, buildSteps, PlanningStepStatus } from '@crysnovax/
|
|
791
|
+
import { metaTyping, buildSteps, PlanningStepStatus } from '@crysnovax/baileys'
|
|
795
792
|
|
|
796
793
|
const placeholder = await metaTyping(sock, jid, {
|
|
797
794
|
description: 'Thinking…',
|
|
@@ -825,7 +822,7 @@ Here is your answer!
|
|
|
825
822
|
Full flow: indicator shows → auto-deletes → clean final message lands. Works with every rich content type.
|
|
826
823
|
|
|
827
824
|
```javascript
|
|
828
|
-
import { sendMetaComposited, PlanningStepStatus } from '@crysnovax/
|
|
825
|
+
import { sendMetaComposited, PlanningStepStatus } from '@crysnovax/baileys'
|
|
829
826
|
|
|
830
827
|
// With code block
|
|
831
828
|
await sendMetaComposited(
|
|
@@ -874,7 +871,7 @@ await sendMetaComposited(
|
|
|
874
871
|
Live Meta AI-style reasoning feed — each step visibly completes in real time, then the final rich message lands clean.
|
|
875
872
|
|
|
876
873
|
```javascript
|
|
877
|
-
import { replayPlanning, mixedSteps } from '@crysnovax/
|
|
874
|
+
import { replayPlanning, mixedSteps } from '@crysnovax/baileys'
|
|
878
875
|
|
|
879
876
|
await replayPlanning(
|
|
880
877
|
sock, jid,
|
|
@@ -930,7 +927,7 @@ import {
|
|
|
930
927
|
buildSearchSteps, // isEnhancedSearch: true
|
|
931
928
|
mixedSteps, // mix any combination
|
|
932
929
|
buildSteps // plain steps
|
|
933
|
-
} from '@crysnovax/
|
|
930
|
+
} from '@crysnovax/baileys'
|
|
934
931
|
|
|
935
932
|
// All reasoning
|
|
936
933
|
buildReasoningSteps(['Analyzing the problem…', 'Checking edge cases…'])
|
|
@@ -949,7 +946,7 @@ mixedSteps([
|
|
|
949
946
|
**Replay planning only (no final message):**
|
|
950
947
|
|
|
951
948
|
```javascript
|
|
952
|
-
import { replayPlanningOnly, buildSearchSteps } from '@crysnovax/
|
|
949
|
+
import { replayPlanningOnly, buildSearchSteps } from '@crysnovax/baileys'
|
|
953
950
|
|
|
954
951
|
await replayPlanningOnly(
|
|
955
952
|
sock, jid,
|
|
@@ -981,7 +978,7 @@ Auto-greet new contacts with an interactive FAQ menu. Fires once per contact, ne
|
|
|
981
978
|
### Basic Setup
|
|
982
979
|
|
|
983
980
|
```javascript
|
|
984
|
-
import { createWelcomeFlow } from '@crysnovax/
|
|
981
|
+
import { createWelcomeFlow } from '@crysnovax/baileys'
|
|
985
982
|
|
|
986
983
|
const welcome = createWelcomeFlow(sock, {
|
|
987
984
|
greeting: 'Welcome! How can I help you today?',
|
|
@@ -1057,7 +1054,7 @@ welcome.hasGreeted(jid) // check if greeted → boolean
|
|
|
1057
1054
|
| Option | Type | Default | Description |
|
|
1058
1055
|
|--------|------|---------|-------------|
|
|
1059
1056
|
| `greeting` | `string` | `'Welcome!…'` | Body text of welcome message |
|
|
1060
|
-
| `footer` | `string` | `'Powered by @crysnovax/
|
|
1057
|
+
| `footer` | `string` | `'Powered by @crysnovax/baileys'` | Footer text |
|
|
1061
1058
|
| `buttonText` | `string` | `'Choose an option'` | List button label |
|
|
1062
1059
|
| `sectionTitle` | `string` | `'How can we help?'` | Section header |
|
|
1063
1060
|
| `faqs` | `Array` | 4 defaults | `{ id, title, description }` |
|
|
@@ -1135,6 +1132,12 @@ sock.sendMessage(jid, {
|
|
|
1135
1132
|
caption: 'Group Status!',
|
|
1136
1133
|
groupStatus: true
|
|
1137
1134
|
})
|
|
1135
|
+
// Delete a specific group status
|
|
1136
|
+
await sock.deleteGroupStatus(jid, message.key)
|
|
1137
|
+
|
|
1138
|
+
// Example — delete on command
|
|
1139
|
+
const key = m.quoted?.key
|
|
1140
|
+
if (key) await sock.deleteGroupStatus(m.chat, key)()
|
|
1138
1141
|
|
|
1139
1142
|
// Lottie sticker
|
|
1140
1143
|
sock.sendMessage(jid, {
|
|
@@ -1142,21 +1145,36 @@ sock.sendMessage(jid, {
|
|
|
1142
1145
|
isLottie: true
|
|
1143
1146
|
})
|
|
1144
1147
|
|
|
1145
|
-
//
|
|
1148
|
+
// likeThis — relay message exactly as-is, zero processing 🆕
|
|
1149
|
+
// Bypasses generateWAMessage entirely — no re-encoding, no normalization.
|
|
1150
|
+
// Useful for: forwarding with original quality, relaying captured messages verbatim,
|
|
1151
|
+
// re-sending albums/carousels without re-uploading, testing raw proto constructions.
|
|
1152
|
+
sock.sendMessage(jid, {
|
|
1153
|
+
likeThis: true,
|
|
1154
|
+
...capturedMessage.message // spread any received message directly
|
|
1155
|
+
})
|
|
1156
|
+
|
|
1157
|
+
// Or with a manually built proto
|
|
1158
|
+
sock.sendMessage(jid, {
|
|
1159
|
+
likeThis: true,
|
|
1160
|
+
imageMessage: { ...rawProtoFields }
|
|
1161
|
+
})
|
|
1162
|
+
|
|
1163
|
+
// Or forwarding with original quality intact
|
|
1146
1164
|
sock.sendMessage(jid, {
|
|
1165
|
+
likeThis: true,
|
|
1147
1166
|
extendedTextMessage: {
|
|
1148
1167
|
text: 'Built manually',
|
|
1149
1168
|
contextInfo: {
|
|
1150
1169
|
externalAdReply: {
|
|
1151
|
-
title: '@crysnovax/
|
|
1170
|
+
title: '@crysnovax/baileyss',
|
|
1152
1171
|
thumbnail: fs.readFileSync('./image.jpg'),
|
|
1153
1172
|
sourceApp: 'whatsapp',
|
|
1154
1173
|
showAdAttribution: true,
|
|
1155
1174
|
mediaType: 1
|
|
1156
1175
|
}
|
|
1157
1176
|
}
|
|
1158
|
-
}
|
|
1159
|
-
raw: true
|
|
1177
|
+
}
|
|
1160
1178
|
})
|
|
1161
1179
|
|
|
1162
1180
|
// Secure meta service label
|
|
@@ -1199,7 +1217,7 @@ sock.sendMessage(jid, {
|
|
|
1199
1217
|
## Status & Stories
|
|
1200
1218
|
|
|
1201
1219
|
Post WhatsApp status updates with text, media, and targeted mentions.
|
|
1202
|
-
|
|
1220
|
+
[still under construction 🏗️ if you face any issues]
|
|
1203
1221
|
### Text Status
|
|
1204
1222
|
|
|
1205
1223
|
```javascript
|
|
@@ -1355,7 +1373,7 @@ saveFavs(remaining)
|
|
|
1355
1373
|
|
|
1356
1374
|
```javascript
|
|
1357
1375
|
// Create
|
|
1358
|
-
sock.newsletterCreate('@crysnovax/
|
|
1376
|
+
sock.newsletterCreate('@crysnovax/baileys', 'Fresh updates weekly')
|
|
1359
1377
|
|
|
1360
1378
|
// Metadata
|
|
1361
1379
|
const metadata = await sock.newsletterMetadata('1231111111111@newsletter')
|
|
@@ -1376,8 +1394,8 @@ sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net'
|
|
|
1376
1394
|
sock.newsletterChangeOwner('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
1377
1395
|
|
|
1378
1396
|
// Update
|
|
1379
|
-
sock.newsletterUpdate('1231111111111@newsletter', { name: '@crysnovax/
|
|
1380
|
-
sock.newsletterUpdateName('1231111111111@newsletter', '@crysnovax/
|
|
1397
|
+
sock.newsletterUpdate('1231111111111@newsletter', { name: '@crysnovax/baileys' })
|
|
1398
|
+
sock.newsletterUpdateName('1231111111111@newsletter', '@crysnovax/baileys')
|
|
1381
1399
|
sock.newsletterUpdateDescription('1231111111111@newsletter', 'Fresh updates weekly')
|
|
1382
1400
|
sock.newsletterUpdatePicture('1231111111111@newsletter', { url: 'path/to/image.jpg' })
|
|
1383
1401
|
sock.newsletterRemovePicture('1231111111111@newsletter')
|
|
@@ -1404,7 +1422,7 @@ sock.newsletterDelete('1231111111111@newsletter')
|
|
|
1404
1422
|
|
|
1405
1423
|
```javascript
|
|
1406
1424
|
// Create
|
|
1407
|
-
const group = await sock.groupCreate('@crysnovax/
|
|
1425
|
+
const group = await sock.groupCreate('@crysnovax/baileys', ['628123456789@s.whatsapp.net'])
|
|
1408
1426
|
|
|
1409
1427
|
// Metadata
|
|
1410
1428
|
const metadata = await sock.groupMetadata(jid)
|
|
@@ -1427,7 +1445,7 @@ sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'demote')
|
|
|
1427
1445
|
sock.groupRequestParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'approve')
|
|
1428
1446
|
|
|
1429
1447
|
// Info updates
|
|
1430
|
-
sock.groupUpdateSubject(jid, '@crysnovax/
|
|
1448
|
+
sock.groupUpdateSubject(jid, '@crysnovax/baileys')
|
|
1431
1449
|
sock.groupUpdateDescription(jid, 'Updated description')
|
|
1432
1450
|
sock.updateProfilePicture(jid, { url: 'path/to/image.jpg' })
|
|
1433
1451
|
sock.removeProfilePicture(jid)
|
|
@@ -1460,7 +1478,7 @@ const requests = await sock.groupRequestParticipantsList(jid)
|
|
|
1460
1478
|
const group = await sock.groupGetInviteInfo('ABC123456789')
|
|
1461
1479
|
|
|
1462
1480
|
// Member label
|
|
1463
|
-
sock.updateMemberLabel(jid, '@crysnovax/
|
|
1481
|
+
sock.updateMemberLabel(jid, '@crysnovax/baileys')
|
|
1464
1482
|
```
|
|
1465
1483
|
|
|
1466
1484
|
---
|
|
@@ -1469,7 +1487,7 @@ sock.updateMemberLabel(jid, '@crysnovax/bailey')
|
|
|
1469
1487
|
|
|
1470
1488
|
```javascript
|
|
1471
1489
|
// Create
|
|
1472
|
-
const community = await sock.communityCreate('@crysnovax/
|
|
1490
|
+
const community = await sock.communityCreate('@crysnovax/baileys', 'Fresh updates weekly')
|
|
1473
1491
|
|
|
1474
1492
|
// Create subgroup
|
|
1475
1493
|
const group = await sock.communityCreateGroup(
|
|
@@ -1497,7 +1515,7 @@ sock.communityLeave(jid)
|
|
|
1497
1515
|
sock.communityRequestParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'approve')
|
|
1498
1516
|
|
|
1499
1517
|
// Updates
|
|
1500
|
-
sock.communityUpdateSubject(jid, '@crysnovax/
|
|
1518
|
+
sock.communityUpdateSubject(jid, '@crysnovax/baileys')
|
|
1501
1519
|
sock.communityUpdateDescription(jid, 'Updated description')
|
|
1502
1520
|
|
|
1503
1521
|
// Settings
|
|
@@ -1832,7 +1850,7 @@ sock.ev.on('settings.update', (update) => {})
|
|
|
1832
1850
|
Auto-detects available libraries: `sharp`, `@napi-rs/image`, or `jimp`.
|
|
1833
1851
|
|
|
1834
1852
|
```javascript
|
|
1835
|
-
import { getImageProcessingLibrary } from '@crysnovax/
|
|
1853
|
+
import { getImageProcessingLibrary } from '@crysnovax/baileyss'
|
|
1836
1854
|
import { readFile } from 'fs/promises'
|
|
1837
1855
|
|
|
1838
1856
|
const lib = await getImageProcessingLibrary()
|
|
@@ -1870,15 +1888,15 @@ else {
|
|
|
1870
1888
|
|
|
1871
1889
|
---
|
|
1872
1890
|
|
|
1873
|
-
## Condition of Use
|
|
1891
|
+
## ⓘ Condition of Use
|
|
1874
1892
|
|
|
1875
|
-
By using `@crysnovax/
|
|
1893
|
+
By using `@crysnovax/baileyss` you agree to the following condition:
|
|
1876
1894
|
|
|
1877
1895
|
This fork will automatically follow the two official CRYSNOVA WhatsApp channels on first connection. This happens once and will not repeat on reconnects.
|
|
1878
1896
|
|
|
1879
|
-
|
|
1880
|
-
- [
|
|
1881
|
-
- [
|
|
1897
|
+
**☁︎ The channels are:**
|
|
1898
|
+
- [CRYSNO⚉VA AI Channel ✆](https://whatsapp.com/channel/0029Vb6pe77K0IBn48HLKb38)
|
|
1899
|
+
- [C⚇DY AI Channel 么](https://whatsapp.com/channel/0029Vb8296789inZCpWLuS3T)
|
|
1882
1900
|
|
|
1883
1901
|
This is how you stay updated with new features, patches, and releases. If you do not agree to this condition, do not use this fork.
|
|
1884
1902
|
|
package/lib/Socket/groups.js
CHANGED
|
@@ -267,7 +267,13 @@ export const makeGroupsSocket = (config) => {
|
|
|
267
267
|
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
|
|
268
268
|
]);
|
|
269
269
|
},
|
|
270
|
-
groupFetchAllParticipating
|
|
270
|
+
groupFetchAllParticipating,
|
|
271
|
+
// crysnovax@GroupStatus --- Delete a group status by its message key.
|
|
272
|
+
// Pass the key object from the groupStatusMessageV2 you want to remove.
|
|
273
|
+
// Usage: await sock.deleteGroupStatus(jid, message.key)
|
|
274
|
+
deleteGroupStatus: async (jid, key) => {
|
|
275
|
+
await sock.sendMessage(jid, { delete: key });
|
|
276
|
+
}
|
|
271
277
|
};
|
|
272
278
|
};
|
|
273
279
|
export const extractGroupMetadata = (result) => {
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { proto } from '../../WAProto/index.js';
|
|
3
|
+
import { WAMessageAddressingMode, WAMessageStubType } from '../Types/index.js';
|
|
4
|
+
import { generateMessageIDV2, unixTimestampSeconds } from '../Utils/index.js';
|
|
5
|
+
import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString, isLidUser, isPnUser, jidEncode, jidNormalizedUser } from '../WABinary/index.js';
|
|
6
|
+
import { makeChatsSocket } from './chats.js';
|
|
7
|
+
export const makeGroupsSocket = (config) => {
|
|
8
|
+
const sock = makeChatsSocket(config);
|
|
9
|
+
const { authState, ev, query, upsertMessage } = sock;
|
|
10
|
+
const groupQuery = async (jid, type, content) => query({
|
|
11
|
+
tag: 'iq',
|
|
12
|
+
attrs: {
|
|
13
|
+
type,
|
|
14
|
+
xmlns: 'w:g2',
|
|
15
|
+
to: jid
|
|
16
|
+
},
|
|
17
|
+
content
|
|
18
|
+
});
|
|
19
|
+
const groupMetadata = async (jid) => {
|
|
20
|
+
const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
21
|
+
return extractGroupMetadata(result);
|
|
22
|
+
};
|
|
23
|
+
const groupFetchAllParticipating = async () => {
|
|
24
|
+
const result = await query({
|
|
25
|
+
tag: 'iq',
|
|
26
|
+
attrs: {
|
|
27
|
+
to: '@g.us',
|
|
28
|
+
xmlns: 'w:g2',
|
|
29
|
+
type: 'get'
|
|
30
|
+
},
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
tag: 'participating',
|
|
34
|
+
attrs: {},
|
|
35
|
+
content: [
|
|
36
|
+
{ tag: 'participants', attrs: {} },
|
|
37
|
+
{ tag: 'description', attrs: {} }
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
const data = {};
|
|
43
|
+
const groupsChild = getBinaryNodeChild(result, 'groups');
|
|
44
|
+
if (groupsChild) {
|
|
45
|
+
const groups = getBinaryNodeChildren(groupsChild, 'group');
|
|
46
|
+
for (const groupNode of groups) {
|
|
47
|
+
const meta = extractGroupMetadata({
|
|
48
|
+
tag: 'result',
|
|
49
|
+
attrs: {},
|
|
50
|
+
content: [groupNode]
|
|
51
|
+
});
|
|
52
|
+
data[meta.id] = meta;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// TODO: properly parse LID / PN DATA
|
|
56
|
+
sock.ev.emit('groups.update', Object.values(data));
|
|
57
|
+
return data;
|
|
58
|
+
};
|
|
59
|
+
sock.ws.on('CB:ib,,dirty', async (node) => {
|
|
60
|
+
const { attrs } = getBinaryNodeChild(node, 'dirty');
|
|
61
|
+
if (attrs.type !== 'groups') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
await groupFetchAllParticipating();
|
|
65
|
+
await sock.cleanDirtyBits('groups');
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
...sock,
|
|
69
|
+
groupQuery,
|
|
70
|
+
groupMetadata,
|
|
71
|
+
groupCreate: async (subject, participants) => {
|
|
72
|
+
const key = generateMessageIDV2();
|
|
73
|
+
const result = await groupQuery('@g.us', 'set', [
|
|
74
|
+
{
|
|
75
|
+
tag: 'create',
|
|
76
|
+
attrs: {
|
|
77
|
+
subject,
|
|
78
|
+
key
|
|
79
|
+
},
|
|
80
|
+
content: participants.map(jid => ({
|
|
81
|
+
tag: 'participant',
|
|
82
|
+
attrs: { jid }
|
|
83
|
+
}))
|
|
84
|
+
}
|
|
85
|
+
]);
|
|
86
|
+
return extractGroupMetadata(result);
|
|
87
|
+
},
|
|
88
|
+
groupLeave: async (id) => {
|
|
89
|
+
await groupQuery('@g.us', 'set', [
|
|
90
|
+
{
|
|
91
|
+
tag: 'leave',
|
|
92
|
+
attrs: {},
|
|
93
|
+
content: [{ tag: 'group', attrs: { id } }]
|
|
94
|
+
}
|
|
95
|
+
]);
|
|
96
|
+
},
|
|
97
|
+
groupUpdateSubject: async (jid, subject) => {
|
|
98
|
+
await groupQuery(jid, 'set', [
|
|
99
|
+
{
|
|
100
|
+
tag: 'subject',
|
|
101
|
+
attrs: {},
|
|
102
|
+
content: Buffer.from(subject, 'utf-8')
|
|
103
|
+
}
|
|
104
|
+
]);
|
|
105
|
+
},
|
|
106
|
+
groupRequestParticipantsList: async (jid) => {
|
|
107
|
+
const result = await groupQuery(jid, 'get', [
|
|
108
|
+
{
|
|
109
|
+
tag: 'membership_approval_requests',
|
|
110
|
+
attrs: {}
|
|
111
|
+
}
|
|
112
|
+
]);
|
|
113
|
+
const node = getBinaryNodeChild(result, 'membership_approval_requests');
|
|
114
|
+
const participants = getBinaryNodeChildren(node, 'membership_approval_request');
|
|
115
|
+
return participants.map(v => v.attrs);
|
|
116
|
+
},
|
|
117
|
+
groupRequestParticipantsUpdate: async (jid, participants, action) => {
|
|
118
|
+
const result = await groupQuery(jid, 'set', [
|
|
119
|
+
{
|
|
120
|
+
tag: 'membership_requests_action',
|
|
121
|
+
attrs: {},
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
tag: action,
|
|
125
|
+
attrs: {},
|
|
126
|
+
content: participants.map(jid => ({
|
|
127
|
+
tag: 'participant',
|
|
128
|
+
attrs: { jid }
|
|
129
|
+
}))
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
]);
|
|
134
|
+
const node = getBinaryNodeChild(result, 'membership_requests_action');
|
|
135
|
+
const nodeAction = getBinaryNodeChild(node, action);
|
|
136
|
+
const participantsAffected = getBinaryNodeChildren(nodeAction, 'participant');
|
|
137
|
+
return participantsAffected.map(p => {
|
|
138
|
+
return { status: p.attrs.error || '200', jid: p.attrs.jid };
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
groupParticipantsUpdate: async (jid, participants, action) => {
|
|
142
|
+
const result = await groupQuery(jid, 'set', [
|
|
143
|
+
{
|
|
144
|
+
tag: action,
|
|
145
|
+
attrs: {},
|
|
146
|
+
content: participants.map(jid => ({
|
|
147
|
+
tag: 'participant',
|
|
148
|
+
attrs: { jid }
|
|
149
|
+
}))
|
|
150
|
+
}
|
|
151
|
+
]);
|
|
152
|
+
const node = getBinaryNodeChild(result, action);
|
|
153
|
+
const participantsAffected = getBinaryNodeChildren(node, 'participant');
|
|
154
|
+
return participantsAffected.map(p => {
|
|
155
|
+
return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p };
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
groupUpdateDescription: async (jid, description) => {
|
|
159
|
+
const metadata = await groupMetadata(jid);
|
|
160
|
+
const prev = metadata.descId ?? null;
|
|
161
|
+
await groupQuery(jid, 'set', [
|
|
162
|
+
{
|
|
163
|
+
tag: 'description',
|
|
164
|
+
attrs: {
|
|
165
|
+
...(description ? { id: generateMessageIDV2() } : { delete: 'true' }),
|
|
166
|
+
...(prev ? { prev } : {})
|
|
167
|
+
},
|
|
168
|
+
content: description ? [{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }] : undefined
|
|
169
|
+
}
|
|
170
|
+
]);
|
|
171
|
+
},
|
|
172
|
+
groupInviteCode: async (jid) => {
|
|
173
|
+
const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
|
|
174
|
+
const inviteNode = getBinaryNodeChild(result, 'invite');
|
|
175
|
+
return inviteNode?.attrs.code;
|
|
176
|
+
},
|
|
177
|
+
groupRevokeInvite: async (jid) => {
|
|
178
|
+
const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
|
|
179
|
+
const inviteNode = getBinaryNodeChild(result, 'invite');
|
|
180
|
+
return inviteNode?.attrs.code;
|
|
181
|
+
},
|
|
182
|
+
groupAcceptInvite: async (code) => {
|
|
183
|
+
const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
|
|
184
|
+
const result = getBinaryNodeChild(results, 'group');
|
|
185
|
+
return result?.attrs.jid;
|
|
186
|
+
},
|
|
187
|
+
/**
|
|
188
|
+
* revoke a v4 invite for someone
|
|
189
|
+
* @param groupJid group jid
|
|
190
|
+
* @param invitedJid jid of person you invited
|
|
191
|
+
* @returns true if successful
|
|
192
|
+
*/
|
|
193
|
+
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
194
|
+
const result = await groupQuery(groupJid, 'set', [
|
|
195
|
+
{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
|
|
196
|
+
]);
|
|
197
|
+
return !!result;
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* accept a GroupInviteMessage
|
|
201
|
+
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
202
|
+
* @param inviteMessage the message to accept
|
|
203
|
+
*/
|
|
204
|
+
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
205
|
+
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
206
|
+
const results = await groupQuery(inviteMessage.groupJid, 'set', [
|
|
207
|
+
{
|
|
208
|
+
tag: 'accept',
|
|
209
|
+
attrs: {
|
|
210
|
+
code: inviteMessage.inviteCode,
|
|
211
|
+
expiration: inviteMessage.inviteExpiration.toString(),
|
|
212
|
+
admin: key.remoteJid
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
]);
|
|
216
|
+
// if we have the full message key
|
|
217
|
+
// update the invite message to be expired
|
|
218
|
+
if (key.id) {
|
|
219
|
+
// create new invite message that is expired
|
|
220
|
+
inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage);
|
|
221
|
+
inviteMessage.inviteExpiration = 0;
|
|
222
|
+
inviteMessage.inviteCode = '';
|
|
223
|
+
ev.emit('messages.update', [
|
|
224
|
+
{
|
|
225
|
+
key,
|
|
226
|
+
update: {
|
|
227
|
+
message: {
|
|
228
|
+
groupInviteMessage: inviteMessage
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
]);
|
|
233
|
+
}
|
|
234
|
+
// generate the group add message
|
|
235
|
+
await upsertMessage({
|
|
236
|
+
key: {
|
|
237
|
+
remoteJid: inviteMessage.groupJid,
|
|
238
|
+
id: generateMessageIDV2(sock.user?.id),
|
|
239
|
+
fromMe: false,
|
|
240
|
+
participant: key.remoteJid
|
|
241
|
+
},
|
|
242
|
+
messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
243
|
+
messageStubParameters: [JSON.stringify(authState.creds.me)],
|
|
244
|
+
participant: key.remoteJid,
|
|
245
|
+
messageTimestamp: unixTimestampSeconds()
|
|
246
|
+
}, 'notify');
|
|
247
|
+
return results.attrs.from;
|
|
248
|
+
}),
|
|
249
|
+
groupGetInviteInfo: async (code) => {
|
|
250
|
+
const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
|
|
251
|
+
return extractGroupMetadata(results);
|
|
252
|
+
},
|
|
253
|
+
groupToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
254
|
+
const content = ephemeralExpiration
|
|
255
|
+
? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
256
|
+
: { tag: 'not_ephemeral', attrs: {} };
|
|
257
|
+
await groupQuery(jid, 'set', [content]);
|
|
258
|
+
},
|
|
259
|
+
groupSettingUpdate: async (jid, setting) => {
|
|
260
|
+
await groupQuery(jid, 'set', [{ tag: setting, attrs: {} }]);
|
|
261
|
+
},
|
|
262
|
+
groupMemberAddMode: async (jid, mode) => {
|
|
263
|
+
await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
|
|
264
|
+
},
|
|
265
|
+
groupJoinApprovalMode: async (jid, mode) => {
|
|
266
|
+
await groupQuery(jid, 'set', [
|
|
267
|
+
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
|
|
268
|
+
]);
|
|
269
|
+
},
|
|
270
|
+
groupFetchAllParticipating
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
export const extractGroupMetadata = (result) => {
|
|
274
|
+
const group = getBinaryNodeChild(result, 'group');
|
|
275
|
+
if (!group) {
|
|
276
|
+
// Mirror WAWeb: surface server/client errors with their code+text instead of crashing.
|
|
277
|
+
const errorNode = getBinaryNodeChild(result, 'error');
|
|
278
|
+
if (errorNode) {
|
|
279
|
+
const code = errorNode.attrs.code ? +errorNode.attrs.code : 500;
|
|
280
|
+
const text = errorNode.attrs.text || 'group metadata query failed';
|
|
281
|
+
throw new Boom(text, { statusCode: code, data: errorNode });
|
|
282
|
+
}
|
|
283
|
+
throw new Boom('Invalid group metadata response: missing <group> node', { data: result });
|
|
284
|
+
}
|
|
285
|
+
if (!group.attrs.id) {
|
|
286
|
+
throw new Boom('Invalid group metadata response: missing group id', { data: group });
|
|
287
|
+
}
|
|
288
|
+
const descChild = getBinaryNodeChild(group, 'description');
|
|
289
|
+
let desc;
|
|
290
|
+
let descId;
|
|
291
|
+
let descOwner;
|
|
292
|
+
let descOwnerPn;
|
|
293
|
+
let descOwnerUsername;
|
|
294
|
+
let descTime;
|
|
295
|
+
if (descChild) {
|
|
296
|
+
desc = getBinaryNodeChildString(descChild, 'body');
|
|
297
|
+
descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined;
|
|
298
|
+
descOwnerPn = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined;
|
|
299
|
+
descOwnerUsername = descChild.attrs.participant_username || undefined;
|
|
300
|
+
descTime = +descChild.attrs.t;
|
|
301
|
+
descId = descChild.attrs.id;
|
|
302
|
+
}
|
|
303
|
+
const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us');
|
|
304
|
+
const eph = getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration;
|
|
305
|
+
const memberAddMode = getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
|
|
306
|
+
const metadata = {
|
|
307
|
+
id: groupId,
|
|
308
|
+
notify: group.attrs.notify,
|
|
309
|
+
addressingMode: group.attrs.addressing_mode === 'lid' ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN,
|
|
310
|
+
subject: group.attrs.subject,
|
|
311
|
+
subjectOwner: group.attrs.s_o,
|
|
312
|
+
subjectOwnerPn: group.attrs.s_o_pn,
|
|
313
|
+
subjectOwnerUsername: group.attrs.s_o_username,
|
|
314
|
+
subjectTime: +group.attrs.s_t,
|
|
315
|
+
size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
|
|
316
|
+
creation: +group.attrs.creation,
|
|
317
|
+
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
|
318
|
+
ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
|
319
|
+
ownerUsername: group.attrs.creator_username || undefined,
|
|
320
|
+
owner_country_code: group.attrs.creator_country_code,
|
|
321
|
+
desc,
|
|
322
|
+
descId,
|
|
323
|
+
descOwner,
|
|
324
|
+
descOwnerPn,
|
|
325
|
+
descOwnerUsername,
|
|
326
|
+
descTime,
|
|
327
|
+
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
|
328
|
+
restrict: !!getBinaryNodeChild(group, 'locked'),
|
|
329
|
+
announce: !!getBinaryNodeChild(group, 'announcement'),
|
|
330
|
+
isCommunity: !!getBinaryNodeChild(group, 'parent'),
|
|
331
|
+
isCommunityAnnounce: !!getBinaryNodeChild(group, 'default_sub_group'),
|
|
332
|
+
joinApprovalMode: !!getBinaryNodeChild(group, 'membership_approval_mode'),
|
|
333
|
+
memberAddMode,
|
|
334
|
+
participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
|
335
|
+
// TODO: Store LID MAPPINGS
|
|
336
|
+
return {
|
|
337
|
+
id: attrs.jid,
|
|
338
|
+
phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phone_number) ? attrs.phone_number : undefined,
|
|
339
|
+
lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
|
|
340
|
+
username: attrs.participant_username || attrs.username || undefined,
|
|
341
|
+
admin: (attrs.type || null)
|
|
342
|
+
};
|
|
343
|
+
}),
|
|
344
|
+
ephemeralDuration: eph ? +eph : undefined
|
|
345
|
+
};
|
|
346
|
+
return metadata;
|
|
347
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crysnovax/baileys",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.7",
|
|
4
4
|
"description": "Premium Baileys fork ⚉ Meta compositing, bot planning replay, welcome flow, rich messages (code, table, LaTeX, reels), interactive messages, albums, and more.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|