@innovatorssoft/innovators-bot2 2.0.0 → 2.0.2

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.
Files changed (4) hide show
  1. package/README.md +222 -10
  2. package/example.js +509 -52
  3. package/index.js +609 -19
  4. package/package.json +2 -1
package/README.md CHANGED
@@ -9,12 +9,14 @@ A powerful WhatsApp client library that provides seamless integration between Ba
9
9
  - 💬 Send and receive messages
10
10
  - � Message reactions (add/remove emoji reactions)
11
11
  - �📸 Media handling (images, videos, documents)
12
- - 👥 Group management
12
+ - Mentions support in text and media messages
13
+ - �👥 Group management
13
14
  - 💾 Message history and chat management
14
15
  - 🔄 Auto-reconnect functionality
15
16
  - 📝 Read receipts
16
17
  - 🔐 LID (Local Identifier) support for enhanced privacy
17
18
  - 🗂️ Signal repository store for LID/PN mapping
19
+ - 🧩 Interactive buttons support for both text and media (URL or local file)
18
20
 
19
21
  ## Installation
20
22
 
@@ -97,10 +99,22 @@ await client.sendMedia('1234567890@s.whatsapp.net', './image.jpg', {
97
99
  caption: 'Check out this image!'
98
100
  })
99
101
 
102
+ // Send an image with mentions
103
+ await client.sendMedia('1234567890@s.whatsapp.net', './image.jpg', {
104
+ caption: 'Hey @user, check this out!',
105
+ mentions: ['user@s.whatsapp.net']
106
+ })
107
+
100
108
  // Send a document
101
109
  await client.sendDocument('1234567890@s.whatsapp.net', './document.pdf',
102
110
  'Check out this document!'
103
111
  )
112
+
113
+ // Send a document with mentions (caption object is supported)
114
+ await client.sendDocument('1234567890@s.whatsapp.net', './document.pdf', {
115
+ caption: 'Hey @user, please read this',
116
+ mentions: ['user@s.whatsapp.net']
117
+ })
104
118
  ```
105
119
 
106
120
  ### 3. Sticker Management
@@ -145,6 +159,45 @@ client.on('message-deleted', async (data) => {
145
159
  // Get all groups
146
160
  const groups = await client.getAllGroups()
147
161
 
162
+ // Get group metadata (participants, name, description...)
163
+ const metadata = await client.getGroupMetadata(groupId)
164
+ console.log(metadata.id, metadata.subject, metadata.desc)
165
+
166
+ // Create a new group
167
+ const newGroup = await client.createGroup('Group Name', ['1234567890@s.whatsapp.net'])
168
+ console.log('Created group:', newGroup.id)
169
+
170
+ // Change group subject (name)
171
+ await client.changeGroupSubject(groupId, 'New Group Name')
172
+
173
+ // Change group description
174
+ await client.changeGroupDescription(groupId, 'New description for the group')
175
+
176
+ // Change group settings
177
+ // Options: 'announcement' (only admins send), 'not_announcement' (everyone sends),
178
+ // 'locked' (only admins edit info), 'unlocked' (everyone edits info)
179
+ await client.changeGroupSettings(groupId, 'announcement')
180
+
181
+ // Get group invite code
182
+ const code = await client.getGroupInviteCode(groupId)
183
+ console.log('Invite link: https://chat.whatsapp.com/' + code)
184
+
185
+ // Revoke invite code (generates a new one)
186
+ const newCode = await client.revokeGroupInviteCode(groupId)
187
+ console.log('New invite link: https://chat.whatsapp.com/' + newCode)
188
+
189
+ // Join group by invite code
190
+ const joinedGroupId = await client.joinGroupByInviteCode('AbCdEfGhIjK')
191
+ // Also accepts full URL - it strips the prefix automatically
192
+ await client.joinGroupByInviteCode('https://chat.whatsapp.com/AbCdEfGhIjK')
193
+
194
+ // Get group info by invite code (without joining)
195
+ const groupInfo = await client.getGroupInfoByInviteCode('AbCdEfGhIjK')
196
+ console.log('Group name:', groupInfo.subject)
197
+
198
+ // Leave a group
199
+ await client.leaveGroup(groupId)
200
+
148
201
  // Add participant to group
149
202
  // Note: If adding fails due to user's privacy settings (403),
150
203
  // an invitation link is automatically sent to the user instead.
@@ -165,9 +218,71 @@ await client.changeGroupParticipants(groupId, ['1234567890@s.whatsapp.net'], 'pr
165
218
 
166
219
  // Demote admin
167
220
  await client.changeGroupParticipants(groupId, ['1234567890@s.whatsapp.net'], 'demote')
221
+
222
+ // Get pending join requests
223
+ const requests = await client.getGroupJoinRequests(groupId)
224
+ console.log('Pending requests:', requests)
225
+
226
+ // Approve/Reject join requests
227
+ await client.handleGroupJoinRequest(groupId, ['1234567890@s.whatsapp.net'], 'approve')
228
+ await client.handleGroupJoinRequest(groupId, ['1234567890@s.whatsapp.net'], 'reject')
229
+
230
+ // Toggle ephemeral (disappearing) messages
231
+ // Options: 0 (off), 86400 (24h), 604800 (7d), 7776000 (90d)
232
+ await client.toggleGroupEphemeral(groupId, 86400)
233
+
234
+ // Change who can add members
235
+ // Options: 'all_member_add' or 'admin_add'
236
+ await client.changeGroupAddMode(groupId, 'admin_add')
168
237
  ```
