@crysnovax/baileys 2.6.2 → 2.6.3
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 +261 -67
- package/lib/Socket/chats.js +23 -1
- package/lib/Socket/{chats.js[past] → chats.js[old]} +16 -2
- package/lib/Socket/messages-send.js +30 -0
- package/lib/Socket/messages-send.js[old] +1367 -0
- package/lib/Utils/chat-utils.js +14 -0
- package/lib/Utils/chat-utils.js[old] +871 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,60 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
<h2 align="center">
|
|
3
|
-
<img src="https://media2.giphy.com/media/QssGEmpkyEOhBCb7e1/giphy.gif?cid=ecf05e47a0n3gi1bfqntqmob8g9aid1oyj2wr3ds3mg700bl&rid=giphy.gif" width="28" />
|
|
4
|
-
About Me
|
|
5
|
-
<img src="https://media2.giphy.com/media/QssGEmpkyEOhBCb7e1/giphy.gif?cid=ecf05e47a0n3gi1bfqntqmob8g9aid1oyj2wr3ds3mg700bl&rid=giphy.gif" width="28" />
|
|
6
|
-
</h2>
|
|
7
|
-
|
|
8
|
-
```javascript
|
|
9
|
-
const crysnova = {
|
|
10
|
-
name: "CRYSNOVA AI",
|
|
11
|
-
location: "🌍 Global",
|
|
12
|
-
role: "Full Stack Developer & Bot Creator",
|
|
13
|
-
stack: ["JavaScript", "Node.js", "Cloudflare Workers", "WhatsApp Bot Development"],
|
|
14
|
-
interests: ["AI", "Automation", "Open Source", "Building Cool Stuff"],
|
|
15
|
-
currentFocus: "Building the most powerful WhatsApp bot ecosystem 🚀",
|
|
16
|
-
funFact: "My code runs 24/7 on Cloudflare's edge network ⚡"
|
|
17
|
-
};
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
<br />
|
|
21
|
-
|
|
22
|
-
<h2 align="center">
|
|
23
|
-
<img src="https://media.giphy.com/media/iY8CRBdQXODJSCERIr/giphy.gif" width="28" />
|
|
24
|
-
Tech Stack
|
|
25
|
-
<img src="https://media.giphy.com/media/iY8CRBdQXODJSCERIr/giphy.gif" width="28" />
|
|
26
|
-
</h2>
|
|
27
|
-
|
|
28
|
-
<p align="center">
|
|
29
|
-
<img src="https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge&logo=javascript&logoColor=black&labelColor=0a0f0a&color=10b981" />
|
|
30
|
-
<img src="https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=node.js&logoColor=white&labelColor=0a0f0a&color=10b981" />
|
|
31
|
-
<img src="https://img.shields.io/badge/Cloudflare-F38020?style=for-the-badge&logo=cloudflare&logoColor=white&labelColor=0a0f0a&color=10b981" />
|
|
32
|
-
<img src="https://img.shields.io/badge/Workers-F38020?style=for-the-badge&logo=cloudflareworkers&logoColor=white&labelColor=0a0f0a&color=10b981" />
|
|
33
|
-
<img src="https://img.shields.io/badge/GitHub-181717?style=for-the-badge&logo=github&logoColor=white&labelColor=0a0f0a&color=10b981" />
|
|
34
|
-
<img src="https://img.shields.io/badge/Baileys-25D366?style=for-the-badge&logo=whatsapp&logoColor=white&labelColor=0a0f0a&color=10b981" />
|
|
35
|
-
<img src="https://img.shields.io/badge/API-FF6F00?style=for-the-badge&logo=fastapi&logoColor=white&labelColor=0a0f0a&color=10b981" />
|
|
36
|
-
<img src="https://img.shields.io/badge/KV-FF4F00?style=for-the-badge&logo=cloudflare&logoColor=white&labelColor=0a0f0a&color=10b981" />
|
|
37
|
-
</p>
|
|
38
|
-
<br />
|
|
39
|
-
|
|
40
|
-
<h2 align="center">
|
|
41
|
-
<img src="https://media.giphy.com/media/W5eoZHPpUx9sapR0eu/giphy.gif" width="28" />
|
|
42
|
-
Featured Projects
|
|
43
|
-
<img src="https://media.giphy.com/media/W5eoZHPpUx9sapR0eu/giphy.gif" width="28" />
|
|
44
|
-
</h2>
|
|
45
|
-
|
|
46
|
-
<div align="center">
|
|
47
|
-
|
|
48
|
-
| 🚀 Project | ⭐ Stars | 📝 Description |
|
|
49
|
-
|-----------|---------|---------------|
|
|
50
|
-
| **CRYSNOVA AI** | [](https://github.com/crysnovax/CRYSNOVA_AI) | 550+ Command WhatsApp Bot with AI Integration |
|
|
51
|
-
| **API Gateway** | [](https://github.com/crysnovax/API) | Nexray Endpoints Unified API Gateway |
|
|
52
|
-
| **Economy Engine** | [](https://github.com/crysnovax) | Realistic Virtual Economy with Banking System |
|
|
53
|
-
|
|
54
|
-
</div>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
1
|
<p align="center">
|
|
59
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%2Fbailey%3B+WhatsApp+API+for+Node.js%3B+Rich+Messages+%7C+Meta+AI+Style%3B+Production+Ready+%E2%9C%85" alt="Typing Animation" />
|
|
60
3
|
</p>
|
|
@@ -90,15 +33,18 @@ const crysnova = {
|
|
|
90
33
|
| 10 | [Welcome Flow](#welcome-flow) | Auto-greet new contacts with FAQ menus |
|
|
91
34
|
| 11 | [Payment Messages](#payment-messages) | Invites, invoices, orders, payment requests |
|
|
92
35
|
| 12 | [Message Options](#message-options) | AI icon, ephemeral, spoilers, view once, raw, and more |
|
|
93
|
-
| 13 | [
|
|
94
|
-
| 14 | [
|
|
95
|
-
| 15 | [
|
|
96
|
-
| 16 | [
|
|
97
|
-
| 17 | [
|
|
98
|
-
| 18 | [
|
|
99
|
-
| 19 | [
|
|
100
|
-
| 20 | [
|
|
101
|
-
| 21 | [
|
|
36
|
+
| 13 | [Status & Stories](#status--stories) | Post status updates with text, media, mentions |
|
|
37
|
+
| 14 | [Favorites](#favorites) | Manage WhatsApp Favorites list |
|
|
38
|
+
| 15 | [Newsletter Management](#newsletter-management) | Create, update, follow, react, delete newsletters |
|
|
39
|
+
| 16 | [Group Management](#group-management) | Create, settings, participants, invites, metadata |
|
|
40
|
+
| 17 | [Community Management](#community-management) | Communities, subgroups, linked groups |
|
|
41
|
+
| 18 | [Profile & Business](#profile--business) | Profile pictures, business catalog, products, quick replies |
|
|
42
|
+
| 19 | [Privacy & Security](#privacy--security) | Last seen, online, status, read receipts, calls |
|
|
43
|
+
| 20 | [Utility Methods](#utility-methods) | LID mapping, dirty bits, app state sync, props |
|
|
44
|
+
| 21 | [Events Reference](#events-reference) | Full list of socket event listeners |
|
|
45
|
+
| 22 | [Image Processing](#image-processing) | Sharp, NAPI-RS, Jimp auto-detection |
|
|
46
|
+
| 23 | [Condition of Use](#condition-of-use) | Channel follow agreement |
|
|
47
|
+
| 24 | [Credits](#credits) | Attribution and enhancements |
|
|
102
48
|
|
|
103
49
|
---
|
|
104
50
|
|
|
@@ -113,12 +59,16 @@ const crysnova = {
|
|
|
113
59
|
| Rich Messages | ✅ | Code blocks, tables, inline entities, carousel cards |
|
|
114
60
|
| Meta AI Style | ✅ | Live thinking indicators without "edited" badges |
|
|
115
61
|
| Welcome Flow | ✅ | Auto-greet new contacts with interactive FAQ menus |
|
|
62
|
+
| Status Posting | ✅ | Text with colors/fonts, image, video, audio, mentions |
|
|
63
|
+
| Favorites Management | ✅ | Add/remove JIDs with local persistence |
|
|
64
|
+
| HD Profile Picture | ✅ | Full-size upload with no crop or resize via `{ hd: true }` (max 720px) |
|
|
65
|
+
| LID/PN Resolution | ✅ | Cross-resolve LID and phone number JIDs |
|
|
66
|
+
| Member Labels | ✅ | Group participant labels |
|
|
116
67
|
| No Obfuscation | ✅ | Fully readable, auditable source code |
|
|
117
68
|
| Newsletter Ready | ✅ | Full media support, quoting, quiz polls |
|
|
118
69
|
| Image Processing | ✅ | Auto-detects `sharp`, `@napi-rs/image`, or `jimp` |
|
|
119
70
|
| Safe FFmpeg | ✅ | Uses `spawn` instead of `exec` |
|
|
120
71
|
| In-Memory Store | ✅ | Reintroduced with minimal ESM adaptation |
|
|
121
|
-
| HD Profile Picture | ✅ | Full-size upload with no crop or resize via `{ hd: true }` (max 720px) |
|
|
122
72
|
|
|
123
73
|
---
|
|
124
74
|
|
|
@@ -1190,6 +1140,161 @@ sock.sendMessage(jid, {
|
|
|
1190
1140
|
|
|
1191
1141
|
---
|
|
1192
1142
|
|
|
1143
|
+
## Status & Stories
|
|
1144
|
+
|
|
1145
|
+
Post WhatsApp status updates with text, media, and targeted mentions.
|
|
1146
|
+
|
|
1147
|
+
### Text Status
|
|
1148
|
+
|
|
1149
|
+
```javascript
|
|
1150
|
+
// Plain text status
|
|
1151
|
+
sock.sendMessage(jid, {
|
|
1152
|
+
text: 'Hello world!',
|
|
1153
|
+
status: true
|
|
1154
|
+
})
|
|
1155
|
+
|
|
1156
|
+
// With background color (named)
|
|
1157
|
+
sock.sendMessage(jid, {
|
|
1158
|
+
text: 'Hello world!',
|
|
1159
|
+
status: true,
|
|
1160
|
+
backgroundColor: '#FFD32B2B' // red
|
|
1161
|
+
})
|
|
1162
|
+
|
|
1163
|
+
// With hex color
|
|
1164
|
+
sock.sendMessage(jid, {
|
|
1165
|
+
text: 'Hello world!',
|
|
1166
|
+
status: true,
|
|
1167
|
+
backgroundColor: '#FF0057FF' // blue
|
|
1168
|
+
})
|
|
1169
|
+
|
|
1170
|
+
// With font style (0-5)
|
|
1171
|
+
sock.sendMessage(jid, {
|
|
1172
|
+
text: 'Hello world!',
|
|
1173
|
+
status: true,
|
|
1174
|
+
backgroundColor: '#FF1FA15A', // green
|
|
1175
|
+
font: 2 // norican
|
|
1176
|
+
})
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
**Available colors:** `red`, `blue`, `green`, `black`, `white`, `purple`, `orange`, `pink`, `yellow`, `teal`
|
|
1180
|
+
|
|
1181
|
+
**Available fonts:** `0=sans`, `1=serif`, `2=norican`, `3=bryndan`, `4=bebasneue`, `5=futura`
|
|
1182
|
+
|
|
1183
|
+
### Media Status
|
|
1184
|
+
|
|
1185
|
+
```javascript
|
|
1186
|
+
// Image status
|
|
1187
|
+
sock.sendMessage(jid, {
|
|
1188
|
+
image: { url: './image.jpg' },
|
|
1189
|
+
caption: 'My status!',
|
|
1190
|
+
status: true
|
|
1191
|
+
})
|
|
1192
|
+
|
|
1193
|
+
// Video status
|
|
1194
|
+
sock.sendMessage(jid, {
|
|
1195
|
+
video: { url: './video.mp4' },
|
|
1196
|
+
caption: 'Watch this!',
|
|
1197
|
+
status: true
|
|
1198
|
+
})
|
|
1199
|
+
|
|
1200
|
+
// Audio status
|
|
1201
|
+
sock.sendMessage(jid, {
|
|
1202
|
+
audio: { url: './audio.mp3' },
|
|
1203
|
+
ptt: false,
|
|
1204
|
+
status: true
|
|
1205
|
+
})
|
|
1206
|
+
```
|
|
1207
|
+
|
|
1208
|
+
### Status with Targeted Viewers
|
|
1209
|
+
|
|
1210
|
+
```javascript
|
|
1211
|
+
// Only specific contacts can see the status
|
|
1212
|
+
sock.sendMessage(jid, {
|
|
1213
|
+
text: 'Exclusive status!',
|
|
1214
|
+
status: true,
|
|
1215
|
+
statusJidList: [
|
|
1216
|
+
'628123456789@s.whatsapp.net',
|
|
1217
|
+
'628987654321@s.whatsapp.net'
|
|
1218
|
+
]
|
|
1219
|
+
})
|
|
1220
|
+
```
|
|
1221
|
+
|
|
1222
|
+
### Status Mentions
|
|
1223
|
+
|
|
1224
|
+
```javascript
|
|
1225
|
+
// Mention users/groups in status (they get a notification)
|
|
1226
|
+
sock.sendMessage([jidA, jidB, jidC], {
|
|
1227
|
+
text: 'Hey check my status!'
|
|
1228
|
+
})
|
|
1229
|
+
```
|
|
1230
|
+
|
|
1231
|
+
---
|
|
1232
|
+
|
|
1233
|
+
## Favorites
|
|
1234
|
+
|
|
1235
|
+
Manage your WhatsApp Favorites list — add, remove, and sync across devices.
|
|
1236
|
+
|
|
1237
|
+
### Add to Favorites
|
|
1238
|
+
|
|
1239
|
+
```javascript
|
|
1240
|
+
// Add a single JID
|
|
1241
|
+
await sock.addToFavorites(['628123456789@s.whatsapp.net'])
|
|
1242
|
+
|
|
1243
|
+
// Add multiple JIDs (replaces entire list — merge handled by caller)
|
|
1244
|
+
await sock.addToFavorites([
|
|
1245
|
+
'628123456789@s.whatsapp.net',
|
|
1246
|
+
'628987654321@s.whatsapp.net',
|
|
1247
|
+
'1234@g.us'
|
|
1248
|
+
])
|
|
1249
|
+
```
|
|
1250
|
+
|
|
1251
|
+
### Remove from Favorites
|
|
1252
|
+
|
|
1253
|
+
```javascript
|
|
1254
|
+
// Remove specific JIDs (pass remaining list after filter)
|
|
1255
|
+
await sock.removeFromFavorites([
|
|
1256
|
+
'628123456789@s.whatsapp.net' // only this one remains
|
|
1257
|
+
])
|
|
1258
|
+
```
|
|
1259
|
+
|
|
1260
|
+
### Full Example with Local Persistence
|
|
1261
|
+
|
|
1262
|
+
```javascript
|
|
1263
|
+
const fs = require('fs')
|
|
1264
|
+
const path = require('path')
|
|
1265
|
+
|
|
1266
|
+
const FAV_FILE = path.join(__dirname, 'database', 'favorites.json')
|
|
1267
|
+
|
|
1268
|
+
const loadFavs = () => {
|
|
1269
|
+
try { return JSON.parse(fs.readFileSync(FAV_FILE, 'utf8')) }
|
|
1270
|
+
catch { return [] }
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
const saveFavs = (favs) => {
|
|
1274
|
+
fs.mkdirSync(path.dirname(FAV_FILE), { recursive: true })
|
|
1275
|
+
fs.writeFileSync(FAV_FILE, JSON.stringify(favs, null, 2))
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// Add
|
|
1279
|
+
const existing = loadFavs()
|
|
1280
|
+
const target = '628123456789@s.whatsapp.net'
|
|
1281
|
+
if (!existing.includes(target)) {
|
|
1282
|
+
const merged = [...existing, target]
|
|
1283
|
+
await sock.addToFavorites(merged)
|
|
1284
|
+
saveFavs(merged)
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// Remove
|
|
1288
|
+
const toRemove = '628123456789@s.whatsapp.net'
|
|
1289
|
+
const remaining = existing.filter(jid => jid !== toRemove)
|
|
1290
|
+
await sock.addToFavorites(remaining)
|
|
1291
|
+
saveFavs(remaining)
|
|
1292
|
+
```
|
|
1293
|
+
|
|
1294
|
+
> **Note:** WhatsApp favorites use a single app state record. Each `SET` replaces the entire list. Always pass the complete desired array.
|
|
1295
|
+
|
|
1296
|
+
---
|
|
1297
|
+
|
|
1193
1298
|
## Newsletter Management
|
|
1194
1299
|
|
|
1195
1300
|
```javascript
|
|
@@ -1541,6 +1646,91 @@ sock.updateDisableLinkPreviewsPrivacy(true)
|
|
|
1541
1646
|
|
|
1542
1647
|
---
|
|
1543
1648
|
|
|
1649
|
+
## Utility Methods
|
|
1650
|
+
|
|
1651
|
+
### LID / Phone Number Resolution
|
|
1652
|
+
|
|
1653
|
+
```javascript
|
|
1654
|
+
// Resolve LID ↔ PN cross-mappings
|
|
1655
|
+
const userId = await sock.findUserId('628123456789@s.whatsapp.net')
|
|
1656
|
+
console.log(userId)
|
|
1657
|
+
// { lid: '1234567890@lid', phoneNumber: '628123456789@s.whatsapp.net' }
|
|
1658
|
+
|
|
1659
|
+
const userId2 = await sock.findUserId('1234567890@lid')
|
|
1660
|
+
console.log(userId2)
|
|
1661
|
+
// { lid: '1234567890@lid', phoneNumber: '628123456789@s.whatsapp.net' }
|
|
1662
|
+
```
|
|
1663
|
+
|
|
1664
|
+
### Fetch User Status
|
|
1665
|
+
|
|
1666
|
+
```javascript
|
|
1667
|
+
// Fetch status metadata for one or more users
|
|
1668
|
+
const statusList = await sock.fetchStatus('628123456789@s.whatsapp.net', '628987654321@s.whatsapp.net')
|
|
1669
|
+
```
|
|
1670
|
+
|
|
1671
|
+
### Fetch Disappearing Duration
|
|
1672
|
+
|
|
1673
|
+
```javascript
|
|
1674
|
+
// Get disappearing message duration for contacts
|
|
1675
|
+
const durations = await sock.fetchDisappearingDuration('628123456789@s.whatsapp.net')
|
|
1676
|
+
```
|
|
1677
|
+
|
|
1678
|
+
### Bot List
|
|
1679
|
+
|
|
1680
|
+
```javascript
|
|
1681
|
+
// Fetch official bot list (v2)
|
|
1682
|
+
const bots = await sock.getBotListV2()
|
|
1683
|
+
// [{ jid: '...', personaId: '...' }]
|
|
1684
|
+
```
|
|
1685
|
+
|
|
1686
|
+
### Call Links
|
|
1687
|
+
|
|
1688
|
+
```javascript
|
|
1689
|
+
// Create voice/video call link
|
|
1690
|
+
const token = await sock.createCallLink('audio') // voice call
|
|
1691
|
+
const token2 = await sock.createCallLink('video') // video call
|
|
1692
|
+
const token3 = await sock.createCallLink('video', { // with scheduled event
|
|
1693
|
+
startTime: Date.now() + 3600000
|
|
1694
|
+
})
|
|
1695
|
+
```
|
|
1696
|
+
|
|
1697
|
+
### Server Properties
|
|
1698
|
+
|
|
1699
|
+
```javascript
|
|
1700
|
+
// Access server-assigned AB props
|
|
1701
|
+
console.log(sock.serverProps)
|
|
1702
|
+
// {
|
|
1703
|
+
// privacyTokenOn1to1: true, // tctoken on 1:1 messages
|
|
1704
|
+
// profilePicPrivacyToken: true, // tctoken on profile pic IQs
|
|
1705
|
+
// lidTrustedTokenIssueToLid: false // issue tctokens to LID
|
|
1706
|
+
// }
|
|
1707
|
+
```
|
|
1708
|
+
|
|
1709
|
+
### App State Sync
|
|
1710
|
+
|
|
1711
|
+
```javascript
|
|
1712
|
+
// Force resync specific collections
|
|
1713
|
+
await sock.resyncAppState(['regular_high', 'regular_low'], false)
|
|
1714
|
+
|
|
1715
|
+
// Apply custom app patch
|
|
1716
|
+
await sock.appPatch({
|
|
1717
|
+
syncAction: { ... },
|
|
1718
|
+
index: ['...'],
|
|
1719
|
+
type: 'regular_low',
|
|
1720
|
+
apiVersion: 5,
|
|
1721
|
+
operation: proto.SyncdMutation.SyncdOperation.SET
|
|
1722
|
+
})
|
|
1723
|
+
```
|
|
1724
|
+
|
|
1725
|
+
### Clean Dirty Bits
|
|
1726
|
+
|
|
1727
|
+
```javascript
|
|
1728
|
+
// Clear dirty bits for specific sync types
|
|
1729
|
+
await sock.cleanDirtyBits('account_sync', timestamp)
|
|
1730
|
+
```
|
|
1731
|
+
|
|
1732
|
+
---
|
|
1733
|
+
|
|
1544
1734
|
## Events Reference
|
|
1545
1735
|
|
|
1546
1736
|
```javascript
|
|
@@ -1654,6 +1844,10 @@ Full credit to the original maintainers and contributors:
|
|
|
1654
1844
|
- Rich message types (code blocks, tables, inline entities)
|
|
1655
1845
|
- Meta AI-style compositing and replay planning
|
|
1656
1846
|
- Welcome flow with FAQ auto-greeting
|
|
1847
|
+
- Status posting with text, media, colors, fonts, mentions
|
|
1848
|
+
- Favorites management with full list sync
|
|
1849
|
+
- LID/PN cross-resolution
|
|
1850
|
+
- Member labels for groups
|
|
1657
1851
|
- Newsletter media fixes and quiz support
|
|
1658
1852
|
- Image processing auto-detection
|
|
1659
1853
|
- Safe FFmpeg spawn-based execution
|
package/lib/Socket/chats.js
CHANGED
|
@@ -936,6 +936,26 @@ export const makeChatsSocket = (config) => {
|
|
|
936
936
|
quickReply: { timestamp, deleted: true }
|
|
937
937
|
}, '');
|
|
938
938
|
};
|
|
939
|
+
/**
|
|
940
|
+
* crysnovax@Favorites --- Set complete WhatsApp Favorites list.
|
|
941
|
+
* Replaces server-side list with the provided array (merging is handled by caller).
|
|
942
|
+
* @param jids — complete array of JIDs to set as favorites
|
|
943
|
+
*/
|
|
944
|
+
const addToFavorites = (jids) => {
|
|
945
|
+
return chatModify({
|
|
946
|
+
favorites: { jids, add: true }
|
|
947
|
+
}, '');
|
|
948
|
+
};
|
|
949
|
+
/**
|
|
950
|
+
* crysnovax@Favorites --- Remove all favorites (clear list).
|
|
951
|
+
*/
|
|
952
|
+
const removeFromFavorites = (jids) => {
|
|
953
|
+
// For single removal, caller must pass remaining list to addToFavorites
|
|
954
|
+
// This sends the provided jids array (should be remaining items after filter)
|
|
955
|
+
return chatModify({
|
|
956
|
+
favorites: { jids, add: true }
|
|
957
|
+
}, '');
|
|
958
|
+
};
|
|
939
959
|
/**
|
|
940
960
|
* queries need to be fired on connection open
|
|
941
961
|
* help ensure parity with WA Web
|
|
@@ -1222,6 +1242,8 @@ export const makeChatsSocket = (config) => {
|
|
|
1222
1242
|
removeMessageLabel,
|
|
1223
1243
|
star,
|
|
1224
1244
|
addOrEditQuickReply,
|
|
1225
|
-
removeQuickReply
|
|
1245
|
+
removeQuickReply,
|
|
1246
|
+
addToFavorites,
|
|
1247
|
+
removeFromFavorites
|
|
1226
1248
|
};
|
|
1227
1249
|
};
|
|
@@ -5,6 +5,7 @@ import { DEFAULT_CACHE_TTLS, HISTORY_SYNC_PAUSED_TIMEOUT_MS, PROCESSABLE_HISTORY
|
|
|
5
5
|
import { ALL_WA_PATCH_NAMES } from '../Types/index.js';
|
|
6
6
|
import { SyncState } from '../Types/State.js';
|
|
7
7
|
import { chatModificationToAppPatch, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, ensureLTHashStateVersion, extractSyncdPatches, generateProfilePicture, getHistoryMsg, isAppStateSyncIrrecoverable, isMissingKeyError, MAX_SYNC_ATTEMPTS, newLTHashState, processSyncAction } from '../Utils/index.js';
|
|
8
|
+
import { generateProfilePictureHD } from '../Utils/messages-media.js';
|
|
8
9
|
import { makeMutex } from '../Utils/make-mutex.js';
|
|
9
10
|
import processMessage from '../Utils/process-message.js';
|
|
10
11
|
import { buildTcTokenFromJid } from '../Utils/tc-token-utils.js';
|
|
@@ -207,7 +208,15 @@ export const makeChatsSocket = (config) => {
|
|
|
207
208
|
}
|
|
208
209
|
return userId;
|
|
209
210
|
};
|
|
210
|
-
/** update the profile picture for yourself or a group
|
|
211
|
+
/** update the profile picture for yourself or a group
|
|
212
|
+
*
|
|
213
|
+
* Standard (crop + resize to 720×720):
|
|
214
|
+
* sock.updateProfilePicture(jid, content)
|
|
215
|
+
* sock.updateProfilePicture(jid, content, { width: 640, height: 640 })
|
|
216
|
+
*
|
|
217
|
+
* HD (full-size, no crop, no resize):
|
|
218
|
+
* sock.updateProfilePicture(jid, content, { hd: true })
|
|
219
|
+
*/
|
|
211
220
|
const updateProfilePicture = async (jid, content, dimensions) => {
|
|
212
221
|
let targetJid;
|
|
213
222
|
if (!jid) {
|
|
@@ -219,7 +228,12 @@ export const makeChatsSocket = (config) => {
|
|
|
219
228
|
else {
|
|
220
229
|
targetJid = undefined;
|
|
221
230
|
}
|
|
222
|
-
|
|
231
|
+
// crysnovax@HD-Profile --- Dual mode:
|
|
232
|
+
// hd:true → generateProfilePictureHD (preserves aspect ratio, caps at 1920, manages file size)
|
|
233
|
+
// standard → generateProfilePicture (720×720 square crop, or custom dimensions)
|
|
234
|
+
const { img } = dimensions?.hd
|
|
235
|
+
? await generateProfilePictureHD(content)
|
|
236
|
+
: await generateProfilePicture(content, dimensions);
|
|
223
237
|
await query({
|
|
224
238
|
tag: 'iq',
|
|
225
239
|
attrs: {
|
|
@@ -1218,6 +1218,36 @@ export const makeMessagesSocket = (config) => {
|
|
|
1218
1218
|
: disappearingMessagesInChat;
|
|
1219
1219
|
await groupToggleEphemeral(jid, value);
|
|
1220
1220
|
}
|
|
1221
|
+
// crysnovax@Status --- status:true flag routes any message type to status@broadcast
|
|
1222
|
+
// Supports: text with backgroundColor + font, image, video, audio, sticker
|
|
1223
|
+
// Usage: sock.sendMessage(jid, { text: 'Hello', status: true, backgroundColor: '#FF0000', font: 2 })
|
|
1224
|
+
// sock.sendMessage(jid, { audio: buffer, status: true, ptt: false })
|
|
1225
|
+
else if ('status' in content && content.status === true) {
|
|
1226
|
+
const { status: _, backgroundColor, font, statusJidList: contentJidList, ...statusContent } = content;
|
|
1227
|
+
const fullMsg = await generateWAMessage('status@broadcast', statusContent, {
|
|
1228
|
+
logger,
|
|
1229
|
+
userJid,
|
|
1230
|
+
upload: waUploadToServer,
|
|
1231
|
+
mediaCache: config.mediaCache,
|
|
1232
|
+
options: config.options,
|
|
1233
|
+
...options,
|
|
1234
|
+
...(backgroundColor ? { backgroundColor } : {}),
|
|
1235
|
+
...(font !== undefined ? { font } : {}),
|
|
1236
|
+
messageId: generateMessageIDV2(userJid)
|
|
1237
|
+
});
|
|
1238
|
+
await relayMessage('status@broadcast', fullMsg.message, {
|
|
1239
|
+
messageId: fullMsg.key.id,
|
|
1240
|
+
statusJidList: contentJidList || options.statusJidList,
|
|
1241
|
+
additionalAttributes: options.additionalAttributes || {},
|
|
1242
|
+
additionalNodes: options.additionalNodes || []
|
|
1243
|
+
});
|
|
1244
|
+
if (config.emitOwnEvents) {
|
|
1245
|
+
process.nextTick(async () => {
|
|
1246
|
+
await messageMutex.mutex(() => upsertMessage(fullMsg, 'append'));
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
return fullMsg;
|
|
1250
|
+
}
|
|
1221
1251
|
else {
|
|
1222
1252
|
const fullMsg = await generateWAMessage(jid, content, {
|
|
1223
1253
|
logger,
|