@elfhkry666/baileys 0.3.20 โ 0.3.22
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 +68 -2022
- package/WAProto/index.d.ts +31 -168
- package/WAProto/index.js +211 -1256
- package/lib/Defaults/index.d.ts +1 -1
- package/lib/Defaults/index.js +2 -1
- package/lib/Socket/business.d.ts +1 -1
- package/lib/Socket/chats.d.ts +1 -8
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +7 -12
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +1 -1
- package/lib/Socket/groups.d.ts +1 -1
- package/lib/Socket/index.d.ts +1 -1
- package/lib/Socket/messages-recv.d.ts +1 -1
- package/lib/Socket/messages-send.d.ts +1 -1
- package/lib/Socket/newsletter.d.ts +1 -1
- package/lib/Socket/newsletter.js +9 -12
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +0 -3
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Utils/auth-utils.d.ts.map +1 -1
- package/lib/Utils/auth-utils.js +1 -5
- package/lib/Utils/auth-utils.js.map +1 -1
- package/lib/Utils/browser-utils.d.ts +0 -1
- package/lib/Utils/browser-utils.d.ts.map +1 -1
- package/lib/Utils/browser-utils.js +0 -1
- package/lib/Utils/browser-utils.js.map +1 -1
- package/lib/Utils/generics.js +1 -1
- package/lib/Utils/messages.d.ts +4 -4
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +54 -21
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/rich-message-utils.d.ts +1 -1
- package/lib/Utils/rich-message-utils.d.ts.map +1 -1
- package/lib/Utils/rich-message-utils.js +10 -122
- package/lib/Utils/rich-message-utils.js.map +1 -1
- package/lib/Utils/tc-token-utils.d.ts.map +1 -1
- package/lib/Utils/tc-token-utils.js +2 -3
- package/lib/Utils/tc-token-utils.js.map +1 -1
- package/lib/Utils/use-single-file-auth-state.js +1 -1
- package/lib/Utils/validate-connection.d.ts.map +1 -1
- package/lib/Utils/validate-connection.js +2 -9
- package/lib/Utils/validate-connection.js.map +1 -1
- package/lib/index.js +7 -8
- package/package.json +14 -45
package/README.md
CHANGED
|
@@ -1,286 +1,112 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# ๐ @elfhkry666/baileys
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
Enhanced Baileys v7 with fixes for newsletter media uploads, plus support for interactive messages, albums, and additional message types.
|
|
7
|
-
<br><br>
|
|
8
|
-
<a href="https://www.npmjs.com/package/@elfhkry666/baileys">
|
|
9
|
-
<img src="https://img.shields.io/npm/v/@elfhkry666/baileys?style=for-the-badge&logo=npm"/>
|
|
10
|
-
</a>
|
|
11
|
-
<a href="https://www.npmjs.com/package/@elfhkry666/baileys">
|
|
12
|
-
<img src="https://img.shields.io/npm/dm/@elfhkry666/baileys?style=for-the-badge&logo=npm"/>
|
|
13
|
-
</a>
|
|
14
|
-
<a href="https://github.com/Fhkryxv-0/Baileys">
|
|
15
|
-
<img src="https://img.shields.io/github/stars/Fhkryxv-0/Baileys?style=for-the-badge&logo=github"/>
|
|
16
|
-
</a>
|
|
17
|
-
<a href="LICENSE">
|
|
18
|
-
<img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge"/>
|
|
19
|
-
</a>
|
|
20
|
-
<a href="https://nodejs.org">
|
|
21
|
-
<img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&labelColor=green&logoColor=white&style=for-the-badge"/>
|
|
22
|
-
</a>
|
|
23
|
-
<a href="#">
|
|
24
|
-
<img src="https://img.shields.io/badge/ESM-only?logo=javascript&labelColor=yellow&logoColor=black&style=for-the-badge"/>
|
|
25
|
-
</a>
|
|
26
|
-
</p>
|
|
5
|
+
**WhatsApp Web API for Node.js**
|
|
27
6
|
|
|
7
|
+
Enhanced Baileys v7 with newsletter media fixes, interactive messages, albums, and extra message types.
|
|
28
8
|
|
|
29
|
-
|
|
9
|
+
[](https://www.npmjs.com/package/@elfhkry666/baileys)
|
|
10
|
+
[](https://www.npmjs.com/package/@elfhkry666/baileys)
|
|
11
|
+
[](https://nodejs.org)
|
|
12
|
+
[](LICENSE)
|
|
13
|
+
[](#-import-esm--cjs)
|
|
30
14
|
|
|
31
|
-
|
|
15
|
+
</div>
|
|
32
16
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
> [!IMPORTANT]
|
|
36
|
-
> Hi everyone,
|
|
37
|
-
>
|
|
38
|
-
> I need to say this clearly.
|
|
39
|
-
>
|
|
40
|
-
> Some npm packages are reuploading my fork under different names, with almost no meaningful changes:
|
|
41
|
-
>
|
|
42
|
-
> - [@nuisockets](https://www.npmjs.com/package/@nuisockets/baileys)
|
|
43
|
-
> - [@nuiisatoru](https://www.npmjs.com/package/@nuiisatoru/baileys)
|
|
44
|
-
> - [@nuiisweetberry](https://www.npmjs.com/package/@nuiisweetberry/baileys)
|
|
45
|
-
> - [@lumina-md](https://www.npmjs.com/package/@lumina-md/baileys)
|
|
46
|
-
>
|
|
47
|
-
> They:
|
|
48
|
-
>
|
|
49
|
-
> - Renamed my fork under different package names
|
|
50
|
-
> - Removed or ignored proper maintainer credit
|
|
51
|
-
> - Added unnecessary overhead
|
|
52
|
-
> - Rewrote changelogs and modification notes under their own names
|
|
53
|
-
> - Claimed existing work and changes as if they made them
|
|
54
|
-
> - Copied code directly from my fork with little to no meaningful modification
|
|
55
|
-
>
|
|
56
|
-
> This is not acceptable.
|
|
57
|
-
>
|
|
58
|
-
> To be clear, I am **NOT** the original maintainer of Baileys. full respect goes to https://github.com/WhiskeySockets/Baileys.
|
|
59
|
-
>
|
|
60
|
-
> **This issue is about attribution, honesty, and respecting open-source contributions.**
|
|
61
|
-
>
|
|
62
|
-
> Forking is completely fine. Removing credits and presenting someone else's work as your own is not.
|
|
63
|
-
>
|
|
64
|
-
> Please report if necessary.
|
|
65
|
-
>
|
|
66
|
-
> Thank you. ๐ค
|
|
17
|
+
---
|
|
67
18
|
|
|
68
19
|
> [!NOTE]
|
|
69
|
-
>
|
|
70
|
-
>
|
|
71
|
-
> ๐ And, really sorry for my bad english.
|
|
72
|
-
|
|
73
|
-
### ๐ v0.3.19 Sync Notes
|
|
20
|
+
> This is a community fork maintained by **Fhkry**. It is **not** affiliated with Meta/WhatsApp,
|
|
21
|
+
> and is not intended to replace upstream Baileys. Use it responsibly and at your own risk.
|
|
74
22
|
|
|
75
|
-
Synced from [itsliaaa/baileys](https://github.com/itsliaaa/baileys) (upstream this fork is based on):
|
|
76
|
-
- ๐ผ๏ธ Newsletter media upload fix
|
|
77
|
-
- ๐ `makeInMemoryStore` refresh for Baileys v7
|
|
78
|
-
- ๐ฆ FFmpeg execution moved to `spawn`
|
|
79
|
-
- ๐๏ธ `@napi-rs/image` processing backend
|
|
80
|
-
- โจ Expanded Rich Response (carousel items, inline image/video, LaTeX, posts, products, suggested prompts), Code Block, Inline Entities, Table messages
|
|
81
|
-
- ๐ญ Newsletter (channel) message quoting
|
|
82
|
-
- ๐ Custom interactive button icons
|
|
83
|
-
- ๐ฃ `mentionAll`
|
|
84
|
-
- ๐ `secureMetaServiceLabel`
|
|
85
23
|
|
|
86
|
-
|
|
87
|
-
messages with forged "forwarded from newsletter" metadata, and a routine that silently auto-followed a
|
|
88
|
-
channel on every connection. Neither was part of upstream itsliaaa/baileys, neither was documented, and
|
|
89
|
-
both ran without any consent from applications or end users of this library.
|
|
24
|
+
## โจ What this fork adds
|
|
90
25
|
|
|
91
|
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
-
|
|
26
|
+
- ๐ผ๏ธ Fix for media that could not be sent to newsletters (upstream issue).
|
|
27
|
+
- ๐งฉ Interactive messages: buttons, lists, native flows, templates, carousels.
|
|
28
|
+
- ๐ผ๏ธ Album messages (image + video).
|
|
29
|
+
- ๐ณ Payment-related messages: requests, invites, orders, invoices.
|
|
30
|
+
- ๐ฆ Sticker-pack, rich-response, code-block, inline-entity and table messages.
|
|
31
|
+
- ๐ฃ `externalAdReply` without manual `contextInfo`.
|
|
32
|
+
- ๐๏ธ Reintroduced `makeInMemoryStore` (minimal ESM adaptation for v7).
|
|
33
|
+
- โ๏ธ FFmpeg runs through `spawn` instead of `exec` for safer process handling.
|
|
96
34
|
|
|
97
|
-
|
|
98
|
-
- ๐ฉ Expanded messages support for:
|
|
99
|
-
- ๐ผ๏ธ [Album Message](#%EF%B8%8F-album-image--video)
|
|
100
|
-
- ๐ค [Group Status Message](#%E2%80%8D%E2%80%8D-group-status)
|
|
101
|
-
- ๐๐ป [Interactive Message](#-sending-interactive-messages) (buttons, lists, native flows, templates, carousels).
|
|
102
|
-
- ๐๏ธ [Status Mention Message](#%EF%B8%8F-status-mention)
|
|
103
|
-
- ๐ฆ [Sticker Pack Message](#-sticker-pack)
|
|
104
|
-
- โจ [Rich Response Message](#-rich-response) **[NEW]**
|
|
105
|
-
- ๐งพ [Message with Code Blocks](#-message-with-code-block) **[NEW]**
|
|
106
|
-
- [๐ Message with Inline Entities](#-message-with-inline-entities) **[NEW]**
|
|
107
|
-
- ๐ [Message with Table](#-message-with-table) **[NEW]**
|
|
108
|
-
- ๐ณ [Payment-related Message](#-sending-payment-messages) (payment requests, invites, orders, invoices).
|
|
109
|
-
- ๐ฐ Simplified sending messages with ad thumbnail using [`externalAdReply`](#-external-ad-reply), without requiring manual `contextInfo`.
|
|
110
|
-
- ๐ญ Added support for quoting messages inside channel (newsletter). **[NEW]**
|
|
111
|
-
- ๐ Added support for [custom button icon](#%EF%B8%8F-interactive). **[NEW]**
|
|
35
|
+
## ๐ฅ Installation
|
|
112
36
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
- ๐ฃ [`mentionAll`](#-mention) - Mention all group participants without requiring their JIDs in `mentions` or `mentionedJid` **[NEW]**
|
|
117
|
-
- ๐ง [`ephemeral`](#-ephemeral), [`groupStatus`](#%E2%80%8D%E2%80%8D-group-status), [`isLottie`](#-lottie-sticker), [`spoiler`](#-spoiler), [`viewOnce`](#%EF%B8%8F-view-once), [`viewOnceV2`](#%EF%B8%8F-view-once-v2), [`viewOnceV2Extension`](#%EF%B8%8F-view-once-v2-extension), [`interactiveAsTemplate`](#%EF%B8%8F-interactive) - Message wrappers
|
|
118
|
-
- ๐ [`secureMetaServiceLabel`](#%EF%B8%8F-secure-meta-service-label) - Secure meta service label on message **[NEW]**
|
|
119
|
-
- ๐ [`raw`](#-raw) - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
|
|
120
|
-
|
|
121
|
-
### ๐ Table of Contents
|
|
122
|
-
- [โจ Highlights](#-highlights)
|
|
123
|
-
- [๐ ๏ธ Internal Adjustments](#%EF%B8%8F-internal-adjustments)
|
|
124
|
-
- [๐จ Messages Handling & Compatibility](#-highlights)
|
|
125
|
-
- [๐งฉ Additional Message Options](#-additional-message-options)
|
|
126
|
-
- [๐ฅ Installation](#-installation)
|
|
127
|
-
- [๐งฉ Import (ESM & CJS)](#-import-esm--cjs)
|
|
128
|
-
- [๐ Connect to WhatsApp (Quick Step)](#-connect-to-whatsapp-quick-step)
|
|
129
|
-
- [๐ Auth State](#-auth-state)
|
|
130
|
-
- [๐๏ธ Implementing Data Store](#%EF%B8%8F-implementing-data-store)
|
|
131
|
-
- [๐ชช WhatsApp IDs Explain](#-whatsapp-ids-explain)
|
|
132
|
-
- [โ๏ธ Sending Messages](#%EF%B8%8F-sending-messages)
|
|
133
|
-
- [๐ Text](#-text)
|
|
134
|
-
- [๐ Mention](#-mention)
|
|
135
|
-
- [๐ Reaction](#-reaction)
|
|
136
|
-
- [๐ Pin Message](#-pin-message)
|
|
137
|
-
- [๐ Keep Chat](#-keep-chat)
|
|
138
|
-
- [โก๏ธ Forward Message](#%EF%B8%8F-forward-message)
|
|
139
|
-
- [๐ค Contact](#-contact)
|
|
140
|
-
- [๐ Location](#-location)
|
|
141
|
-
- [๐๏ธ Event](#%EF%B8%8F-event)
|
|
142
|
-
- [๐ฅ Group Invite](#-group-invite)
|
|
143
|
-
- [๐๏ธ Product](#%EF%B8%8F-product)
|
|
144
|
-
- [๐ Poll](#-poll)
|
|
145
|
-
- [๐ญ Button Response](#-button-response)
|
|
146
|
-
- [โจ Rich Response](#-rich-response)
|
|
147
|
-
- [๐งพ Message with Code Block](#-message-with-code-block)
|
|
148
|
-
- [๐ Message with Inline Entities](#-message-with-inline-entities)
|
|
149
|
-
- [๐ Message with Table](#-message-with-table)
|
|
150
|
-
- [๐๏ธ Status Mention](#%EF%B8%8F-status-mention)
|
|
151
|
-
- [๐ Sending Media Messages](#-sending-media-messages)
|
|
152
|
-
- [๐ผ๏ธ Image](#%EF%B8%8F-image)
|
|
153
|
-
- [๐ฅ Video](#-video)
|
|
154
|
-
- [๐ Sticker](#-sticker)
|
|
155
|
-
- [๐ฝ Audio](#-audio)
|
|
156
|
-
- [๐๏ธ Document](#%EF%B8%8F-document)
|
|
157
|
-
- [๐ผ๏ธ Album (Image & Video)](#%EF%B8%8F-album-image--video)
|
|
158
|
-
- [๐ฆ Sticker Pack](#-sticker-pack)
|
|
159
|
-
- [๐๐ป Sending Interactive Messages](#-sending-interactive-messages)
|
|
160
|
-
- [๐ Buttons](#-buttons)
|
|
161
|
-
- [๐ List](#-list)
|
|
162
|
-
- [๐๏ธ Interactive](#%EF%B8%8F-interactive)
|
|
163
|
-
- [๐ซ Hydrated Template](#-hydrated-template)
|
|
164
|
-
- [๐ณ Sending Payment Messages](#-sending-payment-messages)
|
|
165
|
-
- [โ Invite Payment](#-invite-payment)
|
|
166
|
-
- [๐งพ Invoice](#-invoice)
|
|
167
|
-
- [๐๏ธ Order](#%EF%B8%8F-order)
|
|
168
|
-
- [๐ณ Request Payment](#-request-payment)
|
|
169
|
-
- [๐๏ธ Other Message Options](#%EF%B8%8F-other-message-options)
|
|
170
|
-
- [๐ค AI Icon](#-ai-icon)
|
|
171
|
-
- [๐ Ephemeral](#-ephemeral)
|
|
172
|
-
- [๐ฐ External Ad Reply](#-external-ad-reply)
|
|
173
|
-
- [๐งโ๐งโ๐ง Group Status](#%E2%80%8D%E2%80%8D-group-status)
|
|
174
|
-
- [๐ฑ Lottie Sticker](#-lottie-sticker)
|
|
175
|
-
- [๐งฉ Raw](#-raw)
|
|
176
|
-
- [๐ท๏ธ Secure Meta Service Label](#%EF%B8%8F-secure-meta-service-label)
|
|
177
|
-
- [๐ Spoiler](#-spoiler)
|
|
178
|
-
- [๐๏ธ View Once](#%EF%B8%8F-view-once)
|
|
179
|
-
- [๐๏ธ View Once V2](#%EF%B8%8F-view-once-v2)
|
|
180
|
-
- [๐๏ธ View Once V2 Extension](#%EF%B8%8F-view-once-v2-extension)
|
|
181
|
-
- [โป๏ธ Modify Messages](#%EF%B8%8F-modify-messages)
|
|
182
|
-
- [๐๏ธ Delete Messages](#%EF%B8%8F-delete-messages)
|
|
183
|
-
- [โ๏ธ Edit Messages](#%EF%B8%8F-edit-messages)
|
|
184
|
-
- [๐งฐ Additional Contents](#-additional-contents)
|
|
185
|
-
- [๐ท๏ธ Find User ID (JID|PN/LID)](#%EF%B8%8F-find-user-id-jidpnlid)
|
|
186
|
-
- [๐ Request Custom Pairing Code](#-request-custom-pairing-code)
|
|
187
|
-
- [๐ผ๏ธ Image Processing](#%EF%B8%8F-image-processing)
|
|
188
|
-
- [๐ฃ Newsletter Management](#-newsletter-management)
|
|
189
|
-
- [๐ฅ Group Management](#-group-management)
|
|
190
|
-
- [๐ฅ Community Management](#-community-management)
|
|
191
|
-
- [๐ค Profile Management](#-profile-management)
|
|
192
|
-
- [๐ Business Management](#-business-management)
|
|
193
|
-
- [๐ Privacy Management](#-privacy-management)
|
|
194
|
-
- [๐ก Events](#-events)
|
|
195
|
-
- [๐ Try the Bot](#-try-the-bot)
|
|
196
|
-
- [๐ฆ Fork Base](#-fork-base)
|
|
197
|
-
- [๐ฃ Credits](#-credits)
|
|
37
|
+
```bash
|
|
38
|
+
# npm
|
|
39
|
+
npm i @elfhkry666/baileys@latest
|
|
198
40
|
|
|
199
|
-
|
|
41
|
+
# github
|
|
42
|
+
npm i Fhkryxv-0/Baileys#v0.3.21
|
|
43
|
+
```
|
|
200
44
|
|
|
201
|
-
|
|
45
|
+
Or in `package.json`:
|
|
202
46
|
|
|
203
47
|
```json
|
|
204
|
-
# NPM
|
|
205
48
|
"dependencies": {
|
|
206
49
|
"@elfhkry666/baileys": "latest"
|
|
207
50
|
}
|
|
208
|
-
|
|
209
|
-
|
|
51
|
+
```
|
|
52
|
+
```json
|
|
210
53
|
"dependencies": {
|
|
211
|
-
"@elfhkry666/baileys": "github:Fhkryxv-0/Baileys"
|
|
54
|
+
"@elfhkry666/baileys": "github:Fhkryxv-0/Baileys#v0.3.21"
|
|
212
55
|
}
|
|
213
56
|
```
|
|
214
57
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
```bash
|
|
218
|
-
# NPM
|
|
219
|
-
npm i @elfhkry666/baileys@latest
|
|
220
|
-
|
|
221
|
-
# GitHub
|
|
222
|
-
npm i github:Fhkryxv-0/Baileys
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
#### ๐งฉ Import (ESM & CJS)
|
|
58
|
+
### ๐งฉ Import (ESM & CJS)
|
|
226
59
|
|
|
227
60
|
```javascript
|
|
228
|
-
//
|
|
61
|
+
// ESM
|
|
229
62
|
import { makeWASocket } from '@elfhkry666/baileys'
|
|
230
63
|
|
|
231
|
-
//
|
|
64
|
+
// CJS
|
|
232
65
|
const { makeWASocket } = require('@elfhkry666/baileys')
|
|
233
66
|
```
|
|
234
67
|
|
|
235
|
-
|
|
68
|
+
## ๐ Quick start (pairing code)
|
|
236
69
|
|
|
237
70
|
```javascript
|
|
238
|
-
import {
|
|
71
|
+
import {
|
|
72
|
+
makeWASocket, delay, DisconnectReason, useMultiFileAuthState
|
|
73
|
+
} from '@elfhkry666/baileys'
|
|
239
74
|
import { Boom } from '@hapi/boom'
|
|
240
75
|
import pino from 'pino'
|
|
241
76
|
|
|
242
|
-
//
|
|
243
|
-
const myPhoneNumber = '6288888888888'
|
|
244
|
-
|
|
245
|
-
const logger = pino({ level: 'silent' })
|
|
77
|
+
const myPhoneNumber = '628xxxxxxxx' // bot number, no "+"
|
|
246
78
|
|
|
247
79
|
const connectToWhatsApp = async () => {
|
|
248
80
|
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
249
|
-
|
|
81
|
+
|
|
250
82
|
const sock = makeWASocket({
|
|
251
|
-
logger,
|
|
83
|
+
logger: pino({ level: 'silent' }),
|
|
252
84
|
auth: state
|
|
253
85
|
})
|
|
254
86
|
|
|
255
87
|
sock.ev.on('creds.update', saveCreds)
|
|
256
88
|
|
|
257
|
-
sock.ev.on('connection.update', (update) => {
|
|
89
|
+
sock.ev.on('connection.update', async (update) => {
|
|
258
90
|
const { connection, lastDisconnect } = update
|
|
91
|
+
|
|
259
92
|
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
260
93
|
await delay(1500)
|
|
261
94
|
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
262
|
-
console.log('๐ Pairing code
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
console.log('โ ๏ธ Connection closed
|
|
267
|
-
if (shouldReconnect)
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
else if (connection === 'open') {
|
|
272
|
-
console.log('โ
Successfully connected to WhatsApp')
|
|
95
|
+
console.log('๐ Pairing code :', code)
|
|
96
|
+
} else if (connection === 'close') {
|
|
97
|
+
const shouldReconnect =
|
|
98
|
+
new Boom(lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
99
|
+
console.log('โ ๏ธ Connection closed, reconnecting:', shouldReconnect)
|
|
100
|
+
if (shouldReconnect) connectToWhatsApp()
|
|
101
|
+
} else if (connection === 'open') {
|
|
102
|
+
console.log('โ
Connected to WhatsApp')
|
|
273
103
|
}
|
|
274
104
|
})
|
|
275
105
|
|
|
276
106
|
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
277
107
|
for (const message of messages) {
|
|
278
108
|
if (!message.message) continue
|
|
279
|
-
|
|
280
|
-
console.log('๐ Got new message', ':', message)
|
|
281
|
-
await sock.sendMessage(message.key.remoteJid, {
|
|
282
|
-
text: '๐๐ป Hello world'
|
|
283
|
-
})
|
|
109
|
+
await sock.sendMessage(message.key.remoteJid, { text: '๐ Hello from Fhkry' })
|
|
284
110
|
}
|
|
285
111
|
})
|
|
286
112
|
}
|
|
@@ -288,1807 +114,27 @@ const connectToWhatsApp = async () => {
|
|
|
288
114
|
connectToWhatsApp()
|
|
289
115
|
```
|
|
290
116
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
> [!NOTE]
|
|
294
|
-
> You can use the experimental `useSingleFileAuthState` and `useSqliteAuthState` as an alternative to `useMultiFileAuthState`. However, `useSingleFileAuthState` already includes an internal caching mechanism, so there is no need to wrap `state.keys` with `makeCacheableSignalKeyStore`.
|
|
295
|
-
|
|
296
|
-
### ๐๏ธ Implementing Data Store
|
|
297
|
-
|
|
298
|
-
> [!CAUTION]
|
|
299
|
-
> I highly recommend building your own data store, as keeping an entire chat history in memory can lead to excessive RAM usage.
|
|
300
|
-
|
|
301
|
-
```javascript
|
|
302
|
-
import { makeWASocket, makeInMemoryStore, delay, DisconnectReason, useMultiFileAuthState } from '@elfhkry666/baileys'
|
|
303
|
-
import { Boom } from '@hapi/boom'
|
|
304
|
-
import pino from 'pino'
|
|
305
|
-
|
|
306
|
-
const myPhoneNumber = '6288888888888'
|
|
307
|
-
|
|
308
|
-
// --- Create your store path
|
|
309
|
-
const storePath = './store.json'
|
|
310
|
-
|
|
311
|
-
const logger = pino({ level: 'silent' })
|
|
312
|
-
|
|
313
|
-
const connectToWhatsApp = async () => {
|
|
314
|
-
const { state, saveCreds } = await useMultiFileAuthState('session')
|
|
315
|
-
|
|
316
|
-
const sock = makeWASocket({
|
|
317
|
-
logger,
|
|
318
|
-
auth: state
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
const store = makeInMemoryStore({
|
|
322
|
-
logger,
|
|
323
|
-
socket: sock
|
|
324
|
-
})
|
|
325
|
-
|
|
326
|
-
store.bind(sock.ev)
|
|
327
|
-
|
|
328
|
-
sock.ev.on('creds.update', saveCreds)
|
|
329
|
-
|
|
330
|
-
sock.ev.on('connection.update', (update) => {
|
|
331
|
-
const { connection, lastDisconnect } = update
|
|
332
|
-
if (connection === 'connecting' && !sock.authState.creds.registered) {
|
|
333
|
-
await delay(1500)
|
|
334
|
-
const code = await sock.requestPairingCode(myPhoneNumber)
|
|
335
|
-
console.log('๐ Pairing code', ':', code)
|
|
336
|
-
}
|
|
337
|
-
else if (connection === 'close') {
|
|
338
|
-
const shouldReconnect = new Boom(connection?.lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
|
|
339
|
-
console.log('โ ๏ธ Connection closed because', lastDisconnect.error, ', reconnecting ', shouldReconnect)
|
|
340
|
-
if (shouldReconnect) {
|
|
341
|
-
connectToWhatsApp()
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
else if (connection === 'open') {
|
|
345
|
-
console.log('โ
Successfully connected to WhatsApp')
|
|
346
|
-
}
|
|
347
|
-
})
|
|
348
|
-
|
|
349
|
-
sock.ev.on('chats.upsert', () => {
|
|
350
|
-
console.log('โ๏ธ Got chats', store.chats.all())
|
|
351
|
-
})
|
|
352
|
-
|
|
353
|
-
sock.ev.on('contacts.upsert', () => {
|
|
354
|
-
console.log('๐ฅ Got contacts', Object.values(store.contacts))
|
|
355
|
-
})
|
|
356
|
-
|
|
357
|
-
// --- Read store from file
|
|
358
|
-
store.readFromFile(storePath)
|
|
359
|
-
|
|
360
|
-
// --- Save store every 3 minutes
|
|
361
|
-
setInterval(() => {
|
|
362
|
-
store.writeToFile(storePath)
|
|
363
|
-
}, 180000)
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
connectToWhatsApp()
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### ๐ชช WhatsApp IDs Explain
|
|
370
|
-
|
|
371
|
-
`id` is the WhatsApp ID, called `jid` and `lid` too, of the person or group you're sending the message to.
|
|
372
|
-
- It must be in the format `[country code][phone number]@s.whatsapp.net`
|
|
373
|
-
- Example for people: `19999999999@s.whatsapp.net` and `12699999999@lid`.
|
|
374
|
-
- For groups, it must be in the format `123456789-123345@g.us`.
|
|
375
|
-
- For Meta AI, it's `11111111111@bot`.
|
|
376
|
-
- For broadcast lists, it's `[timestamp of creation]@broadcast`.
|
|
377
|
-
- For stories, the ID is `status@broadcast`.
|
|
378
|
-
|
|
379
|
-
### โ๏ธ Sending Messages
|
|
380
|
-
|
|
381
|
-
> [!NOTE]
|
|
382
|
-
> You can get the `jid` from `message.key.remoteJid` in the first example.
|
|
383
|
-
|
|
384
|
-
#### ๐ Text
|
|
385
|
-
|
|
386
|
-
```javascript
|
|
387
|
-
// --- Send a regular text message
|
|
388
|
-
sock.sendMessage(jid, {
|
|
389
|
-
text: '๐๐ป Hello'
|
|
390
|
-
}, {
|
|
391
|
-
quoted: message
|
|
392
|
-
})
|
|
393
|
-
|
|
394
|
-
// --- Send a text message with a link preview
|
|
395
|
-
const urlA = 'https://www.npmjs.com/package/@elfhkry666/baileys'
|
|
396
|
-
|
|
397
|
-
sock.sendMessage(jid, {
|
|
398
|
-
text: urlA + ' ๐๐ป Check it out!',
|
|
399
|
-
linkPreview: {
|
|
400
|
-
'matched-text': urlA,
|
|
401
|
-
title: '๐ฑ @elfhkry666/baileys',
|
|
402
|
-
description: 'Underrated Baileys Fork',
|
|
403
|
-
previewType: 0, // --- Use 1 for video playback in the link preview
|
|
404
|
-
jpegThumbnail: fs.readFileSync('./path/to/image.jpg')
|
|
405
|
-
}
|
|
406
|
-
})
|
|
407
|
-
|
|
408
|
-
// --- Send a text message with a large link preview and favicon
|
|
409
|
-
import { prepareWAMessageMedia } from '@elfhkry666/baileys'
|
|
410
|
-
|
|
411
|
-
const urlB = 'https://www.npmjs.com/package/@elfhkry666/baileys#readme'
|
|
412
|
-
|
|
413
|
-
const { imageMessage: image } = await prepareWAMessageMedia({
|
|
414
|
-
image: {
|
|
415
|
-
url: './path/to/image.jpg'
|
|
416
|
-
}
|
|
417
|
-
}, {
|
|
418
|
-
upload: sock.waUploadToServer,
|
|
419
|
-
mediaTypeOverride: 'thumbnail-link'
|
|
420
|
-
})
|
|
421
|
-
|
|
422
|
-
// --- Set the thumbnail display size
|
|
423
|
-
image.height = 720
|
|
424
|
-
image.width = 480
|
|
425
|
-
|
|
426
|
-
sock.sendMessage(jid, {
|
|
427
|
-
text: urlB + ' ๐๐ป Check it out!',
|
|
428
|
-
linkPreview: {
|
|
429
|
-
'matched-text': urlB,
|
|
430
|
-
title: '๐ฑ @elfhkry666/baileys',
|
|
431
|
-
description: 'Underrated Baileys Fork',
|
|
432
|
-
previewType: 0,
|
|
433
|
-
jpegThumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
434
|
-
highQualityThumbnail: image,
|
|
435
|
-
linkPreviewMetadata: {
|
|
436
|
-
linkMediaDuration: 0, // --- Duration in seconds (for video/audio content)
|
|
437
|
-
socialMediaPostType: 1, // --- Enum: 0 = NONE, 1 = REEL, 2 = LIVE_VIDEO, 3 = LONG_VIDEO, 4 = SINGLE_IMAGE, 5 = CAROUSEL
|
|
438
|
-
} // --- Additional metadata for large link preview
|
|
439
|
-
},
|
|
440
|
-
favicon: {
|
|
441
|
-
url: './path/to/tiny-image.ico'
|
|
442
|
-
}
|
|
443
|
-
})
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
#### ๐ Mention
|
|
447
|
-
|
|
448
|
-
```javascript
|
|
449
|
-
// --- Regular mention
|
|
450
|
-
sock.sendMessage(jid, {
|
|
451
|
-
text: '๐๐ป Hello @628123456789',
|
|
452
|
-
mentions: ['628123456789@s.whatsapp.net']
|
|
453
|
-
}, {
|
|
454
|
-
quoted: message
|
|
455
|
-
})
|
|
456
|
-
|
|
457
|
-
// --- Mention all
|
|
458
|
-
sock.sendMessage(jid, {
|
|
459
|
-
text: '๐๐ป Hello @all',
|
|
460
|
-
mentionAll: true
|
|
461
|
-
}, {
|
|
462
|
-
quoted: message
|
|
463
|
-
})
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
#### ๐ Reaction
|
|
467
|
-
|
|
468
|
-
```javascript
|
|
469
|
-
sock.sendMessage(jid, {
|
|
470
|
-
react: {
|
|
471
|
-
key: message.key,
|
|
472
|
-
text: 'โจ'
|
|
473
|
-
}
|
|
474
|
-
})
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
#### ๐ Pin Message
|
|
478
|
-
|
|
479
|
-
```javascript
|
|
480
|
-
sock.sendMessage(jid, {
|
|
481
|
-
pin: message.key,
|
|
482
|
-
time: 86400, // --- Set the value in seconds: 86400 (1d), 604800 (7d), or 2592000 (30d)
|
|
483
|
-
type: 1 // --- Or 2 to remove
|
|
484
|
-
})
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
#### ๐ Keep Chat
|
|
488
|
-
|
|
489
|
-
> [!NOTE]
|
|
490
|
-
> Keep Chat can only be used in chats or groups with disappearing messages enabled.
|
|
491
|
-
|
|
492
|
-
```javascript
|
|
493
|
-
sock.sendMessage(jid, {
|
|
494
|
-
keep: message.key,
|
|
495
|
-
type: 1 // --- Or 2 to remove
|
|
496
|
-
})
|
|
497
|
-
```
|
|
498
|
-
|
|
499
|
-
#### โก๏ธ Forward Message
|
|
500
|
-
|
|
501
|
-
```javascript
|
|
502
|
-
sock.sendMessage(jid, {
|
|
503
|
-
forward: message,
|
|
504
|
-
force: true // --- Optional
|
|
505
|
-
})
|
|
506
|
-
```
|
|
507
|
-
|
|
508
|
-
#### ๐ค Contact
|
|
509
|
-
|
|
510
|
-
```javascript
|
|
511
|
-
const vcard = 'BEGIN:VCARD\n'
|
|
512
|
-
+ 'VERSION:3.0\n'
|
|
513
|
-
+ 'FN:Fhkry\n'
|
|
514
|
-
+ 'ORG:Waitress;\n'
|
|
515
|
-
+ 'TEL;type=CELL;type=VOICE;waid=628123456789:+62 8123 4567 89\n'
|
|
516
|
-
+ 'END:VCARD'
|
|
517
|
-
|
|
518
|
-
sock.sendMessage(jid, {
|
|
519
|
-
contacts: {
|
|
520
|
-
displayName: 'Fhkry',
|
|
521
|
-
contacts: [
|
|
522
|
-
{ vcard }
|
|
523
|
-
]
|
|
524
|
-
}
|
|
525
|
-
}, {
|
|
526
|
-
quoted: message
|
|
527
|
-
})
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
#### ๐ Location
|
|
531
|
-
|
|
532
|
-
```javascript
|
|
533
|
-
sock.sendMessage(jid, {
|
|
534
|
-
location: {
|
|
535
|
-
degreesLatitude: 24.121231,
|
|
536
|
-
degreesLongitude: 55.1121221,
|
|
537
|
-
name: '๐๐ป I am here'
|
|
538
|
-
}
|
|
539
|
-
}, {
|
|
540
|
-
quoted: message
|
|
541
|
-
})
|
|
542
|
-
```
|
|
543
|
-
|
|
544
|
-
#### ๐๏ธ Event
|
|
545
|
-
|
|
546
|
-
```javascript
|
|
547
|
-
sock.sendMessage(jid, {
|
|
548
|
-
event: {
|
|
549
|
-
name: '๐ถ Meet & Mingle Party',
|
|
550
|
-
description: 'Meet & Mingle Party is a fun, casual gathering to connect, chat, and build new relationships within the community.',
|
|
551
|
-
call: 'audio', // --- Or "video", this field is optional
|
|
552
|
-
startDate: new Date(Date.now() + 3600000),
|
|
553
|
-
endDate: new Date(Date.now() + 28800000),
|
|
554
|
-
isCancelled: false, // --- Optional
|
|
555
|
-
isScheduleCall: false, // --- Optional
|
|
556
|
-
extraGuestsAllowed: false, // --- Optional
|
|
557
|
-
location: {
|
|
558
|
-
name: 'Jakarta',
|
|
559
|
-
degreesLatitude: -6.2,
|
|
560
|
-
degreesLongitude: 106.8
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
}, {
|
|
564
|
-
quoted: message
|
|
565
|
-
})
|
|
566
|
-
```
|
|
567
|
-
|
|
568
|
-
#### ๐ฅ Group Invite
|
|
569
|
-
|
|
570
|
-
```javascript
|
|
571
|
-
const inviteCode = groupUrl
|
|
572
|
-
.split('chat.whatsapp.com/')[1]
|
|
573
|
-
?.split('?')[0]
|
|
574
|
-
|
|
575
|
-
const groupJid = '1201111111111@g.us'
|
|
576
|
-
const groupName = '@elfhkry666/baileys'
|
|
577
|
-
|
|
578
|
-
sock.sendMessage(jid, {
|
|
579
|
-
groupInvite: {
|
|
580
|
-
inviteCode,
|
|
581
|
-
inviteExpiration: Date.now() + 86400000,
|
|
582
|
-
text: '๐๐ป Hello, we invite you to join our group.',
|
|
583
|
-
jid: groupJid,
|
|
584
|
-
subject: groupName,
|
|
585
|
-
}
|
|
586
|
-
}, {
|
|
587
|
-
quoted: message
|
|
588
|
-
})
|
|
589
|
-
```
|
|
590
|
-
|
|
591
|
-
#### ๐๏ธ Product
|
|
592
|
-
|
|
593
|
-
```javascript
|
|
594
|
-
import { randomUUID } from 'crypto'
|
|
595
|
-
|
|
596
|
-
sock.sendMessage(jid, {
|
|
597
|
-
image: {
|
|
598
|
-
url: './path/to/image.jpg'
|
|
599
|
-
},
|
|
600
|
-
body: '๐๐ป Check my product here!',
|
|
601
|
-
footer: '@elfhkry666/baileys',
|
|
602
|
-
product: {
|
|
603
|
-
currencyCode: 'IDR',
|
|
604
|
-
description: '๐๏ธ Interesting product!',
|
|
605
|
-
priceAmount1000: 70_000_000,
|
|
606
|
-
productId: randomUUID(),
|
|
607
|
-
productImageCount: 1,
|
|
608
|
-
salePriceAmount1000: 65_000_000,
|
|
609
|
-
signedUrl: 'https://www.npmjs.com/package/@elfhkry666/baileys',
|
|
610
|
-
title: '๐ฆ Starseed (Premium)',
|
|
611
|
-
url: 'https://www.npmjs.com/package/@elfhkry666/baileys'
|
|
612
|
-
},
|
|
613
|
-
businessOwnerJid: '0@s.whatsapp.net'
|
|
614
|
-
})
|
|
615
|
-
```
|
|
616
|
-
|
|
617
|
-
#### ๐ Poll
|
|
618
|
-
|
|
619
|
-
```javascript
|
|
620
|
-
// --- Regular poll message
|
|
621
|
-
sock.sendMessage(jid, {
|
|
622
|
-
poll: {
|
|
623
|
-
name: '๐ฅ Voting time',
|
|
624
|
-
values: ['Yes', 'No'],
|
|
625
|
-
selectableCount: 1,
|
|
626
|
-
toAnnouncementGroup: false,
|
|
627
|
-
endDate: new Date(Date.now() + 28800000), // --- Optional
|
|
628
|
-
hideVoter: false, // --- Optional
|
|
629
|
-
canAddOption: false // --- Optional
|
|
630
|
-
}
|
|
631
|
-
}, {
|
|
632
|
-
quoted: message
|
|
633
|
-
})
|
|
634
|
-
|
|
635
|
-
// --- Quiz (only for newsletter)
|
|
636
|
-
sock.sendMessage('1211111111111@newsletter', {
|
|
637
|
-
poll: {
|
|
638
|
-
name: '๐ฅ Quiz',
|
|
639
|
-
values: ['Yes', 'No'],
|
|
640
|
-
correctAnswer: 'Yes',
|
|
641
|
-
pollType: 1
|
|
642
|
-
}
|
|
643
|
-
}, {
|
|
644
|
-
quoted: message
|
|
645
|
-
})
|
|
646
|
-
|
|
647
|
-
// --- Poll result
|
|
648
|
-
sock.sendMessage(jid, {
|
|
649
|
-
pollResult: {
|
|
650
|
-
name: '๐ Poll Result',
|
|
651
|
-
votes: [{
|
|
652
|
-
name: 'Nice',
|
|
653
|
-
voteCount: 10
|
|
654
|
-
}, {
|
|
655
|
-
name: 'Nah',
|
|
656
|
-
voteCount: 2
|
|
657
|
-
}],
|
|
658
|
-
pollType: 0 // Or 1 for quiz
|
|
659
|
-
}
|
|
660
|
-
}, {
|
|
661
|
-
quoted: message
|
|
662
|
-
})
|
|
663
|
-
|
|
664
|
-
// --- Poll update
|
|
665
|
-
sock.sendMessage(jid, {
|
|
666
|
-
pollUpdate: {
|
|
667
|
-
metadata: {},
|
|
668
|
-
key: message.key,
|
|
669
|
-
vote: {
|
|
670
|
-
enclv: /* <Buffer> */,
|
|
671
|
-
encPayload: /* <Buffer> */
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}, {
|
|
675
|
-
quoted: message
|
|
676
|
-
})
|
|
677
|
-
```
|
|
678
|
-
|
|
679
|
-
#### ๐ญ Button Response
|
|
680
|
-
|
|
681
|
-
```javascript
|
|
682
|
-
// --- Using buttonsResponseMessage
|
|
683
|
-
sock.sendMessage(jid, {
|
|
684
|
-
type: 'plain',
|
|
685
|
-
buttonReply: {
|
|
686
|
-
id: '#Menu',
|
|
687
|
-
displayText: 'โจ Interesting Menu'
|
|
688
|
-
}
|
|
689
|
-
}, {
|
|
690
|
-
quoted: message
|
|
691
|
-
})
|
|
692
|
-
|
|
693
|
-
// --- Using interactiveResponseMessage
|
|
694
|
-
sock.sendMessage(jid, {
|
|
695
|
-
flowReply: {
|
|
696
|
-
format: 0,
|
|
697
|
-
text: '๐ญ Response',
|
|
698
|
-
name: 'menu_options',
|
|
699
|
-
paramsJson: JSON.stringify({
|
|
700
|
-
id: '#Menu',
|
|
701
|
-
description: 'โจ Interesting Menu'
|
|
702
|
-
})
|
|
703
|
-
}
|
|
704
|
-
}, {
|
|
705
|
-
quoted: message
|
|
706
|
-
})
|
|
707
|
-
|
|
708
|
-
// --- Using listResponseMessage
|
|
709
|
-
sock.sendMessage(jid, {
|
|
710
|
-
listReply: {
|
|
711
|
-
title: '๐ See More',
|
|
712
|
-
description: 'โจ Interesting Menu',
|
|
713
|
-
id: '#Menu'
|
|
714
|
-
}
|
|
715
|
-
}, {
|
|
716
|
-
quoted: message
|
|
717
|
-
})
|
|
718
|
-
|
|
719
|
-
// --- Using templateButtonReplyMessage
|
|
720
|
-
sock.sendMessage(jid, {
|
|
721
|
-
type: 'template',
|
|
722
|
-
buttonReply: {
|
|
723
|
-
id: '#Menu',
|
|
724
|
-
displayText: 'โจ Interesting Menu',
|
|
725
|
-
index: 1
|
|
726
|
-
}
|
|
727
|
-
}, {
|
|
728
|
-
quoted: message
|
|
729
|
-
})
|
|
730
|
-
```
|
|
731
|
-
|
|
732
|
-
#### โจ Rich Response
|
|
733
|
-
|
|
734
|
-
> [!NOTE]
|
|
735
|
-
> `richResponse[]` is a representation of [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) inside `richResponseMessage`.
|
|
736
|
-
|
|
737
|
-
> [!TIP]
|
|
738
|
-
> You can still use the original [`submessages[]`](https://baileys.wiki/docs/api/namespaces/proto/interfaces/IAIRichResponseSubMessage) field directly.
|
|
739
|
-
> The code example below is just an implementation using a helper, not a required structure.
|
|
740
|
-
|
|
741
|
-
```javascript
|
|
742
|
-
sock.sendMessage(jid, {
|
|
743
|
-
disclaimerText: 'RAW submessages structure example',
|
|
744
|
-
richResponse: [{
|
|
745
|
-
text: 'Example Usage',
|
|
746
|
-
}, {
|
|
747
|
-
language: 'javascript',
|
|
748
|
-
code: [{
|
|
749
|
-
highlightType: 0,
|
|
750
|
-
codeContent: 'console.log("Hello, World!")'
|
|
751
|
-
}]
|
|
752
|
-
}, {
|
|
753
|
-
text: 'Pretty simple, right?\n'
|
|
754
|
-
}, {
|
|
755
|
-
text: 'Comparison between Node.js, Bun, and Deno',
|
|
756
|
-
}, {
|
|
757
|
-
title: 'Runtime Comparison',
|
|
758
|
-
table: [{
|
|
759
|
-
isHeading: true,
|
|
760
|
-
items: ['', 'Node.js', 'Bun', 'Deno']
|
|
761
|
-
}, {
|
|
762
|
-
isHeading: false,
|
|
763
|
-
items: ['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)']
|
|
764
|
-
}, {
|
|
765
|
-
isHeading: false,
|
|
766
|
-
items: ['Performance', '4/5', '5/5', '4/5']
|
|
767
|
-
}]
|
|
768
|
-
}, {
|
|
769
|
-
text: 'Does this help clarify the differences?'
|
|
770
|
-
}]
|
|
771
|
-
})
|
|
772
|
-
```
|
|
773
|
-
|
|
774
|
-
> [!TIP]
|
|
775
|
-
> You can easily add syntax highlighting by importing `tokenizeCode` directly from Baileys.
|
|
776
|
-
|
|
777
|
-
```javascript
|
|
778
|
-
import { tokenizeCode } from '@elfhkry666/baileys'
|
|
779
|
-
|
|
780
|
-
const language = 'javascript'
|
|
781
|
-
const code = 'console.log("Hello, World!")'
|
|
782
|
-
|
|
783
|
-
sock.sendMessage(jid, {
|
|
784
|
-
disclaimerText: 'Example of tokenizing Code Block',
|
|
785
|
-
richResponse: [{
|
|
786
|
-
text: 'Example Usage',
|
|
787
|
-
}, {
|
|
788
|
-
language,
|
|
789
|
-
code: tokenizeCode(code, language)
|
|
790
|
-
}, {
|
|
791
|
-
text: 'Pretty simple, right?'
|
|
792
|
-
}]
|
|
793
|
-
})
|
|
794
|
-
```
|
|
795
|
-
|
|
796
|
-
> ๐ก Supported Languages: `css`, `html`, `javascript`, `typescript`, `python`, `golang`, `rust`, `c`, `c#`, `c++`, `bash`, `bat`, `powershell`.
|
|
797
|
-
|
|
798
|
-
#### ๐งพ Message with Code Block
|
|
799
|
-
|
|
800
|
-
> [!NOTE]
|
|
801
|
-
> This feature already includes a built-in tokenizer with `tokenizeCode`.
|
|
802
|
-
|
|
803
|
-
```javascript
|
|
804
|
-
sock.sendMessage(jid, {
|
|
805
|
-
disclaimerText: 'Code Block',
|
|
806
|
-
headerText: '## Example Usage',
|
|
807
|
-
contentText: '---',
|
|
808
|
-
code: 'console.log("Hello, World!")',
|
|
809
|
-
language: 'javascript',
|
|
810
|
-
footerText: 'Pretty simple, right?'
|
|
811
|
-
})
|
|
812
|
-
```
|
|
813
|
-
|
|
814
|
-
#### ๐ Message with Inline Entities
|
|
815
|
-
|
|
816
|
-
```javascript
|
|
817
|
-
sock.sendMessage(jid, {
|
|
818
|
-
disclaimerText: 'Inline Entities',
|
|
819
|
-
headerText: '## Check Out!',
|
|
820
|
-
contentText: '---',
|
|
821
|
-
links: [{
|
|
822
|
-
text: '1. Google',
|
|
823
|
-
title: 'Popular Search Engine',
|
|
824
|
-
url: 'https://www.google.com/'
|
|
825
|
-
}, {
|
|
826
|
-
text: '2. YouTube',
|
|
827
|
-
title: 'Popular Streaming Platform',
|
|
828
|
-
url: 'https://www.youtube.com/'
|
|
829
|
-
}, {
|
|
830
|
-
text: '3. Modded Baileys',
|
|
831
|
-
title: 'Underrated Baileys Fork',
|
|
832
|
-
url: 'https://www.npmjs.com/package/@elfhkry666/baileys'
|
|
833
|
-
}],
|
|
834
|
-
footerText: '---'
|
|
835
|
-
})
|
|
836
|
-
```
|
|
837
|
-
|
|
838
|
-
#### ๐ Message with Table
|
|
839
|
-
|
|
840
|
-
```javascript
|
|
841
|
-
sock.sendMessage(jid, {
|
|
842
|
-
disclaimerText: 'Table',
|
|
843
|
-
headerText: '## Comparison between Node.js, Bun, and Deno',
|
|
844
|
-
contentText: '---',
|
|
845
|
-
title: 'Runtime Comparison',
|
|
846
|
-
table: [
|
|
847
|
-
['', 'Node.js', 'Bun', 'Deno'],
|
|
848
|
-
['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)'],
|
|
849
|
-
['Performance', '4/5', '5/5', '4/5']
|
|
850
|
-
],
|
|
851
|
-
noHeading: false, // --- Optional
|
|
852
|
-
footerText: 'Does this help clarify the differences?'
|
|
853
|
-
})
|
|
854
|
-
```
|
|
855
|
-
|
|
856
|
-
#### ๐๏ธ Status Mention
|
|
857
|
-
|
|
858
|
-
```javascript
|
|
859
|
-
sock.sendMessage([jidA, jidB, jidC], {
|
|
860
|
-
text: 'Hello! ๐๐ป'
|
|
861
|
-
})
|
|
862
|
-
```
|
|
863
|
-
|
|
864
|
-
### ๐ Sending Media Messages
|
|
865
|
-
|
|
866
|
-
> [!NOTE]
|
|
867
|
-
> For media messages, you can pass a `Buffer` directly, or an object with either `{ stream: Readable }` or `{ url: string }` (local file path or HTTP/HTTPS URL).
|
|
868
|
-
|
|
869
|
-
#### ๐ผ๏ธ Image
|
|
870
|
-
|
|
871
|
-
```javascript
|
|
872
|
-
sock.sendMessage(jid, {
|
|
873
|
-
image: {
|
|
874
|
-
url: './path/to/image.jpg'
|
|
875
|
-
},
|
|
876
|
-
caption: '๐ฅ Superb'
|
|
877
|
-
}, {
|
|
878
|
-
quoted: message
|
|
879
|
-
})
|
|
880
|
-
```
|
|
881
|
-
|
|
882
|
-
#### ๐ฅ Video
|
|
883
|
-
|
|
884
|
-
```javascript
|
|
885
|
-
sock.sendMessage(jid, {
|
|
886
|
-
video: {
|
|
887
|
-
url: './path/to/video.mp4'
|
|
888
|
-
},
|
|
889
|
-
gifPlayback: false, // --- Set true if you want to send video as GIF
|
|
890
|
-
ptv: false, // --- Set true if you want to send video as PTV
|
|
891
|
-
caption: '๐ฅ Superb'
|
|
892
|
-
}, {
|
|
893
|
-
quoted: message
|
|
894
|
-
})
|
|
895
|
-
```
|
|
896
|
-
|
|
897
|
-
#### ๐ Sticker
|
|
898
|
-
|
|
899
|
-
```javascript
|
|
900
|
-
sock.sendMessage(jid, {
|
|
901
|
-
sticker: {
|
|
902
|
-
url: './path/to/sticker.webp'
|
|
903
|
-
}
|
|
904
|
-
}, {
|
|
905
|
-
quoted: message
|
|
906
|
-
})
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
#### ๐ฝ Audio
|
|
910
|
-
|
|
911
|
-
```javascript
|
|
912
|
-
sock.sendMessage(jid, {
|
|
913
|
-
audio: {
|
|
914
|
-
url: './path/to/audio.mp3'
|
|
915
|
-
},
|
|
916
|
-
ptt: false // --- Set true if you want to send audio as Voice Note
|
|
917
|
-
}, {
|
|
918
|
-
quoted: message
|
|
919
|
-
})
|
|
920
|
-
```
|
|
921
|
-
|
|
922
|
-
#### ๐๏ธ Document
|
|
923
|
-
|
|
924
|
-
```javascript
|
|
925
|
-
sock.sendMessage(jid, {
|
|
926
|
-
document: {
|
|
927
|
-
url: './path/to/document.pdf'
|
|
928
|
-
},
|
|
929
|
-
mimetype: 'application/pdf',
|
|
930
|
-
caption: 'โจ My work!'
|
|
931
|
-
}, {
|
|
932
|
-
quoted: message
|
|
933
|
-
})
|
|
934
|
-
```
|
|
935
|
-
|
|
936
|
-
#### ๐ผ๏ธ Album (Image & Video)
|
|
937
|
-
|
|
938
|
-
```javascript
|
|
939
|
-
sock.sendMessage(jid, {
|
|
940
|
-
album: [{
|
|
941
|
-
image: {
|
|
942
|
-
url: './path/to/image.jpg'
|
|
943
|
-
},
|
|
944
|
-
caption: '1st image'
|
|
945
|
-
}, {
|
|
946
|
-
video: {
|
|
947
|
-
url: './path/to/video.mp4'
|
|
948
|
-
},
|
|
949
|
-
caption: '1st video'
|
|
950
|
-
}, {
|
|
951
|
-
image: {
|
|
952
|
-
url: './path/to/image.jpg'
|
|
953
|
-
},
|
|
954
|
-
caption: '2nd image'
|
|
955
|
-
}, {
|
|
956
|
-
video: {
|
|
957
|
-
url: './path/to/video.mp4'
|
|
958
|
-
},
|
|
959
|
-
caption: '2nd video'
|
|
960
|
-
}]
|
|
961
|
-
}, {
|
|
962
|
-
quoted: message
|
|
963
|
-
})
|
|
964
|
-
```
|
|
965
|
-
|
|
966
|
-
#### ๐ฆ Sticker Pack
|
|
967
|
-
|
|
968
|
-
> [!IMPORTANT]
|
|
969
|
-
> If `sharp` or `@napi-rs/image` is not installed, the `cover` and `stickers` must already be in WebP format.
|
|
970
|
-
|
|
971
|
-
```javascript
|
|
972
|
-
sock.sendMessage(jid, {
|
|
973
|
-
cover: {
|
|
974
|
-
url: './path/to/image.webp'
|
|
975
|
-
},
|
|
976
|
-
stickers: [{
|
|
977
|
-
data: {
|
|
978
|
-
url: './path/to/image.webp'
|
|
979
|
-
}
|
|
980
|
-
}, {
|
|
981
|
-
data: {
|
|
982
|
-
url: './path/to/image.webp'
|
|
983
|
-
}
|
|
984
|
-
}, {
|
|
985
|
-
data: {
|
|
986
|
-
url: './path/to/image.webp'
|
|
987
|
-
}
|
|
988
|
-
}],
|
|
989
|
-
name: '๐ฆ My Sticker Pack',
|
|
990
|
-
publisher: '๐ Fhkry',
|
|
991
|
-
description: '@elfhkry666/baileys'
|
|
992
|
-
}, {
|
|
993
|
-
quoted: message
|
|
994
|
-
})
|
|
995
|
-
```
|
|
996
|
-
|
|
997
|
-
### ๐๐ป Sending Interactive Messages
|
|
998
|
-
|
|
999
|
-
#### ๐ Buttons
|
|
1000
|
-
|
|
1001
|
-
```javascript
|
|
1002
|
-
// --- Regular buttons message
|
|
1003
|
-
sock.sendMessage(jid, {
|
|
1004
|
-
text: '๐๐ป Buttons!',
|
|
1005
|
-
footer: '@elfhkry666/baileys',
|
|
1006
|
-
buttons: [{
|
|
1007
|
-
text: '๐๐ป SignUp',
|
|
1008
|
-
id: '#SignUp'
|
|
1009
|
-
}]
|
|
1010
|
-
}, {
|
|
1011
|
-
quoted: message
|
|
1012
|
-
})
|
|
1013
|
-
|
|
1014
|
-
// --- Buttons with Media & Native Flow
|
|
1015
|
-
sock.sendMessage(jid, {
|
|
1016
|
-
image: {
|
|
1017
|
-
url: './path/to/image.jpg'
|
|
1018
|
-
},
|
|
1019
|
-
caption: '๐๐ป Buttons and Native Flow!',
|
|
1020
|
-
footer: '@elfhkry666/baileys',
|
|
1021
|
-
buttons: [{
|
|
1022
|
-
text: '๐๐ป Rating',
|
|
1023
|
-
id: '#Rating'
|
|
1024
|
-
}, {
|
|
1025
|
-
text: '๐ Select',
|
|
1026
|
-
sections: [{
|
|
1027
|
-
title: 'โจ Section 1',
|
|
1028
|
-
rows: [{
|
|
1029
|
-
header: '',
|
|
1030
|
-
title: '๐ญ Secret Ingredient',
|
|
1031
|
-
description: '',
|
|
1032
|
-
id: '#SecretIngredient'
|
|
1033
|
-
}]
|
|
1034
|
-
}, {
|
|
1035
|
-
title: 'โจ Section 2',
|
|
1036
|
-
highlight_label: '๐ฅ Popular',
|
|
1037
|
-
rows: [{
|
|
1038
|
-
header: '',
|
|
1039
|
-
title: '๐ท๏ธ Coupon',
|
|
1040
|
-
description: '',
|
|
1041
|
-
id: '#CouponCode'
|
|
1042
|
-
}]
|
|
1043
|
-
}]
|
|
1044
|
-
}]
|
|
1045
|
-
}, {
|
|
1046
|
-
quoted: message
|
|
1047
|
-
})
|
|
1048
|
-
```
|
|
1049
|
-
|
|
1050
|
-
#### ๐ List
|
|
1051
|
-
|
|
1052
|
-
> [!NOTE]
|
|
1053
|
-
> It only works in private chat (`@s.whatsapp.net`).
|
|
1054
|
-
|
|
1055
|
-
```javascript
|
|
1056
|
-
sock.sendMessage(jid, {
|
|
1057
|
-
text: '๐ List!',
|
|
1058
|
-
footer: '@elfhkry666/baileys',
|
|
1059
|
-
buttonText: '๐ Select',
|
|
1060
|
-
title: '๐๐ป Hello',
|
|
1061
|
-
sections: [{
|
|
1062
|
-
title: '๐ Menu 1',
|
|
1063
|
-
rows: [{
|
|
1064
|
-
title: 'โจ AI',
|
|
1065
|
-
description: '',
|
|
1066
|
-
rowId: '#AI'
|
|
1067
|
-
}]
|
|
1068
|
-
}, {
|
|
1069
|
-
title: '๐ฑ Menu 2',
|
|
1070
|
-
rows: [{
|
|
1071
|
-
title: '๐ Search',
|
|
1072
|
-
description: '',
|
|
1073
|
-
rowId: '#Search'
|
|
1074
|
-
}]
|
|
1075
|
-
}]
|
|
1076
|
-
}, {
|
|
1077
|
-
quoted: message
|
|
1078
|
-
})
|
|
1079
|
-
```
|
|
1080
|
-
|
|
1081
|
-
#### ๐๏ธ Interactive
|
|
1082
|
-
|
|
1083
|
-
```javascript
|
|
1084
|
-
// --- Native Flow
|
|
1085
|
-
sock.sendMessage(jid, {
|
|
1086
|
-
image: {
|
|
1087
|
-
url: './path/to/image.jpg'
|
|
1088
|
-
},
|
|
1089
|
-
caption: '๐๏ธ๏ธ Interactive!',
|
|
1090
|
-
footer: '@elfhkry666/baileys',
|
|
1091
|
-
optionText: '๐๐ป Select Options', // --- Optional, wrap all native flow into a single list
|
|
1092
|
-
optionTitle: '๐ Select Options', // --- Optional
|
|
1093
|
-
offerText: '๐ท๏ธ Newest Coupon!', // --- Optional, add an offer into message
|
|
1094
|
-
offerCode: '@elfhkry666/baileys', // --- Optional
|
|
1095
|
-
offerUrl: 'https://www.npmjs.com/package/@elfhkry666/baileys', // --- Optional
|
|
1096
|
-
offerExpiration: Date.now() + 3_600_000, // --- Optional
|
|
1097
|
-
nativeFlow: [{
|
|
1098
|
-
text: '๐๐ป Greeting',
|
|
1099
|
-
id: '#Greeting',
|
|
1100
|
-
icon: 'review' // --- Optional
|
|
1101
|
-
}, {
|
|
1102
|
-
text: '๐ Call',
|
|
1103
|
-
call: '628123456789'
|
|
1104
|
-
}, {
|
|
1105
|
-
text: '๐ Copy',
|
|
1106
|
-
copy: '@elfhkry666/baileys'
|
|
1107
|
-
}, {
|
|
1108
|
-
text: '๐ Source',
|
|
1109
|
-
url: 'https://www.npmjs.com/package/@elfhkry666/baileys',
|
|
1110
|
-
useWebview: true // --- Optional
|
|
1111
|
-
}, {
|
|
1112
|
-
text: '๐ Select',
|
|
1113
|
-
sections: [{
|
|
1114
|
-
title: 'โจ Section 1',
|
|
1115
|
-
rows: [{
|
|
1116
|
-
header: '',
|
|
1117
|
-
title: '๐ท๏ธ Coupon',
|
|
1118
|
-
description: '',
|
|
1119
|
-
id: '#CouponCode'
|
|
1120
|
-
}]
|
|
1121
|
-
}, {
|
|
1122
|
-
title: 'โจ Section 2',
|
|
1123
|
-
highlight_label: '๐ฅ Popular',
|
|
1124
|
-
rows: [{
|
|
1125
|
-
header: '',
|
|
1126
|
-
title: '๐ญ Secret Ingredient',
|
|
1127
|
-
description: '',
|
|
1128
|
-
id: '#SecretIngredient'
|
|
1129
|
-
}]
|
|
1130
|
-
}],
|
|
1131
|
-
icon: 'default' // --- Optional
|
|
1132
|
-
}],
|
|
1133
|
-
interactiveAsTemplate: false, // --- Optional, wrap the interactive message into a template
|
|
1134
|
-
}, {
|
|
1135
|
-
quoted: message
|
|
1136
|
-
})
|
|
1137
|
-
|
|
1138
|
-
// --- Carousel & Native Flow
|
|
1139
|
-
sock.sendMessage(jid, {
|
|
1140
|
-
text: '๐๏ธ Interactive with Carousel!',
|
|
1141
|
-
footer: '@elfhkry666/baileys',
|
|
1142
|
-
cards: [{
|
|
1143
|
-
image: {
|
|
1144
|
-
url: './path/to/image.jpg'
|
|
1145
|
-
},
|
|
1146
|
-
caption: '๐ผ๏ธ Image 1',
|
|
1147
|
-
footer: '๐ท๏ธ๏ธ Pinterest',
|
|
1148
|
-
nativeFlow: [{
|
|
1149
|
-
text: '๐ Source',
|
|
1150
|
-
url: 'https://www.npmjs.com/package/@elfhkry666/baileys',
|
|
1151
|
-
useWebview: true
|
|
1152
|
-
}]
|
|
1153
|
-
}, {
|
|
1154
|
-
image: {
|
|
1155
|
-
url: './path/to/image.jpg'
|
|
1156
|
-
},
|
|
1157
|
-
caption: '๐ผ๏ธ Image 2',
|
|
1158
|
-
footer: '๐ท๏ธ Pinterest',
|
|
1159
|
-
offerText: '๐ท๏ธ New Coupon!',
|
|
1160
|
-
offerCode: '@elfhkry666/baileys',
|
|
1161
|
-
offerUrl: 'https://www.npmjs.com/package/@elfhkry666/baileys',
|
|
1162
|
-
offerExpiration: Date.now() + 3_600_000,
|
|
1163
|
-
nativeFlow: [{
|
|
1164
|
-
text: '๐ Source',
|
|
1165
|
-
url: 'https://www.npmjs.com/package/@elfhkry666/baileys'
|
|
1166
|
-
}]
|
|
1167
|
-
}, {
|
|
1168
|
-
image: {
|
|
1169
|
-
url: './path/to/image.jpg'
|
|
1170
|
-
},
|
|
1171
|
-
caption: '๐ผ๏ธ Image 3',
|
|
1172
|
-
footer: '๐ท๏ธ Pinterest',
|
|
1173
|
-
optionText: '๐๐ป Select Options',
|
|
1174
|
-
optionTitle: '๐๐ป Select Options',
|
|
1175
|
-
offerText: '๐ท๏ธ New Coupon!',
|
|
1176
|
-
offerCode: '@elfhkry666/baileys',
|
|
1177
|
-
offerUrl: 'https://www.npmjs.com/package/@elfhkry666/baileys',
|
|
1178
|
-
offerExpiration: Date.now() + 3_600_000,
|
|
1179
|
-
nativeFlow: [{
|
|
1180
|
-
text: '๐ Product',
|
|
1181
|
-
id: '#Product',
|
|
1182
|
-
icon: 'default'
|
|
1183
|
-
}, {
|
|
1184
|
-
text: '๐ Source',
|
|
1185
|
-
url: 'https://www.npmjs.com/package/@elfhkry666/baileys'
|
|
1186
|
-
}]
|
|
1187
|
-
}]
|
|
1188
|
-
}, {
|
|
1189
|
-
quoted: message
|
|
1190
|
-
})
|
|
1191
|
-
|
|
1192
|
-
// --- Native Flow with Audio in the Footer
|
|
1193
|
-
sock.sendMessage(jid, {
|
|
1194
|
-
text: '๐ Music in the footer!',
|
|
1195
|
-
audioFooter: {
|
|
1196
|
-
url: './path/to/audio.mp3'
|
|
1197
|
-
}, // --- Like other media upload methods, buffers and streams are supported
|
|
1198
|
-
nativeFlow: [{
|
|
1199
|
-
text: '๐๐ป Good, next',
|
|
1200
|
-
id: '#Next',
|
|
1201
|
-
icon: 'review'
|
|
1202
|
-
}, {
|
|
1203
|
-
text: '๐๐ป Skip',
|
|
1204
|
-
id: '#Skip',
|
|
1205
|
-
icon: 'default'
|
|
1206
|
-
}]
|
|
1207
|
-
}, {
|
|
1208
|
-
quoted: message
|
|
1209
|
-
})
|
|
1210
|
-
```
|
|
1211
|
-
|
|
1212
|
-
#### ๐ซ Hydrated Template
|
|
1213
|
-
|
|
1214
|
-
```javascript
|
|
1215
|
-
sock.sendMessage(jid, {
|
|
1216
|
-
title: '๐๐ป Hello',
|
|
1217
|
-
image: {
|
|
1218
|
-
url: './path/to/image.jpg'
|
|
1219
|
-
},
|
|
1220
|
-
caption: '๐ซ Template!',
|
|
1221
|
-
footer: '@elfhkry666/baileys',
|
|
1222
|
-
templateButtons: [{
|
|
1223
|
-
text: '๐๐ป Tap Here',
|
|
1224
|
-
id: '#Order'
|
|
1225
|
-
}, {
|
|
1226
|
-
text: '๐ Source',
|
|
1227
|
-
url: 'https://www.npmjs.com/package/@elfhkry666/baileys'
|
|
1228
|
-
}, {
|
|
1229
|
-
text: '๐ Call',
|
|
1230
|
-
call: '628123456789'
|
|
1231
|
-
}]
|
|
1232
|
-
}, {
|
|
1233
|
-
quoted: message
|
|
1234
|
-
})
|
|
1235
|
-
```
|
|
1236
|
-
|
|
1237
|
-
### ๐ณ Sending Payment Messages
|
|
1238
|
-
|
|
1239
|
-
#### โ Invite Payment
|
|
1240
|
-
|
|
1241
|
-
```javascript
|
|
1242
|
-
sock.sendMessage(jid, {
|
|
1243
|
-
paymentInviteServiceType: 3 // 1, 2, or 3
|
|
1244
|
-
})
|
|
1245
|
-
```
|
|
1246
|
-
|
|
1247
|
-
#### ๐งพ Invoice
|
|
1248
|
-
|
|
1249
|
-
> [!NOTE]
|
|
1250
|
-
> Invoice message are not supported yet.
|
|
1251
|
-
|
|
1252
|
-
```javascript
|
|
1253
|
-
sock.sendMessage(jid, {
|
|
1254
|
-
image: {
|
|
1255
|
-
url: './path/to/image.jpg'
|
|
1256
|
-
},
|
|
1257
|
-
invoiceNote: '๐ท๏ธ Invoice'
|
|
1258
|
-
})
|
|
1259
|
-
```
|
|
1260
|
-
|
|
1261
|
-
#### ๐๏ธ Order
|
|
1262
|
-
|
|
1263
|
-
```javascript
|
|
1264
|
-
sock.sendMessage(chat, {
|
|
1265
|
-
orderText: '๐๏ธ Order',
|
|
1266
|
-
thumbnail: fs.readFileSync('./path/to/image.jpg') // --- Must in buffer format
|
|
1267
|
-
}, {
|
|
1268
|
-
quoted: message
|
|
1269
|
-
})
|
|
1270
|
-
```
|
|
1271
|
-
|
|
1272
|
-
#### ๐ณ Request Payment
|
|
1273
|
-
|
|
1274
|
-
```javascript
|
|
1275
|
-
sock.sendMessage(jid, {
|
|
1276
|
-
text: '๐ณ Request Payment',
|
|
1277
|
-
requestPaymentFrom: '0@s.whatsapp.net'
|
|
1278
|
-
})
|
|
1279
|
-
```
|
|
1280
|
-
|
|
1281
|
-
### ๐๏ธ Other Message Options
|
|
1282
|
-
|
|
1283
|
-
#### ๐ค AI Icon
|
|
1284
|
-
|
|
1285
|
-
> [!NOTE]
|
|
1286
|
-
> It only works in private chat (`@s.whatsapp.net`).
|
|
1287
|
-
|
|
1288
|
-
```javascript
|
|
1289
|
-
sock.sendMessage(jid, {
|
|
1290
|
-
image: {
|
|
1291
|
-
url: './path/to/image.jpg'
|
|
1292
|
-
},
|
|
1293
|
-
caption: '๐ค With AI icon!',
|
|
1294
|
-
ai: true
|
|
1295
|
-
}, {
|
|
1296
|
-
quoted: message
|
|
1297
|
-
})
|
|
1298
|
-
```
|
|
1299
|
-
|
|
1300
|
-
#### ๐ Ephemeral
|
|
1301
|
-
|
|
1302
|
-
> [!NOTE]
|
|
1303
|
-
> Wrap message into `ephemeralMessage`
|
|
1304
|
-
|
|
1305
|
-
```javascript
|
|
1306
|
-
sock.sendMessage(jid, {
|
|
1307
|
-
image: {
|
|
1308
|
-
url: './path/to/image.jpg'
|
|
1309
|
-
},
|
|
1310
|
-
caption: '๐๏ธ Ephemeral',
|
|
1311
|
-
ephemeral: true
|
|
1312
|
-
})
|
|
1313
|
-
```
|
|
1314
|
-
|
|
1315
|
-
#### ๐ฐ External Ad Reply
|
|
1316
|
-
|
|
1317
|
-
> [!NOTE]
|
|
1318
|
-
> Add an ad thumbnail to messages (may not be displayed on some WhatsApp versions).
|
|
1319
|
-
|
|
1320
|
-
```javascript
|
|
1321
|
-
sock.sendMessage(jid, {
|
|
1322
|
-
text: '๐ฐ External Ad Reply',
|
|
1323
|
-
externalAdReply: {
|
|
1324
|
-
title: '๐ Did you know?',
|
|
1325
|
-
body: 'โ I dont know',
|
|
1326
|
-
thumbnail: fs.readFileSync('./path/to/image.jpg'), // --- Must in buffer format
|
|
1327
|
-
largeThumbnail: false, // --- Or true for bigger thumbnail
|
|
1328
|
-
url: 'https://www.npmjs.com/package/@elfhkry666/baileys' // --- Optional, used for WhatsApp internal thumbnail caching and direct URL
|
|
1329
|
-
}
|
|
1330
|
-
}, {
|
|
1331
|
-
quoted: message
|
|
1332
|
-
})
|
|
1333
|
-
```
|
|
1334
|
-
|
|
1335
|
-
#### ๐งโ๐งโ๐ง Group Status
|
|
1336
|
-
|
|
1337
|
-
> [!NOTE]
|
|
1338
|
-
> It only works in group chat (`@g.us`)
|
|
1339
|
-
|
|
1340
|
-
```javascript
|
|
1341
|
-
sock.sendMessage(jid, {
|
|
1342
|
-
image: {
|
|
1343
|
-
url: './path/to/image.jpg'
|
|
1344
|
-
},
|
|
1345
|
-
caption: '๐ฅ Group Status!',
|
|
1346
|
-
groupStatus: true
|
|
1347
|
-
})
|
|
1348
|
-
```
|
|
1349
|
-
|
|
1350
|
-
#### ๐ฑ Lottie Sticker
|
|
1351
|
-
|
|
1352
|
-
> [!NOTE]
|
|
1353
|
-
> Wrap message into `lottieStickerMessage`
|
|
1354
|
-
|
|
1355
|
-
```javascript
|
|
1356
|
-
sock.sendMessage(jid, {
|
|
1357
|
-
sticker: {
|
|
1358
|
-
url: './path/to/sticker.webp'
|
|
1359
|
-
},
|
|
1360
|
-
isLottie: true
|
|
1361
|
-
})
|
|
1362
|
-
```
|
|
1363
|
-
|
|
1364
|
-
#### ๐งฉ Raw
|
|
1365
|
-
|
|
1366
|
-
```javascript
|
|
1367
|
-
sock.sendMessage(jid, {
|
|
1368
|
-
extendedTextMessage: {
|
|
1369
|
-
text: '๐ Built manually from scratch using the raw WhatsApp proto structure',
|
|
1370
|
-
contextInfo: {
|
|
1371
|
-
externalAdReply: {
|
|
1372
|
-
title: '@elfhkry666/baileys',
|
|
1373
|
-
thumbnail: fs.readFileSync('./path/to/image.jpg'),
|
|
1374
|
-
sourceApp: 'whatsapp',
|
|
1375
|
-
showAdAttribution: true,
|
|
1376
|
-
mediaType: 1
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
},
|
|
1380
|
-
raw: true
|
|
1381
|
-
}, {
|
|
1382
|
-
quoted: message
|
|
1383
|
-
})
|
|
1384
|
-
```
|
|
1385
|
-
|
|
1386
|
-
#### ๐ท๏ธ Secure Meta Service Label
|
|
1387
|
-
|
|
1388
|
-
```javascript
|
|
1389
|
-
sock.sendMessage(jid, {
|
|
1390
|
-
text: '๐ท๏ธ Just a label!',
|
|
1391
|
-
secureMetaServiceLabel: true
|
|
1392
|
-
})
|
|
1393
|
-
```
|
|
1394
|
-
|
|
1395
|
-
#### ๐ Spoiler
|
|
1396
|
-
|
|
1397
|
-
> [!NOTE]
|
|
1398
|
-
> Wrap message into `spoilerMessage`
|
|
1399
|
-
|
|
1400
|
-
```javascript
|
|
1401
|
-
sock.sendMessage(jid, {
|
|
1402
|
-
image: {
|
|
1403
|
-
url: './path/to/image.jpg'
|
|
1404
|
-
},
|
|
1405
|
-
caption: 'โ Spoiler',
|
|
1406
|
-
spoiler: true
|
|
1407
|
-
})
|
|
1408
|
-
```
|
|
1409
|
-
|
|
1410
|
-
#### ๐๏ธ View Once
|
|
1411
|
-
|
|
1412
|
-
> [!NOTE]
|
|
1413
|
-
> Wrap message into `viewOnceMessage`
|
|
1414
|
-
|
|
1415
|
-
```javascript
|
|
1416
|
-
sock.sendMessage(jid, {
|
|
1417
|
-
image: {
|
|
1418
|
-
url: './path/to/image.jpg'
|
|
1419
|
-
},
|
|
1420
|
-
caption: '๐๏ธ View Once',
|
|
1421
|
-
viewOnce: true
|
|
1422
|
-
})
|
|
1423
|
-
```
|
|
1424
|
-
|
|
1425
|
-
#### ๐๏ธ View Once V2
|
|
1426
|
-
|
|
1427
|
-
> [!NOTE]
|
|
1428
|
-
> Wrap message into `viewOnceMessageV2`
|
|
1429
|
-
|
|
1430
|
-
```javascript
|
|
1431
|
-
sock.sendMessage(jid, {
|
|
1432
|
-
image: {
|
|
1433
|
-
url: './path/to/image.jpg'
|
|
1434
|
-
},
|
|
1435
|
-
caption: '๐๏ธ View Once V2',
|
|
1436
|
-
viewOnceV2: true
|
|
1437
|
-
})
|
|
1438
|
-
```
|
|
1439
|
-
|
|
1440
|
-
#### ๐๏ธ View Once V2 Extension
|
|
1441
|
-
|
|
1442
|
-
> [!NOTE]
|
|
1443
|
-
> Wrap message into `viewOnceMessageV2Extension`
|
|
1444
|
-
|
|
1445
|
-
```javascript
|
|
1446
|
-
sock.sendMessage(jid, {
|
|
1447
|
-
image: {
|
|
1448
|
-
url: './path/to/image.jpg'
|
|
1449
|
-
},
|
|
1450
|
-
caption: '๐๏ธ View Once V2 Extension',
|
|
1451
|
-
viewOnceV2Extension: true
|
|
1452
|
-
})
|
|
1453
|
-
```
|
|
1454
|
-
|
|
1455
|
-
### โป๏ธ Modify Messages
|
|
1456
|
-
|
|
1457
|
-
#### ๐๏ธ Delete Messages
|
|
1458
|
-
|
|
1459
|
-
```javascript
|
|
1460
|
-
sock.sendMessage(jid, {
|
|
1461
|
-
delete: message.key
|
|
1462
|
-
})
|
|
1463
|
-
```
|
|
1464
|
-
|
|
1465
|
-
#### โ๏ธ Edit Messages
|
|
1466
|
-
|
|
1467
|
-
```javascript
|
|
1468
|
-
// --- Edit plain text
|
|
1469
|
-
sock.sendMessage(jid, {
|
|
1470
|
-
text: 'โจ I mean, nice!',
|
|
1471
|
-
edit: message.key
|
|
1472
|
-
})
|
|
1473
|
-
|
|
1474
|
-
// --- Edit media messages caption
|
|
1475
|
-
sock.sendMessage(jid, {
|
|
1476
|
-
caption: 'โจ I mean, here is the image!',
|
|
1477
|
-
edit: message.key
|
|
1478
|
-
})
|
|
1479
|
-
```
|
|
1480
|
-
|
|
1481
|
-
### ๐งฐ Additional Contents
|
|
1482
|
-
|
|
1483
|
-
#### ๐ท๏ธ Find User ID (JID|PN/LID)
|
|
1484
|
-
|
|
1485
|
-
> [!NOTE]
|
|
1486
|
-
> The ID must contain numbers only (no +, (), or -) and must include the country code with WhatsApp ID format.
|
|
1487
|
-
|
|
1488
|
-
```javascript
|
|
1489
|
-
// --- PN (Phone Number)
|
|
1490
|
-
const phoneNumber = '6281111111111@s.whatsapp.net'
|
|
1491
|
-
|
|
1492
|
-
const ids = await sock.findUserId(phoneNumber)
|
|
1493
|
-
|
|
1494
|
-
console.log('๐ท๏ธ Got user ID', ':', ids)
|
|
1495
|
-
|
|
1496
|
-
// --- LID (Local Identifier)
|
|
1497
|
-
const lid = '43411111111111@lid'
|
|
1498
|
-
|
|
1499
|
-
const ids = await sock.findUserId(lid)
|
|
1500
|
-
|
|
1501
|
-
console.log('๐ท๏ธ Got user ID', ':', ids)
|
|
1502
|
-
|
|
1503
|
-
// --- Output
|
|
1504
|
-
// {
|
|
1505
|
-
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
1506
|
-
// lid: '43411111111111@lid'
|
|
1507
|
-
// }
|
|
1508
|
-
// --- Output when failed
|
|
1509
|
-
// {
|
|
1510
|
-
// phoneNumber: '6281111111111@s.whatsapp.net',
|
|
1511
|
-
// lid: undefined
|
|
1512
|
-
// }
|
|
1513
|
-
// --- Same output shape regardless of input type
|
|
1514
|
-
```
|
|
1515
|
-
|
|
1516
|
-
#### ๐ Request Custom Pairing Code
|
|
1517
|
-
|
|
1518
|
-
> [!NOTE]
|
|
1519
|
-
> The phone number must contain numbers only (no +, (), or -) and must include the country code.
|
|
1520
|
-
|
|
1521
|
-
```javascript
|
|
1522
|
-
const phoneNumber = '6281111111111'
|
|
1523
|
-
const customPairingCode = 'STARFALL'
|
|
1524
|
-
|
|
1525
|
-
await sock.requestPairingCode(phoneNumber, customPairingCode)
|
|
1526
|
-
|
|
1527
|
-
console.log('๐ Pairing code', ':', customPairingCode)
|
|
1528
|
-
```
|
|
1529
|
-
|
|
1530
|
-
#### ๐ผ๏ธ Image Processing
|
|
1531
|
-
|
|
1532
|
-
> [!NOTE]
|
|
1533
|
-
> Automatically use available image processing library: `sharp`, `@napi-rs/image`, or `jimp`
|
|
1534
|
-
|
|
1535
|
-
```javascript
|
|
1536
|
-
import { getImageProcessingLibrary } from '@elfhkry666/baileys'
|
|
1537
|
-
import { readFile } from 'fs/promises'
|
|
1538
|
-
|
|
1539
|
-
const lib = await getImageProcessingLibrary()
|
|
1540
|
-
|
|
1541
|
-
const bufferOrFilePath = './path/to/image.jpg'
|
|
1542
|
-
const width = 512
|
|
1543
|
-
|
|
1544
|
-
let output
|
|
1545
|
-
|
|
1546
|
-
// --- If sharp installed
|
|
1547
|
-
if (lib.sharp?.default) {
|
|
1548
|
-
const img = lib.sharp.default(bufferOrFilePath)
|
|
1549
|
-
|
|
1550
|
-
output = await img.resize(width)
|
|
1551
|
-
.jpeg({ quality: 80 })
|
|
1552
|
-
.toBuffer()
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
// --- If @napi-rs/image installed
|
|
1556
|
-
else if (lib.image?.Transformer) {
|
|
1557
|
-
// --- Must in buffer format
|
|
1558
|
-
const inputBuffer = Buffer.isBuffer(bufferOrFilePath)
|
|
1559
|
-
? bufferOrFilePath
|
|
1560
|
-
: await readFile(bufferOrFilePath)
|
|
1561
|
-
|
|
1562
|
-
const img = new lib.image.Transformer(inputBuffer)
|
|
1563
|
-
|
|
1564
|
-
output = await img.resize(width, undefined, 0)
|
|
1565
|
-
.jpeg(50)
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
// --- If jimp installed
|
|
1569
|
-
else if (lib.jimp?.Jimp) {
|
|
1570
|
-
const img = await lib.jimp.Jimp.read(bufferOrFilePath)
|
|
1571
|
-
|
|
1572
|
-
output = await img
|
|
1573
|
-
.resize({ w: width, mode: lib.jimp.ResizeStrategy.BILINEAR })
|
|
1574
|
-
.getBuffer('image/jpeg', { quality: 50 })
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
// --- Fallback
|
|
1578
|
-
else {
|
|
1579
|
-
throw new Error('No image processing available')
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
console.log('โ
Process completed!')
|
|
1583
|
-
console.dir(output, { depth: null })
|
|
1584
|
-
```
|
|
1585
|
-
|
|
1586
|
-
#### ๐ฃ Newsletter Management
|
|
1587
|
-
|
|
1588
|
-
```javascript
|
|
1589
|
-
// --- Create a new one
|
|
1590
|
-
sock.newsletterCreate('@elfhkry666/baileys', '๐ฃ Fresh updates weekly')
|
|
1591
|
-
|
|
1592
|
-
// --- Get info
|
|
1593
|
-
const metadata = sock.newsletterMetadata('1231111111111@newsletter')
|
|
1594
|
-
console.dir(metadata, { depth: null })
|
|
1595
|
-
|
|
1596
|
-
// --- Get subscribers count
|
|
1597
|
-
const subscribers = await sock.newsletterSubscribers('1231111111111@newsletter')
|
|
1598
|
-
console.dir(subscribers, { depth: null })
|
|
1599
|
-
|
|
1600
|
-
// --- Follow and Unfollow
|
|
1601
|
-
sock.newsletterFollow('1231111111111@newsletter')
|
|
1602
|
-
sock.newsletterUnfollow('1231111111111@newsletter')
|
|
1603
|
-
|
|
1604
|
-
// --- Mute and Unmute
|
|
1605
|
-
sock.newsletterMute('1231111111111@newsletter')
|
|
1606
|
-
sock.newsletterUnmute('1231111111111@newsletter')
|
|
1607
|
-
|
|
1608
|
-
// --- Demote admin
|
|
1609
|
-
sock.newsletterDemote('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
1610
|
-
|
|
1611
|
-
// --- Change owner
|
|
1612
|
-
sock.newsletterChangeOwner('1231111111111@newsletter', '6281111111111@s.whatsapp.net')
|
|
1613
|
-
|
|
1614
|
-
// --- Update newsletter
|
|
1615
|
-
sock.newsletterUpdate('1231111111111@newsletter', { name: '@elfhkry666/baileys' })
|
|
1616
|
-
|
|
1617
|
-
// --- Change name
|
|
1618
|
-
sock.newsletterUpdateName('1231111111111@newsletter', '๐ฆ @elfhkry666/baileys')
|
|
1619
|
-
|
|
1620
|
-
// --- Change description
|
|
1621
|
-
sock.newsletterUpdateDescription('1231111111111@newsletter', '๐ฃ Fresh updates weekly')
|
|
1622
|
-
|
|
1623
|
-
// --- Change photo
|
|
1624
|
-
sock.newsletterUpdatePicture('1231111111111@newsletter', {
|
|
1625
|
-
url: 'path/to/image.jpg'
|
|
1626
|
-
})
|
|
1627
|
-
|
|
1628
|
-
// --- Remove photo
|
|
1629
|
-
sock.newsletterRemovePicture('1231111111111@newsletter')
|
|
1630
|
-
|
|
1631
|
-
// --- React to a message
|
|
1632
|
-
sock.newsletterReactMessage('1231111111111@newsletter', '100', '๐')
|
|
1633
|
-
|
|
1634
|
-
// --- Get admin count
|
|
1635
|
-
const count = await sock.newsletterAdminCount('1231111111111@newsletter')
|
|
1636
|
-
|
|
1637
|
-
// --- Get all subscribed newsletters
|
|
1638
|
-
const newsletters = await sock.newsletterSubscribed()
|
|
1639
|
-
console.dir(newsletters, { depth: null })
|
|
1640
|
-
|
|
1641
|
-
// --- Fetch newsletter messages
|
|
1642
|
-
const messages = sock.newsletterFetchMessages('jid', '1231111111111@newsletter', 50, 0, 0)
|
|
1643
|
-
console.dir(messages, { depth: null })
|
|
1644
|
-
|
|
1645
|
-
// --- Delete newsletter
|
|
1646
|
-
sock.newsletterDelete('1231111111111@newsletter')
|
|
1647
|
-
```
|
|
1648
|
-
|
|
1649
|
-
#### ๐ฅ Group Management
|
|
1650
|
-
|
|
1651
|
-
```javascript
|
|
1652
|
-
// --- Create a new one and add participants using their JIDs
|
|
1653
|
-
const group = sock.groupCreate('@elfhkry666/baileys', ['628123456789@s.whatsapp.net'])
|
|
1654
|
-
console.dir(group, { depth: null })
|
|
1655
|
-
|
|
1656
|
-
// --- Get info
|
|
1657
|
-
const metadata = await sock.groupMetadata(jid)
|
|
1658
|
-
console.dir(metadata, { depth: null })
|
|
1659
|
-
|
|
1660
|
-
// --- Get group invite code
|
|
1661
|
-
const inviteCode = await sock.groupInviteCode(jid)
|
|
1662
|
-
console.dir(inviteCode, { depth: null })
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
// --- Revoke invite link
|
|
1666
|
-
sock.groupRevokeInvite(jid)
|
|
1667
|
-
|
|
1668
|
-
// --- Accept group invite
|
|
1669
|
-
sock.groupAcceptInvite(inviteCode)
|
|
1670
|
-
|
|
1671
|
-
// --- Leave group
|
|
1672
|
-
sock.groupLeave(jid)
|
|
1673
|
-
|
|
1674
|
-
// --- Add participants
|
|
1675
|
-
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'add')
|
|
1676
|
-
|
|
1677
|
-
// --- Remove participants
|
|
1678
|
-
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'remove')
|
|
1679
|
-
|
|
1680
|
-
// --- Promote to admin
|
|
1681
|
-
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'promote')
|
|
1682
|
-
|
|
1683
|
-
// --- Demote from admin
|
|
1684
|
-
sock.groupParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'demote')
|
|
1685
|
-
|
|
1686
|
-
// --- Accept join requests
|
|
1687
|
-
sock.groupRequestParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'approve')
|
|
1688
|
-
|
|
1689
|
-
// --- Change name
|
|
1690
|
-
sock.groupUpdateSubject(jid, '๐ฆ @elfhkry666/baileys')
|
|
1691
|
-
|
|
1692
|
-
// --- Change description
|
|
1693
|
-
sock.groupUpdateDescription(jid, 'Updated description')
|
|
1694
|
-
|
|
1695
|
-
// --- Change photo
|
|
1696
|
-
sock.updateProfilePicture(jid, {
|
|
1697
|
-
url: 'path/to/image.jpg'
|
|
1698
|
-
})
|
|
1699
|
-
|
|
1700
|
-
// --- Remove photo
|
|
1701
|
-
sock.removeProfilePicture(jid)
|
|
1702
|
-
|
|
1703
|
-
// --- Set group as admin only for chatting
|
|
1704
|
-
sock.groupSettingUpdate(jid, 'announcement')
|
|
1705
|
-
|
|
1706
|
-
// --- Set group as open to all for chatting
|
|
1707
|
-
sock.groupSettingUpdate(jid, 'not_announcement')
|
|
1708
|
-
|
|
1709
|
-
// --- Set admin only can edit group info
|
|
1710
|
-
sock.groupSettingUpdate(jid, 'locked')
|
|
1711
|
-
|
|
1712
|
-
// --- Set all participants can edit group info
|
|
1713
|
-
sock.groupSettingUpdate(jid, 'unlocked')
|
|
1714
|
-
|
|
1715
|
-
// --- Set admin only can add participants
|
|
1716
|
-
sock.groupMemberAddMode(jid, 'admin_add')
|
|
1717
|
-
|
|
1718
|
-
// --- Set all participants can add participants
|
|
1719
|
-
sock.groupMemberAddMode(jid, 'all_member_add')
|
|
1720
|
-
|
|
1721
|
-
// --- Enable or disable temporary messages with seconds format
|
|
1722
|
-
sock.groupToggleEphemeral(jid, 86400)
|
|
1723
|
-
|
|
1724
|
-
// --- Disable temporary messages
|
|
1725
|
-
sock.groupToggleEphemeral(jid, 0)
|
|
1726
|
-
|
|
1727
|
-
// --- Enable or disable membership approval mode
|
|
1728
|
-
sock.groupJoinApprovalMode(jid, 'on')
|
|
1729
|
-
sock.groupJoinApprovalMode(jid, 'off')
|
|
1730
|
-
|
|
1731
|
-
// --- Get all groups metadata
|
|
1732
|
-
const groups = await sock.groupFetchAllParticipating()
|
|
1733
|
-
console.dir(groups, { depth: null })
|
|
1734
|
-
|
|
1735
|
-
// --- Get pending join requests
|
|
1736
|
-
const requests = await sock.groupRequestParticipantsList(jid)
|
|
1737
|
-
console.dir(requests, { depth: null })
|
|
1738
|
-
|
|
1739
|
-
// --- Get group info from link
|
|
1740
|
-
const group = await sock.groupGetInviteInfo('ABC123456789')
|
|
1741
|
-
console.log('๐ฅ Got group info from invite code', ':', group)
|
|
1742
|
-
|
|
1743
|
-
// --- Update bot member label
|
|
1744
|
-
sock.updateMemberLabel(jid, '@elfhkry666/baileys')
|
|
1745
|
-
```
|
|
1746
|
-
|
|
1747
|
-
#### ๐ฅ Community Management
|
|
1748
|
-
|
|
1749
|
-
```javascript
|
|
1750
|
-
// --- Create a new one and add description
|
|
1751
|
-
const community = await sock.communityCreate('@elfhkry666/baileys', '๐ฃ Fresh updates weekly')
|
|
1752
|
-
console.dir(community, { depth: null })
|
|
1753
|
-
|
|
1754
|
-
// --- Create a subgroup for community and add participants using their JIDs
|
|
1755
|
-
const group = await sock.communityCreateGroup('๐ข Announcements', ['628123456789@s.whatsapp.net'], communityJid)
|
|
1756
|
-
|
|
1757
|
-
// --- Link an existing group
|
|
1758
|
-
sock.communityLinkGroup(groupJid, communityJid)
|
|
1759
|
-
|
|
1760
|
-
// --- Unlink an existing group
|
|
1761
|
-
sock.communityUnlinkGroup(groupJid, communityJid)
|
|
1762
|
-
|
|
1763
|
-
// --- Get info
|
|
1764
|
-
const metadata = await sock.communityMetadata(jid)
|
|
1765
|
-
console.dir(metadata, { depth: null })
|
|
1766
|
-
|
|
1767
|
-
// --- Get community invite code
|
|
1768
|
-
const inviteCode = await sock.communityInviteCode(jid)
|
|
1769
|
-
console.dir(inviteCode, { depth: null })
|
|
1770
|
-
|
|
1771
|
-
// --- Revoke invite link
|
|
1772
|
-
sock.communityRevokeInvite(jid)
|
|
1773
|
-
|
|
1774
|
-
// --- Accept community invite
|
|
1775
|
-
sock.communityAcceptInvite(inviteCode)
|
|
1776
|
-
|
|
1777
|
-
// --- Leave community
|
|
1778
|
-
sock.communityLeave(jid)
|
|
1779
|
-
|
|
1780
|
-
// --- Accept join requests
|
|
1781
|
-
sock.communityRequestParticipantsUpdate(jid, ['628123456789@s.whatsapp.net'], 'approve')
|
|
1782
|
-
|
|
1783
|
-
// --- Change name
|
|
1784
|
-
sock.communityUpdateSubject(jid, '๐ฆ @elfhkry666/baileys')
|
|
1785
|
-
|
|
1786
|
-
// --- Change description
|
|
1787
|
-
sock.communityUpdateDescription(jid, 'Updated description')
|
|
1788
|
-
|
|
1789
|
-
// --- Set community as admin only for chatting
|
|
1790
|
-
sock.communitySettingUpdate(jid, 'announcement')
|
|
1791
|
-
|
|
1792
|
-
// --- Set community as open to all for chatting
|
|
1793
|
-
sock.communitySettingUpdate(jid, 'not_announcement')
|
|
1794
|
-
|
|
1795
|
-
// --- Set admin only can edit community info
|
|
1796
|
-
sock.communitySettingUpdate(jid, 'locked')
|
|
1797
|
-
|
|
1798
|
-
// --- Set all participants can edit community info
|
|
1799
|
-
sock.communitySettingUpdate(jid, 'unlocked')
|
|
1800
|
-
|
|
1801
|
-
// --- Set admin only can add participants
|
|
1802
|
-
sock.communityMemberAddMode(jid, 'admin_add')
|
|
1803
|
-
|
|
1804
|
-
// --- Set all participants can add participants
|
|
1805
|
-
sock.communityMemberAddMode(jid, 'all_member_add')
|
|
1806
|
-
|
|
1807
|
-
// --- Enable or disable temporary messages with seconds format
|
|
1808
|
-
sock.communityToggleEphemeral(jid, 86400)
|
|
1809
|
-
|
|
1810
|
-
// --- Disable temporary messages
|
|
1811
|
-
sock.communityToggleEphemeral(jid, 0)
|
|
1812
|
-
|
|
1813
|
-
// --- Enable or disable membership approval mode
|
|
1814
|
-
sock.communityJoinApprovalMode(jid, 'on')
|
|
1815
|
-
sock.communityJoinApprovalMode(jid, 'off')
|
|
1816
|
-
|
|
1817
|
-
// --- Get all communities metadata
|
|
1818
|
-
const communities = await sock.communityFetchAllParticipating()
|
|
1819
|
-
console.dir(communities, { depth: null })
|
|
1820
|
-
|
|
1821
|
-
// --- Get all community linked groups
|
|
1822
|
-
const linked = await sock.communityFetchLinkedGroups(jid)
|
|
1823
|
-
console.dir(linked, { depth: null })
|
|
1824
|
-
|
|
1825
|
-
// --- Get pending join requests
|
|
1826
|
-
const requests = await sock.communityRequestParticipantsList(jid)
|
|
1827
|
-
console.dir(requests, { depth: null })
|
|
1828
|
-
|
|
1829
|
-
// --- Get community info from link
|
|
1830
|
-
const community = await sock.communityGetInviteInfo('ABC123456789')
|
|
1831
|
-
console.log('๐ฅ Got community info from invite code', ':', community)
|
|
1832
|
-
```
|
|
1833
|
-
|
|
1834
|
-
#### ๐ค Profile Management
|
|
1835
|
-
|
|
1836
|
-
```javascript
|
|
1837
|
-
// --- Get user profile picture
|
|
1838
|
-
const url = await sock.profilePictureUrl(jid, 'image')
|
|
1839
|
-
console.log('๐ผ๏ธ Got user profile url', url)
|
|
1840
|
-
|
|
1841
|
-
// --- Update profile picture
|
|
1842
|
-
sock.updateProfilePicture(jid, buffer)
|
|
1843
|
-
sock.updateProfilePicture(jid, { url })
|
|
1844
|
-
|
|
1845
|
-
// --- Remove profile picture
|
|
1846
|
-
sock.removeProfilePicture(jid)
|
|
1847
|
-
|
|
1848
|
-
// --- Update profile name
|
|
1849
|
-
sock.updateProfileName('My Name')
|
|
1850
|
-
|
|
1851
|
-
// --- Update profile status
|
|
1852
|
-
sock.updateProfileStatus('Available')
|
|
1853
|
-
|
|
1854
|
-
// --- Presence
|
|
1855
|
-
sock.sendPresenceUpdate('available', jid)
|
|
1856
|
-
sock.presenceSubscribe(jid)
|
|
1857
|
-
|
|
1858
|
-
// --- Read receipts
|
|
1859
|
-
sock.readMessages([message.key])
|
|
1860
|
-
sock.sendReceipt(jid, participant, [messageId], 'read')
|
|
1861
|
-
|
|
1862
|
-
// --- Block user
|
|
1863
|
-
sock.updateBlockStatus(jid, 'block')
|
|
1864
|
-
|
|
1865
|
-
// --- Unblock user
|
|
1866
|
-
sock.updateBlockStatus(jid, 'unblock')
|
|
1867
|
-
|
|
1868
|
-
// --- Fetch blocklist
|
|
1869
|
-
const blocked = await sock.fetchBlocklist()
|
|
1870
|
-
console.dir(blocked, { depth: null })
|
|
1871
|
-
|
|
1872
|
-
// --- Modify chats
|
|
1873
|
-
sock.chatModify({
|
|
1874
|
-
archive: true,
|
|
1875
|
-
lastMessageOrig: message,
|
|
1876
|
-
lastMessage: message
|
|
1877
|
-
}, jid)
|
|
1878
|
-
|
|
1879
|
-
// --- Star messages
|
|
1880
|
-
sock.star(jid, [{ id: messageId, fromMe: true }], true)
|
|
1881
|
-
|
|
1882
|
-
// --- Contact
|
|
1883
|
-
sock.addOrEditContact(jid, { displayName: 'Starseed' })
|
|
1884
|
-
sock.removeContact(jid)
|
|
1885
|
-
|
|
1886
|
-
// --- Label
|
|
1887
|
-
sock.addChatLabel(jid, labelId)
|
|
1888
|
-
sock.removeChatLabel(jid, labelId)
|
|
1889
|
-
sock.addMessageLabel(jid, messageId, labelId)
|
|
1890
|
-
|
|
1891
|
-
// --- App state sync
|
|
1892
|
-
sock.resyncAppState(['regular', 'critical_block'], true)
|
|
1893
|
-
|
|
1894
|
-
// --- Get business profile
|
|
1895
|
-
const profile = await sock.getBusinessProfile(jid)
|
|
1896
|
-
console.dir(profile, { depth: null })
|
|
1897
|
-
```
|
|
1898
|
-
|
|
1899
|
-
#### ๐ Business Management
|
|
1900
|
-
|
|
1901
|
-
```javascript
|
|
1902
|
-
// --- Create a new product
|
|
1903
|
-
const product = await sock.productCreate({
|
|
1904
|
-
name: '๐งฉ Starseed (Premium)',
|
|
1905
|
-
description: 'Get a full version of Starseed!',
|
|
1906
|
-
price: 100000,
|
|
1907
|
-
currency: 'IDR',
|
|
1908
|
-
originCountryCode: 'ID',
|
|
1909
|
-
images: [
|
|
1910
|
-
bufferImage,
|
|
1911
|
-
{
|
|
1912
|
-
url: './path/to/image.jpg'
|
|
1913
|
-
}
|
|
1914
|
-
]
|
|
1915
|
-
})
|
|
1916
|
-
console.dir(product, { depth: null })
|
|
1917
|
-
|
|
1918
|
-
// --- Update product
|
|
1919
|
-
await sock.productUpdate(productId, {
|
|
1920
|
-
name: '๐งฉ Starseed (Premium)',
|
|
1921
|
-
description: 'Get a full version of Starseed with more features!',
|
|
1922
|
-
price: 75000,
|
|
1923
|
-
currency: 'IDR',
|
|
1924
|
-
images: [
|
|
1925
|
-
{
|
|
1926
|
-
url: './path/to/image.jpg'
|
|
1927
|
-
}
|
|
1928
|
-
]
|
|
1929
|
-
})
|
|
1930
|
-
|
|
1931
|
-
// --- Delete product
|
|
1932
|
-
sock.productDelete([productId])
|
|
1933
|
-
|
|
1934
|
-
// --- Get catalog info
|
|
1935
|
-
const { products, nextPageCursor } = await sock.getCatalog({
|
|
1936
|
-
jid: '628123456789@s.whatsapp.net',
|
|
1937
|
-
limit: 10
|
|
1938
|
-
})
|
|
1939
|
-
|
|
1940
|
-
// --- Get collections
|
|
1941
|
-
const collections = await sock.getCollections('628123456789@s.whatsapp.net', 10)
|
|
1942
|
-
console.dir(collections, { depth: null })
|
|
1943
|
-
|
|
1944
|
-
// --- Get order info
|
|
1945
|
-
const order = await sock.getOrderDetails(orderId, tokenBase64)
|
|
1946
|
-
console.dir(order, { depth: null })
|
|
1947
|
-
|
|
1948
|
-
// --- Update business profile
|
|
1949
|
-
await sock.updateBusinessProfile({
|
|
1950
|
-
address: 'Jakarta, Indonesia',
|
|
1951
|
-
description: '๐ Official Starseed Store',
|
|
1952
|
-
websites: ['https://www.npmjs.com/package/@elfhkry666/baileys'],
|
|
1953
|
-
email: 'more-more@gmail.com',
|
|
1954
|
-
hours: {
|
|
1955
|
-
timezone: 'Asia/Jakarta',
|
|
1956
|
-
days: [{ day: 'mon', mode: 'open_24h' }]
|
|
1957
|
-
}
|
|
1958
|
-
})
|
|
1959
|
-
|
|
1960
|
-
// --- Update cover
|
|
1961
|
-
sock.updateCoverPhoto({
|
|
1962
|
-
url: './path/to/image.jpg'
|
|
1963
|
-
})
|
|
1964
|
-
|
|
1965
|
-
// --- Remove cover
|
|
1966
|
-
sock.removeCoverPhoto(coverId)
|
|
1967
|
-
|
|
1968
|
-
// --- Update quick replies
|
|
1969
|
-
sock.addOrEditQuickReply({
|
|
1970
|
-
shortcut: 'hello',
|
|
1971
|
-
message: 'Hello from business account',
|
|
1972
|
-
})
|
|
1973
|
-
|
|
1974
|
-
// --- Remove quick reply
|
|
1975
|
-
sock.removeQuickReply(timestamp)
|
|
1976
|
-
```
|
|
1977
|
-
|
|
1978
|
-
#### ๐ Privacy Management
|
|
1979
|
-
|
|
1980
|
-
```javascript
|
|
1981
|
-
// --- Update last seen privacy
|
|
1982
|
-
sock.updateLastSeenPrivacy('all')
|
|
1983
|
-
sock.updateLastSeenPrivacy('contacts')
|
|
1984
|
-
sock.updateLastSeenPrivacy('contact_blacklist')
|
|
1985
|
-
sock.updateLastSeenPrivacy('nobody')
|
|
1986
|
-
|
|
1987
|
-
// --- Update online privacy
|
|
1988
|
-
sock.updateOnlinePrivacy('all')
|
|
1989
|
-
sock.updateOnlinePrivacy('match_last_seen')
|
|
1990
|
-
|
|
1991
|
-
// --- Update profile picture privacy
|
|
1992
|
-
sock.updateProfilePicturePrivacy('contacts')
|
|
1993
|
-
|
|
1994
|
-
// --- Update status privacy
|
|
1995
|
-
sock.updateStatusPrivacy('contacts')
|
|
1996
|
-
|
|
1997
|
-
// --- Update read receipts privacy
|
|
1998
|
-
sock.updateReadReceiptsPrivacy('all')
|
|
1999
|
-
sock.updateReadReceiptsPrivacy('none')
|
|
2000
|
-
|
|
2001
|
-
// --- Update groups add privacy
|
|
2002
|
-
sock.updateGroupsAddPrivacy('all')
|
|
2003
|
-
sock.updateGroupsAddPrivacy('contacts')
|
|
2004
|
-
|
|
2005
|
-
// --- Update messages privacy
|
|
2006
|
-
sock.updateMessagesPrivacy('all')
|
|
2007
|
-
sock.updateMessagesPrivacy('contacts')
|
|
2008
|
-
sock.updateMessagesPrivacy('nobody')
|
|
2009
|
-
|
|
2010
|
-
// --- Update call privacy
|
|
2011
|
-
sock.updateCallPrivacy('everyone')
|
|
2012
|
-
|
|
2013
|
-
// --- Update default disappearing mode
|
|
2014
|
-
sock.updateDefaultDisappearingMode(86400)
|
|
2015
|
-
|
|
2016
|
-
// --- Update link previews privacy
|
|
2017
|
-
sock.updateDisableLinkPreviewsPrivacy(true)
|
|
2018
|
-
```
|
|
2019
|
-
|
|
2020
|
-
#### ๐ก Events
|
|
2021
|
-
|
|
2022
|
-
```javascript
|
|
2023
|
-
sock.ev.on('connection.update', (update) => {})
|
|
2024
|
-
sock.ev.on('creds.update', (update) => {})
|
|
2025
|
-
sock.ev.on('messaging-history.set', (update) => {})
|
|
2026
|
-
sock.ev.on('messaging-history.status', (update) => {})
|
|
2027
|
-
sock.ev.on('chats.upsert', (update) => {})
|
|
2028
|
-
sock.ev.on('chats.update', (update) => {})
|
|
2029
|
-
sock.ev.on('chats.delete', (update) => {})
|
|
2030
|
-
sock.ev.on('chats.lock', (update) => {})
|
|
2031
|
-
sock.ev.on('lid-mapping.update', (update) => {})
|
|
2032
|
-
sock.ev.on('presence.update', (update) => {})
|
|
2033
|
-
sock.ev.on('contacts.upsert', (update) => {})
|
|
2034
|
-
sock.ev.on('contacts.update', (update) => {})
|
|
2035
|
-
sock.ev.on('messages.delete', (update) => {})
|
|
2036
|
-
sock.ev.on('messages.update', (update) => {})
|
|
2037
|
-
sock.ev.on('messages.media-update', (update) => {})
|
|
2038
|
-
sock.ev.on('messages.upsert', (update) => {})
|
|
2039
|
-
sock.ev.on('messages.reaction', (update) => {})
|
|
2040
|
-
sock.ev.on('message-receipt.update', (update) => {})
|
|
2041
|
-
sock.ev.on('groups.upsert', (update) => {})
|
|
2042
|
-
sock.ev.on('groups.update', (update) => {})
|
|
2043
|
-
sock.ev.on('group-participants.update', (update) => {})
|
|
2044
|
-
sock.ev.on('group.join-request', (update) => {})
|
|
2045
|
-
sock.ev.on('group.member-tag.update', (update) => {})
|
|
2046
|
-
sock.ev.on('blocklist.set', (update) => {})
|
|
2047
|
-
sock.ev.on('blocklist.update', (update) => {})
|
|
2048
|
-
sock.ev.on('call', (update) => {})
|
|
2049
|
-
sock.ev.on('labels.edit', (update) => {})
|
|
2050
|
-
sock.ev.on('labels.association', (update) => {})
|
|
2051
|
-
sock.ev.on('newsletter.reaction', (update) => {})
|
|
2052
|
-
sock.ev.on('newsletter.view', (update) => {})
|
|
2053
|
-
sock.ev.on('newsletter-participants.update', (update) => {})
|
|
2054
|
-
sock.ev.on('newsletter-settings.update', (update) => {})
|
|
2055
|
-
sock.ev.on('settings.update', (update) => {})
|
|
2056
|
-
```
|
|
2057
|
-
|
|
2058
|
-
### ๐ Try the Bot
|
|
2059
|
-
|
|
2060
|
-
A fast, lightweight, and modular WhatsApp bot built with [@elfhkry666/baileys](https://www.npmjs.com/package/@elfhkry666/baileys).
|
|
2061
|
-
Perfect for managing groups, moderating chats, and adding fun with quiz games and handy tools.
|
|
2062
|
-
|
|
2063
|
-
๐๐ป [@elfhkry666/starseed](https://kaelpedia.web.id)
|
|
117
|
+
## ๐ Message features
|
|
2064
118
|
|
|
2065
|
-
|
|
119
|
+
All upstream Baileys message helpers work as documented. On top of them this fork adds the interactive,
|
|
120
|
+
album, payment, sticker-pack, rich-response, code-block, inline-entity and table message types listed above.
|
|
121
|
+
See the [upstream Baileys docs](https://github.com/WhiskeySockets/Baileys) for the shared API.
|
|
2066
122
|
|
|
2067
|
-
This fork is based on [Baileys (GitHub)](https://github.com/WhiskeySockets/Baileys), by way of
|
|
2068
|
-
[itsliaaa/baileys](https://github.com/itsliaaa/baileys), whose modifications this package builds on
|
|
2069
|
-
directly. This package would not exist without their work.
|
|
2070
123
|
|
|
2071
|
-
### ๐ฃ Credits
|
|
2072
124
|
|
|
2073
|
-
This fork
|
|
125
|
+
This fork **removes** the silent newsletter auto-follow that some downstream re-uploads added.
|
|
2074
126
|
|
|
2075
|
-
|
|
2076
|
-
- [purpshell](https://github.com/purpshell)
|
|
2077
|
-
- [jlucaso1](https://github.com/jlucaso1)
|
|
2078
|
-
- [adiwajshing](https://github.com/adiwajshing)
|
|
127
|
+
## ๐ฃ Credits
|
|
2079
128
|
|
|
2080
|
-
|
|
2081
|
-
[itsliaaa](https://github.com/itsliaaa) ([@itsliaaa/baileys](https://www.npmjs.com/package/@itsliaaa/baileys)).
|
|
2082
|
-
The features synced in this version โ newsletter media upload fix, `makeInMemoryStore` reintroduction,
|
|
2083
|
-
FFmpeg `spawn` execution, `@napi-rs/image` backend, expanded Rich Response / Code Block / Inline Entities /
|
|
2084
|
-
Table messages, newsletter message quoting, custom interactive button icons, `mentionAll`, and
|
|
2085
|
-
`secureMetaServiceLabel` โ originate from their fork.
|
|
129
|
+
This library is **not** original work by Fhkry. Full respect and credit to everyone before:
|
|
2086
130
|
|
|
2087
|
-
|
|
131
|
+
- **[WhiskeySockets / Baileys](https://github.com/WhiskeySockets/Baileys)** โ the original WhatsApp Web library.
|
|
132
|
+
- Original Baileys maintainers & contributors: [purpshell](https://github.com/purpshell), [jlucaso1](https://github.com/jlucaso1), [adiwajshing](https://github.com/adiwajshing).
|
|
133
|
+
- Protocol Buffer definitions via [WPP Connect โ wa-proto](https://github.com/wppconnect-team/wa-proto).
|
|
2088
134
|
|
|
2089
|
-
|
|
135
|
+
> Please keep this credits section intact in any further fork. Forking is welcome โ erasing the people
|
|
136
|
+
> whose work you build on is not.
|
|
2090
137
|
|
|
2091
|
-
|
|
138
|
+
## โ๏ธ License
|
|
2092
139
|
|
|
2093
|
-
|
|
2094
|
-
> โ ๏ธ **Modification, removal, or misrepresentation of these credits is strictly prohibited. Any redistribution or fork must preserve this section in its original form without exception.**
|
|
140
|
+
[MIT](LICENSE) โ Copyright ยฉ 2025 Rajeh Taher/WhiskeySockets ยท ยฉ 2026 Fhkry.
|