169
238
 
170
- ### 4. Interactive Messages
239
+ ### 6. Privacy Management
240
+
241
+ ```javascript
242
+ // Block a user
243
+ await client.blockUser('1234567890@s.whatsapp.net')
244
+
245
+ // Unblock a user
246
+ await client.unblockUser('1234567890@s.whatsapp.net')
247
+
248
+ // Get all privacy settings
249
+ const settings = await client.getPrivacySettings()
250
+ console.log('Privacy settings:', settings)
251
+
252
+ // Get blocked contacts list
253
+ const blocklist = await client.getBlockList()
254
+ console.log('Blocked users:', blocklist)
255
+
256
+ // Update last seen privacy
257
+ // Options: 'all' | 'contacts' | 'contact_blacklist' | 'none'
258
+ await client.updateLastSeenPrivacy('contacts')
259
+
260
+ // Update online status privacy
261
+ // Options: 'all' | 'match_last_seen'
262
+ await client.updateOnlinePrivacy('match_last_seen')
263
+
264
+ // Update profile picture privacy
265
+ // Options: 'all' | 'contacts' | 'contact_blacklist' | 'none'
266
+ await client.updateProfilePicturePrivacy('contacts')
267
+
268
+ // Update status privacy
269
+ // Options: 'all' | 'contacts' | 'contact_blacklist' | 'none'
270
+ await client.updateStatusPrivacy('contacts')
271
+
272
+ // Update read receipts privacy
273
+ // Options: 'all' | 'none'
274
+ await client.updateReadReceiptsPrivacy('all')
275
+
276
+ // Update who can add you to groups
277
+ // Options: 'all' | 'contacts' | 'contact_blacklist'
278
+ await client.updateGroupsAddPrivacy('contacts')
279
+
280
+ // Update default disappearing mode for new chats
281
+ // Options: 0 (off), 86400 (24h), 604800 (7d), 7776000 (90d)
282
+ await client.updateDefaultDisappearingMode(604800)
283
+ ```
284
+
285
+ ### 7. Interactive Messages
171
286
 
172
287
  #### Buttons
