xmd-baileys 1.0.2 → 1.0.4
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 +222 -8
- package/WAProto/tmp +1 -0
- package/package.json +14 -83
package/README.md
CHANGED
|
@@ -1,10 +1,224 @@
|
|
|
1
|
-
|
|
1
|
+
# xmd-baileys
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<img src="https://capsule-render.vercel.app/api?type=waving&color=gradient&height=60§ion=header" width="100%">
|
|
5
|
-
</div>
|
|
3
|
+
A lightweight, full-featured WhatsApp Web API library for Node.js. This is a maintained fork with bug fixes and improvements.
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
**Website:** [https://bwmxmd.co.ke](https://bwmxmd.co.ke)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install xmd-baileys
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Drop-in Replacement
|
|
14
|
+
|
|
15
|
+
This package is a drop-in replacement for `@whiskeysockets/baileys`. Simply update your imports:
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
// Before
|
|
19
|
+
const { default: makeWASocket } = require('@whiskeysockets/baileys');
|
|
20
|
+
|
|
21
|
+
// After
|
|
22
|
+
const { default: makeWASocket } = require('xmd-baileys');
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
const {
|
|
29
|
+
default: makeWASocket,
|
|
30
|
+
useMultiFileAuthState,
|
|
31
|
+
DisconnectReason,
|
|
32
|
+
makeCacheableSignalKeyStore
|
|
33
|
+
} = require('xmd-baileys');
|
|
34
|
+
const pino = require('pino');
|
|
35
|
+
|
|
36
|
+
async function connectToWhatsApp() {
|
|
37
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_session');
|
|
38
|
+
|
|
39
|
+
const sock = makeWASocket({
|
|
40
|
+
auth: {
|
|
41
|
+
creds: state.creds,
|
|
42
|
+
keys: makeCacheableSignalKeyStore(state.keys, pino({ level: 'silent' }))
|
|
43
|
+
},
|
|
44
|
+
printQRInTerminal: true
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
sock.ev.on('creds.update', saveCreds);
|
|
48
|
+
|
|
49
|
+
sock.ev.on('connection.update', (update) => {
|
|
50
|
+
const { connection, lastDisconnect } = update;
|
|
51
|
+
if (connection === 'close') {
|
|
52
|
+
const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut;
|
|
53
|
+
if (shouldReconnect) {
|
|
54
|
+
connectToWhatsApp();
|
|
55
|
+
}
|
|
56
|
+
} else if (connection === 'open') {
|
|
57
|
+
console.log('Connected to WhatsApp!');
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
62
|
+
for (const msg of messages) {
|
|
63
|
+
if (!msg.key.fromMe && msg.message) {
|
|
64
|
+
console.log('New message:', msg.message);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
connectToWhatsApp();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Features
|
|
74
|
+
|
|
75
|
+
- **Multi-Device Support** - Works with WhatsApp's multi-device feature
|
|
76
|
+
- **QR Code Authentication** - Easy pairing via QR code or pairing code
|
|
77
|
+
- **Message Handling** - Send and receive all message types (text, media, stickers, etc.)
|
|
78
|
+
- **Group Management** - Create groups, manage participants, update settings
|
|
79
|
+
- **Status/Stories** - View and post status updates
|
|
80
|
+
- **Presence Updates** - Online/offline status, typing indicators
|
|
81
|
+
- **Message Reactions** - React to messages with emojis
|
|
82
|
+
- **Newsletter Support** - Subscribe and interact with WhatsApp channels
|
|
83
|
+
- **Media Downloads** - Download images, videos, audio, and documents
|
|
84
|
+
- **Sticker Creation** - Convert images and videos to WhatsApp stickers
|
|
85
|
+
|
|
86
|
+
## Sending Messages
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
// Text message
|
|
90
|
+
await sock.sendMessage(jid, { text: 'Hello World!' });
|
|
91
|
+
|
|
92
|
+
// Image
|
|
93
|
+
await sock.sendMessage(jid, {
|
|
94
|
+
image: fs.readFileSync('./image.jpg'),
|
|
95
|
+
caption: 'Check this out!'
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Video
|
|
99
|
+
await sock.sendMessage(jid, {
|
|
100
|
+
video: fs.readFileSync('./video.mp4'),
|
|
101
|
+
caption: 'Cool video'
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Audio
|
|
105
|
+
await sock.sendMessage(jid, {
|
|
106
|
+
audio: fs.readFileSync('./audio.mp3'),
|
|
107
|
+
mimetype: 'audio/mp4'
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Document
|
|
111
|
+
await sock.sendMessage(jid, {
|
|
112
|
+
document: fs.readFileSync('./file.pdf'),
|
|
113
|
+
mimetype: 'application/pdf',
|
|
114
|
+
fileName: 'document.pdf'
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Sticker
|
|
118
|
+
await sock.sendMessage(jid, {
|
|
119
|
+
sticker: fs.readFileSync('./sticker.webp')
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Location
|
|
123
|
+
await sock.sendMessage(jid, {
|
|
124
|
+
location: {
|
|
125
|
+
degreesLatitude: 24.121231,
|
|
126
|
+
degreesLongitude: 55.1121221
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Contact
|
|
131
|
+
await sock.sendMessage(jid, {
|
|
132
|
+
contacts: {
|
|
133
|
+
displayName: 'John',
|
|
134
|
+
contacts: [{ vcard }]
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Reply to a message
|
|
139
|
+
await sock.sendMessage(jid, { text: 'This is a reply' }, { quoted: message });
|
|
140
|
+
|
|
141
|
+
// React to a message
|
|
142
|
+
await sock.sendMessage(jid, {
|
|
143
|
+
react: { text: '👍', key: message.key }
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Group Operations
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
// Create group
|
|
151
|
+
const group = await sock.groupCreate('Group Name', ['1234567890@s.whatsapp.net']);
|
|
152
|
+
|
|
153
|
+
// Add participants
|
|
154
|
+
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'add');
|
|
155
|
+
|
|
156
|
+
// Remove participants
|
|
157
|
+
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'remove');
|
|
158
|
+
|
|
159
|
+
// Promote to admin
|
|
160
|
+
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'promote');
|
|
161
|
+
|
|
162
|
+
// Update group subject
|
|
163
|
+
await sock.groupUpdateSubject(groupJid, 'New Group Name');
|
|
164
|
+
|
|
165
|
+
// Update group description
|
|
166
|
+
await sock.groupUpdateDescription(groupJid, 'New description');
|
|
167
|
+
|
|
168
|
+
// Get group metadata
|
|
169
|
+
const metadata = await sock.groupMetadata(groupJid);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Configuration Options
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
const sock = makeWASocket({
|
|
176
|
+
auth: { creds, keys },
|
|
177
|
+
printQRInTerminal: true,
|
|
178
|
+
browser: ['MyBot', 'Chrome', '1.0.0'],
|
|
179
|
+
syncFullHistory: false,
|
|
180
|
+
markOnlineOnConnect: true,
|
|
181
|
+
generateHighQualityLinkPreview: true,
|
|
182
|
+
getMessage: async (key) => {
|
|
183
|
+
// Return message from your store
|
|
184
|
+
return { conversation: 'hello' };
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Events
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
// Connection updates
|
|
193
|
+
sock.ev.on('connection.update', (update) => { });
|
|
194
|
+
|
|
195
|
+
// New messages
|
|
196
|
+
sock.ev.on('messages.upsert', ({ messages, type }) => { });
|
|
197
|
+
|
|
198
|
+
// Message updates (read receipts, etc.)
|
|
199
|
+
sock.ev.on('messages.update', (updates) => { });
|
|
200
|
+
|
|
201
|
+
// Presence updates
|
|
202
|
+
sock.ev.on('presence.update', ({ id, presences }) => { });
|
|
203
|
+
|
|
204
|
+
// Group updates
|
|
205
|
+
sock.ev.on('groups.update', (updates) => { });
|
|
206
|
+
|
|
207
|
+
// Group participant updates
|
|
208
|
+
sock.ev.on('group-participants.update', ({ id, participants, action }) => { });
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Requirements
|
|
212
|
+
|
|
213
|
+
- Node.js 14+
|
|
214
|
+
- npm or yarn
|
|
215
|
+
|
|
216
|
+
## Author
|
|
217
|
+
|
|
218
|
+
**BWM XMD**
|
|
219
|
+
|
|
220
|
+
- Website: [https://bwmxmd.co.ke](https://bwmxmd.co.ke)
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT License
|
package/WAProto/tmp
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
CHANGED
|
@@ -1,41 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xmd-baileys",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
5
|
-
"keywords": [
|
|
6
|
-
"whatsapp-baileys",
|
|
7
|
-
"bwm-xmd",
|
|
8
|
-
"disappearing-messages",
|
|
9
|
-
"whatsapp-bot"
|
|
10
|
-
],
|
|
11
|
-
"homepage": "https://github.com/xmd-tech/Baileys",
|
|
12
|
-
"repository": {
|
|
13
|
-
"url": "https://github.com/xmd-tech/Baileys"
|
|
14
|
-
},
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"author": "Ibrahim Adams",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "A lightweight, full-featured WhatsApp Web API library for Node.js",
|
|
17
5
|
"main": "lib/index.js",
|
|
18
6
|
"types": "lib/index.d.ts",
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
"homepage": "https://bwmxmd.co.ke",
|
|
8
|
+
"author": "BWM XMD",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"whatsapp",
|
|
12
|
+
"whatsapp-api",
|
|
13
|
+
"whatsapp-web",
|
|
14
|
+
"baileys",
|
|
15
|
+
"whatsapp-bot",
|
|
16
|
+
"messaging",
|
|
17
|
+
"chat"
|
|
23
18
|
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build:all": "tsc && typedoc",
|
|
26
|
-
"build:docs": "typedoc",
|
|
27
|
-
"build:tsc": "tsc",
|
|
28
|
-
"changelog:last": "conventional-changelog -p angular -r 2",
|
|
29
|
-
"changelog:preview": "conventional-changelog -p angular -u",
|
|
30
|
-
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
|
31
|
-
"lint": "eslint src --ext .js,.ts,.jsx,.tsx",
|
|
32
|
-
"lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
|
|
33
|
-
"prepack": "",
|
|
34
|
-
"prepare": "",
|
|
35
|
-
"preinstall": "node ./engine-requirements.js",
|
|
36
|
-
"release": "release-it",
|
|
37
|
-
"test": "jest"
|
|
38
|
-
},
|
|
39
19
|
"dependencies": {
|
|
40
20
|
"@adiwajshing/keyed-db": "^0.2.4",
|
|
41
21
|
"@hapi/boom": "^9.1.3",
|
|
@@ -47,8 +27,8 @@
|
|
|
47
27
|
"chalk": "^4.1.2",
|
|
48
28
|
"futoin-hkdf": "^1.5.1",
|
|
49
29
|
"libphonenumber-js": "^1.10.20",
|
|
50
|
-
"lodash": "^4.17.21",
|
|
51
30
|
"libsignal": "^2.0.1",
|
|
31
|
+
"lodash": "^4.17.21",
|
|
52
32
|
"music-metadata": "^7.12.3",
|
|
53
33
|
"node-cache": "^5.1.2",
|
|
54
34
|
"node-fetch": "^2.6.1",
|
|
@@ -56,54 +36,5 @@
|
|
|
56
36
|
"protobufjs": "^7.2.4",
|
|
57
37
|
"uuid": "^9.0.0",
|
|
58
38
|
"ws": "^8.13.0"
|
|
59
|
-
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
|
|
62
|
-
"@types/got": "^9.6.11",
|
|
63
|
-
"@types/jest": "^27.5.1",
|
|
64
|
-
"@types/node": "^16.0.0",
|
|
65
|
-
"@types/sharp": "^0.29.4",
|
|
66
|
-
"@types/ws": "^8.0.0",
|
|
67
|
-
"conventional-changelog-cli": "^2.2.2",
|
|
68
|
-
"eslint": "^8.0.0",
|
|
69
|
-
"jest": "^27.0.6",
|
|
70
|
-
"jimp": "^0.16.1",
|
|
71
|
-
"link-preview-js": "^3.0.0",
|
|
72
|
-
"open": "^8.4.2",
|
|
73
|
-
"qrcode-terminal": "^0.12.0",
|
|
74
|
-
"release-it": "^15.10.3",
|
|
75
|
-
"sharp": "^0.30.5",
|
|
76
|
-
"ts-jest": "^27.0.3",
|
|
77
|
-
"ts-node": "^10.8.1",
|
|
78
|
-
"typedoc": "^0.24.7",
|
|
79
|
-
"typescript": "^4.6.4",
|
|
80
|
-
"json": "^11.0.0"
|
|
81
|
-
},
|
|
82
|
-
"peerDependencies": {
|
|
83
|
-
"jimp": "^0.16.1",
|
|
84
|
-
"link-preview-js": "^3.0.0",
|
|
85
|
-
"qrcode-terminal": "^0.12.0",
|
|
86
|
-
"sharp": "^0.32.2"
|
|
87
|
-
},
|
|
88
|
-
"peerDependenciesMeta": {
|
|
89
|
-
"jimp": {
|
|
90
|
-
"optional": true
|
|
91
|
-
},
|
|
92
|
-
"link-preview-js": {
|
|
93
|
-
"optional": true
|
|
94
|
-
},
|
|
95
|
-
"qrcode-terminal": {
|
|
96
|
-
"optional": true
|
|
97
|
-
},
|
|
98
|
-
"sharp": {
|
|
99
|
-
"optional": true
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
"packageManager": "yarn@1.22.19",
|
|
103
|
-
"engines": {
|
|
104
|
-
"node": ">=20.0.0"
|
|
105
|
-
},
|
|
106
|
-
"bugs": {
|
|
107
|
-
"url": "https://github.com/xmd-tech/Baileys/issues"
|
|
108
39
|
}
|
|
109
40
|
}
|