173
288
  ```javascript
@@ -176,7 +291,7 @@ await client.sendButtons('1234567890@s.whatsapp.net', {
176
291
  text: 'Do you like this bot?',
177
292
  title: 'Feedback',
178
293
  subtitle: 'Let us know!',
179
- footer: 'Powered by Baileys',
294
+ footer: 'Powered by Innovators Soft',
180
295
  interactiveButtons: [
181
296
  {
182
297
  name: 'quick_reply',
@@ -194,6 +309,43 @@ await client.sendButtons('1234567890@s.whatsapp.net', {
194
309
  }
195
310
  ]
196
311
  });
312
+
313
+ // Send interactive buttons with an image from URL + caption
314
+ await client.sendButtons('1234567890@s.whatsapp.net', {
315
+ image: { url: 'https://example.com/image.jpg' },
316
+ caption: 'Body',
317
+ title: 'Title',
318
+ subtitle: 'Subtitle',
319
+ footer: 'Footer',
320
+ interactiveButtons: [
321
+ {
322
+ name: 'quick_reply',
323
+ buttonParamsJson: JSON.stringify({
324
+ display_text: 'DisplayText',
325
+ id: 'ID1'
326
+ })
327
+ }
328
+ ],
329
+ hasMediaAttachment: false
330
+ });
331
+
332
+ // Send interactive buttons with a local image file + caption
333
+ await client.sendButtons('1234567890@s.whatsapp.net', {
334
+ imagePath: './image.jpg',
335
+ caption: 'Body',
336
+ title: 'Title',
337
+ subtitle: 'Subtitle',
338
+ footer: 'Footer',
339
+ interactiveButtons: [
340
+ {
341
+ name: 'quick_reply',
342
+ buttonParamsJson: JSON.stringify({
343
+ display_text: 'DisplayText',
344
+ id: 'ID1'
345
+ })
346
+ }
347
+ ]
348
+ });
197
349
  ```
198
350
 
199
351
  #### List Messages
@@ -223,7 +375,7 @@ await client.SendList('1234567890@s.whatsapp.net', {
223
375
  });
224
376
  ```
225
377
 
226
- ### 4. Message History
378
+ ### 8. Message History
227
379
 
228
380
  ```javascript
229
381
  // Get chat history
@@ -260,13 +412,16 @@ The library includes example bot commands that you can use:
260
412
  - `!react` - React to your message with ❤️
261
413
  - `!read` - Mark messages as read
262
414
  - `!typing` - Show typing indicator
263
- - `!presence` - Set online presence
415
+ - `!recording` - Show recording indicator
416
+ - `!paused` - Clear typing or recording indicator
264
417
 
265
418
  ### Media & Content
266
419
  - `!media` - Send an example image
267
420
  - `!doc` - Send an example document
268
421
  - `!location` - Send a location
269
422
  - `!contact` - Send a contact card
423
+ - `!sticker` - Create a sticker from an image
424
+ - `!ad` - Send an ad reply message
270
425
 
271
426
  ### Group Management
272
427
  - `!groups` - List all your groups
@@ -274,7 +429,34 @@ The library includes example bot commands that you can use:
274
429
  - `!remove <number>` - Remove participant from group
275
430
  - `!promote <number>` - Promote participant to admin
276
431
  - `!demote <number>` - Demote admin to participant
277
- - `!list` - Show interactive list message
432
+ - `!invite <number>` - Send group invite link to user
433
+ - `!creategroup <name>` - Create a new group
434
+ - `!groupsubject <name>` - Change group name
435
+ - `!groupdesc <text>` - Change group description
436
+ - `!groupsetting <setting>` - Change group settings (announcement/not_announcement/locked/unlocked)
437
+ - `!invitecode` - Get group invite code/link
438
+ - `!revokeinvite` - Revoke current invite code and generate new one
439
+ - `!leavegroup` - Leave the current group
440
+ - `!joingroup <code>` - Join a group by invite code
441
+ - `!groupinfo <code>` - Get group info by invite code without joining
442
+ - `!joinrequests` - List pending join requests
443
+ - `!approvejoin <number>` - Approve a join request
444
+ - `!rejectjoin <number>` - Reject a join request
445
+ - `!ephemeral <seconds>` - Toggle disappearing messages (0/86400/604800/7776000)
446
+ - `!addmode <mode>` - Change who can add members (all_member_add/admin_add)
447
+
448
+ ### 🔒 Privacy
449
+ - `!block <number>` - Block a user
450
+ - `!unblock <number>` - Unblock a user
451
+ - `!privacy` - View all privacy settings
452
+ - `!blocklist` - List all blocked contacts
453
+ - `!lastseenprivacy <value>` - Update last seen privacy (all/contacts/contact_blacklist/none)
454
+ - `!onlineprivacy <value>` - Update online privacy (all/match_last_seen)
455
+ - `!pfpprivacy <value>` - Update profile picture privacy (all/contacts/contact_blacklist/none)
456
+ - `!statusprivacy <value>` - Update status privacy (all/contacts/contact_blacklist/none)
457
+ - `!readreceiptprivacy <value>` - Update read receipts privacy (all/none)
458
+ - `!groupaddprivacy <value>` - Update who can add you to groups (all/contacts/contact_blacklist)
459
+ - `!disappearing <seconds>` - Update default disappearing mode (0/86400/604800/7776000)
278
460
 
279
461
  ### Interactive Messages
280
462
  - `!buttons` - Show interactive buttons
@@ -290,9 +472,6 @@ The library includes example bot commands that you can use:
290
472
  - `!parse <jid>` - Parse detailed JID information
291
473
  - `!normalize <number>` - Normalize a number to JID format
292
474
 
293
- ### 🎨 Sticker Commands
294
- - `!sticker` - Create a sticker from an image
295
-
296
475
  ### Connection Events
297
476
  ```javascript
298
477
  // When QR code is generated
@@ -316,6 +495,24 @@ client.on('disconnected', (error) => {
316
495
  })
317
496
  ```
318
497
 
498
+ ### Contact Events
499
+ ```javascript
500
+ // When contacts are received from history sync
501
+ client.on('contacts-received', (contacts) => {
502
+ console.log(`Received ${contacts.length} contacts`);
503
+ })
504
+
505
+ // When new contacts are added/updated
506
+ client.on('contacts-upsert', (contacts) => {
507
+ console.log(`New Contacts: ${contacts.length} contacts added/updated`);
508
+ })
509
+
510
+ // When existing contacts are updated (profile picture changes, etc.)
511
+ client.on('contacts-update', (updates) => {
512
+ console.log(`Contact Updates: ${updates.length} contacts modified`);
513
+ })
514
+ ```
515
+
319
516
  ### Message Events
320
517
  ```javascript
321
518
  // When a new message is received
@@ -329,7 +526,14 @@ client.on('message', async msg => {
329
526
  // Handle different message types
330
527
  if (msg.hasMedia) {
331
528
  console.log('Message contains media')
332
- // Handle media message
529
+ // Download media (image/video/audio/document)
530
+ const media = await client.downloadMedia(msg)
531
+ if (media) {
532
+ const fs = require('fs')
533
+ const fileName = `./download-${Date.now()}.${media.extension}`
534
+ fs.writeFileSync(fileName, media.buffer)
535
+ console.log('Saved media to:', fileName)
536
+ }
333
537
  }
334
538
  })
335
539
  ```
@@ -716,3 +920,11 @@ This project is licensed under the MIT License - see the LICENSE file for detail
716
920
  ## Credits
717
921
 
718
922
  Developed by [Innovators Soft](https://facebook.com/innovatorssoft). Based on the [@itsukichan/baileys](https://github.com/itsukichann/baileys) library.
923
+
924
+ # Special Thanks
925
+ - [@whiskeysockets/baileys](https://github.com/whiskeysockets/Baileys)
926
+ - [@itsukichan](https://github.com/itsukichann)
927
+ - [All Contributors](https://github.com/innovatorssoft/Baileys/)
928
+ - [@ZenboBot](https://discordbot.innovatorssoftpk.com/) - AI Powered Baileys Bot
929
+ # Sponsor Me
930
+ Buy me a coffee - [Innovators Soft](https://facebook.com/innovatorssoft)