innovators-bot2 2.0.5 ā 2.0.6
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 +161 -10
- package/example.js +405 -202
- package/example.mp4 +0 -0
- package/index.js +176 -34
- package/package.json +3 -3
package/example.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { WhatsAppClient } = require('./index')
|
|
1
|
+
const { WhatsAppClient, STATUS_BACKGROUNDS, STATUS_FONTS } = require('./index')
|
|
2
2
|
const qrcode = require('qrcode-terminal')
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const readline = require('readline');
|
|
@@ -181,10 +181,22 @@ async function start() {
|
|
|
181
181
|
return
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
|
|
184
185
|
console.log('Message Received');
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
isGroupMsg = msg.isGroup
|
|
189
|
+
if (isGroupMsg) {
|
|
190
|
+
msgFrom = msg.from
|
|
191
|
+
} else {
|
|
192
|
+
msgFrom = msg.sender
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
console.log('Msg From:', msg.from);
|
|
196
|
+
console.log('Msg Sender:', msg.sender);
|
|
197
|
+
console.log('Sender Name:', msg.raw.pushName);
|
|
187
198
|
console.log('Message:', msg.body);
|
|
199
|
+
console.log('Is Group:', msg.isGroup);
|
|
188
200
|
// Mark the message as read
|
|
189
201
|
await client.readMessage(msg.raw.key)
|
|
190
202
|
|
|
@@ -193,32 +205,40 @@ async function start() {
|
|
|
193
205
|
|
|
194
206
|
switch (command) {
|
|
195
207
|
case '!ping':
|
|
196
|
-
await client.sendMessage(
|
|
208
|
+
await client.sendMessage(msgFrom, 'Hello Pong! š')
|
|
197
209
|
break
|
|
198
|
-
|
|
199
210
|
case '!echo':
|
|
200
211
|
if (args) {
|
|
201
|
-
await client.sendMessage(
|
|
212
|
+
await client.sendMessage(msgFrom, args)
|
|
202
213
|
} else {
|
|
203
|
-
await client.sendMessage(
|
|
214
|
+
await client.sendMessage(msgFrom, 'Please provide text to echo')
|
|
204
215
|
}
|
|
205
216
|
break
|
|
206
|
-
|
|
207
217
|
case '!mention':
|
|
208
|
-
const number = msg.
|
|
209
|
-
await client.sendMessage(
|
|
218
|
+
const number = msg.sender.split('@')[0]
|
|
219
|
+
await client.sendMessage(msgFrom, {
|
|
210
220
|
type: 'text',
|
|
211
221
|
text: `Hey @${number}! How are you?`,
|
|
212
|
-
mentions: [
|
|
222
|
+
mentions: [number]
|
|
223
|
+
})
|
|
224
|
+
break
|
|
225
|
+
case '!mentionall':
|
|
226
|
+
if (!isGroupMsg) {
|
|
227
|
+
await client.sendMessage(msgFrom, 'This command is only for groups')
|
|
228
|
+
return
|
|
229
|
+
}
|
|
230
|
+
await client.sendMessage(msgFrom, {
|
|
231
|
+
type: 'text',
|
|
232
|
+
text: `Hey @all! How are you?`,
|
|
233
|
+
mentions: ['@all']
|
|
213
234
|
})
|
|
214
235
|
break
|
|
215
|
-
|
|
216
236
|
case '!reply':
|
|
217
237
|
await msg.reply('This is a reply message')
|
|
218
238
|
break
|
|
219
239
|
|
|
220
240
|
case '!location':
|
|
221
|
-
await client.sendMessage(
|
|
241
|
+
await client.sendMessage(msgFrom, {
|
|
222
242
|
type: 'location',
|
|
223
243
|
latitude: 24.121231,
|
|
224
244
|
longitude: 55.1121221
|
|
@@ -226,7 +246,7 @@ async function start() {
|
|
|
226
246
|
break
|
|
227
247
|
|
|
228
248
|
case '!contact':
|
|
229
|
-
await client.sendMessage(
|
|
249
|
+
await client.sendMessage(msgFrom, {
|
|
230
250
|
type: 'contact',
|
|
231
251
|
fullName: 'John Doe',
|
|
232
252
|
organization: 'Example Corp',
|
|
@@ -236,7 +256,7 @@ async function start() {
|
|
|
236
256
|
|
|
237
257
|
case '!react':
|
|
238
258
|
await client.sendMessage(
|
|
239
|
-
|
|
259
|
+
msgFrom,
|
|
240
260
|
{
|
|
241
261
|
type: 'reaction',
|
|
242
262
|
emoji: 'š',
|
|
@@ -246,24 +266,24 @@ async function start() {
|
|
|
246
266
|
break
|
|
247
267
|
case '!media':
|
|
248
268
|
if (fs.existsSync('./example.jpg')) {
|
|
249
|
-
await client.sendMedia(
|
|
269
|
+
await client.sendMedia(msgFrom, './example.jpg', {
|
|
250
270
|
caption: 'Check out this image!'
|
|
251
271
|
})
|
|
252
272
|
} else {
|
|
253
|
-
await client.sendMessage(
|
|
273
|
+
await client.sendMessage(msgFrom, 'Example image not found')
|
|
254
274
|
}
|
|
255
275
|
break
|
|
256
276
|
|
|
257
277
|
case '!doc':
|
|
258
278
|
if (fs.existsSync('./example.pdf')) {
|
|
259
|
-
await client.sendDocument(
|
|
279
|
+
await client.sendDocument(msgFrom, './example.pdf', 'Check out this document!')
|
|
260
280
|
} else {
|
|
261
|
-
await client.sendMessage(
|
|
281
|
+
await client.sendMessage(msgFrom, 'Example document not found')
|
|
262
282
|
}
|
|
263
283
|
break
|
|
264
284
|
|
|
265
285
|
case '!list':
|
|
266
|
-
await client.SendList(
|
|
286
|
+
await client.SendList(msgFrom, {
|
|
267
287
|
text: 'Please select an option from the list below:',
|
|
268
288
|
title: 'Comprehensive Menu',
|
|
269
289
|
buttonText: 'View All Options',
|
|
@@ -298,7 +318,7 @@ async function start() {
|
|
|
298
318
|
break
|
|
299
319
|
case '!buttons':
|
|
300
320
|
// Example: Send a text interactive message (modern Baileys format)
|
|
301
|
-
await client.sendButtons(
|
|
321
|
+
await client.sendButtons(msgFrom, {
|
|
302
322
|
text: 'Do you like this bot?',
|
|
303
323
|
title: 'Feedback',
|
|
304
324
|
subtitle: 'Let us know!',
|
|
@@ -323,7 +343,7 @@ async function start() {
|
|
|
323
343
|
|
|
324
344
|
// Example: Send an image interactive message (modern Baileys format)
|
|
325
345
|
|
|
326
|
-
await client.sendButtons(
|
|
346
|
+
await client.sendButtons(msgFrom, {
|
|
327
347
|
imagePath: './example.jpg',
|
|
328
348
|
caption: 'here is captions of image\nwith linebreaks', // Keep it short and concise
|
|
329
349
|
title: 'Image Title', // Max 24 chars
|
|
@@ -372,7 +392,7 @@ async function start() {
|
|
|
372
392
|
break
|
|
373
393
|
|
|
374
394
|
case '!quickreplyv2':
|
|
375
|
-
await client.sendQuickReplyV2(
|
|
395
|
+
await client.sendQuickReplyV2(msgFrom, 'Please select an option below:', [
|
|
376
396
|
{ id: 'btn-1', displayText: 'ā
Accept' },
|
|
377
397
|
{ id: 'btn-2', displayText: 'ā Reject' },
|
|
378
398
|
{ id: 'btn-3', displayText: 'š Contact Support' }
|
|
@@ -380,17 +400,17 @@ async function start() {
|
|
|
380
400
|
break
|
|
381
401
|
|
|
382
402
|
case '!urlbuttonv2':
|
|
383
|
-
await client.sendUrlButtonV2(
|
|
403
|
+
await client.sendUrlButtonV2(msgFrom, 'Visit our website for more info', [
|
|
384
404
|
{ displayText: 'š Open Website', url: 'https://example.com' }
|
|
385
405
|
], { title: 'Product Info', footer: 'Click to open' });
|
|
386
406
|
break
|
|
387
407
|
|
|
388
408
|
case '!copycodev2':
|
|
389
|
-
await client.sendCopyCodeV2(
|
|
409
|
+
await client.sendCopyCodeV2(msgFrom, 'Your OTP Code is:', '123456', 'š Copy Code');
|
|
390
410
|
break
|
|
391
411
|
|
|
392
412
|
case '!combinedv2':
|
|
393
|
-
await client.sendCombinedButtonsV2(
|
|
413
|
+
await client.sendCombinedButtonsV2(msgFrom, 'Choose an action:', [
|
|
394
414
|
{ type: 'reply', displayText: 'š Order Now', id: 'order' },
|
|
395
415
|
{ type: 'url', displayText: 'š Website', url: 'https://example.com' },
|
|
396
416
|
{ type: 'call', displayText: 'š Phone', phoneNumber: '+923224559543' },
|
|
@@ -399,7 +419,7 @@ async function start() {
|
|
|
399
419
|
break
|
|
400
420
|
|
|
401
421
|
case '!listv2':
|
|
402
|
-
await client.sendListV2(
|
|
422
|
+
await client.sendListV2(msgFrom, {
|
|
403
423
|
title: 'š Product Menu',
|
|
404
424
|
buttonText: 'View Menu',
|
|
405
425
|
description: 'Please select a product',
|
|
@@ -423,6 +443,90 @@ async function start() {
|
|
|
423
443
|
});
|
|
424
444
|
break
|
|
425
445
|
|
|
446
|
+
case '!cards':
|
|
447
|
+
if (fs.existsSync('./example.jpg')) {
|
|
448
|
+
const imageBuffer = fs.readFileSync('./example.jpg');
|
|
449
|
+
const videoBuffer = fs.readFileSync('./example.mp4');
|
|
450
|
+
|
|
451
|
+
await client.sendcards(msgFrom, {
|
|
452
|
+
text: 'Body Message',
|
|
453
|
+
title: 'Title Message',
|
|
454
|
+
subtile: 'Subtitle Message',
|
|
455
|
+
footer: 'Footer Message',
|
|
456
|
+
cards: [
|
|
457
|
+
{
|
|
458
|
+
image: imageBuffer, // use local buffer
|
|
459
|
+
title: 'Title Cards 1',
|
|
460
|
+
body: 'Body Cards 1',
|
|
461
|
+
footer: 'Footer Cards 1',
|
|
462
|
+
buttons: [
|
|
463
|
+
{
|
|
464
|
+
name: 'quick_reply',
|
|
465
|
+
buttonParamsJson: JSON.stringify({
|
|
466
|
+
display_text: 'Display Button',
|
|
467
|
+
id: 'ID'
|
|
468
|
+
})
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
name: 'cta_url',
|
|
472
|
+
buttonParamsJson: JSON.stringify({
|
|
473
|
+
display_text: 'Display Button',
|
|
474
|
+
url: 'https://www.example.com'
|
|
475
|
+
})
|
|
476
|
+
}
|
|
477
|
+
]
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
video: { url: 'https://files.inqscribe.com/samples/IS_Intro.mp4' },//videoBuffer, // use same local buffer for second card
|
|
481
|
+
title: 'Title Cards 2',
|
|
482
|
+
body: 'Body Cards 2',
|
|
483
|
+
footer: 'Video URL',
|
|
484
|
+
buttons: [
|
|
485
|
+
{
|
|
486
|
+
name: 'quick_reply',
|
|
487
|
+
buttonParamsJson: JSON.stringify({
|
|
488
|
+
display_text: 'Display Button',
|
|
489
|
+
id: 'ID2'
|
|
490
|
+
})
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
name: 'cta_url',
|
|
494
|
+
buttonParamsJson: JSON.stringify({
|
|
495
|
+
display_text: 'Display Button',
|
|
496
|
+
url: 'https://www.example.com'
|
|
497
|
+
})
|
|
498
|
+
}
|
|
499
|
+
]
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
video: videoBuffer, // use same local buffer for second card
|
|
503
|
+
title: 'Title Cards 3',
|
|
504
|
+
body: 'Body Cards 3',
|
|
505
|
+
footer: 'Video Buffer',
|
|
506
|
+
buttons: [
|
|
507
|
+
{
|
|
508
|
+
name: 'quick_reply',
|
|
509
|
+
buttonParamsJson: JSON.stringify({
|
|
510
|
+
display_text: 'Display Button',
|
|
511
|
+
id: 'ID3'
|
|
512
|
+
})
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
name: 'cta_url',
|
|
516
|
+
buttonParamsJson: JSON.stringify({
|
|
517
|
+
display_text: 'Display Button',
|
|
518
|
+
url: 'https://www.example.com'
|
|
519
|
+
})
|
|
520
|
+
}
|
|
521
|
+
]
|
|
522
|
+
}
|
|
523
|
+
]
|
|
524
|
+
});
|
|
525
|
+
} else {
|
|
526
|
+
await client.sendMessage(msgFrom, 'Example image (example.jpg) not found for cards demonstration.');
|
|
527
|
+
}
|
|
528
|
+
break
|
|
529
|
+
|
|
426
530
|
|
|
427
531
|
case '!call':
|
|
428
532
|
try {
|
|
@@ -430,11 +534,11 @@ async function start() {
|
|
|
430
534
|
clearTimeout(autoCancelCallTimer);
|
|
431
535
|
autoCancelCallTimer = null;
|
|
432
536
|
}
|
|
433
|
-
const result = await client.initiateCall(
|
|
537
|
+
const result = await client.initiateCall(msgFrom);
|
|
434
538
|
lastOutgoingCallId = result?.callId || null;
|
|
435
|
-
lastOutgoingCallJid =
|
|
539
|
+
lastOutgoingCallJid = msgFrom;
|
|
436
540
|
|
|
437
|
-
await client.sendMessage(
|
|
541
|
+
await client.sendMessage(msgFrom, `Calling... CallId: ${lastOutgoingCallId || 'unknown'}`);
|
|
438
542
|
|
|
439
543
|
if (lastOutgoingCallId) {
|
|
440
544
|
autoCancelCallTimer = setTimeout(async () => {
|
|
@@ -451,7 +555,7 @@ async function start() {
|
|
|
451
555
|
}
|
|
452
556
|
} catch (error) {
|
|
453
557
|
console.error('Error initiating voice call:', error);
|
|
454
|
-
await client.sendMessage(
|
|
558
|
+
await client.sendMessage(msgFrom, 'Failed to initiate call');
|
|
455
559
|
}
|
|
456
560
|
break
|
|
457
561
|
|
|
@@ -461,10 +565,10 @@ async function start() {
|
|
|
461
565
|
clearTimeout(autoCancelCallTimer);
|
|
462
566
|
autoCancelCallTimer = null;
|
|
463
567
|
}
|
|
464
|
-
const result = await client.initiateCall(
|
|
568
|
+
const result = await client.initiateCall(msgFrom, { isVideo: true });
|
|
465
569
|
lastOutgoingCallId = result?.callId || null;
|
|
466
|
-
lastOutgoingCallJid =
|
|
467
|
-
await client.sendMessage(
|
|
570
|
+
lastOutgoingCallJid = msgFrom;
|
|
571
|
+
await client.sendMessage(msgFrom, `Video calling... CallId: ${lastOutgoingCallId || 'unknown'}`);
|
|
468
572
|
|
|
469
573
|
if (lastOutgoingCallId) {
|
|
470
574
|
autoCancelCallTimer = setTimeout(async () => {
|
|
@@ -481,7 +585,7 @@ async function start() {
|
|
|
481
585
|
}
|
|
482
586
|
} catch (error) {
|
|
483
587
|
console.error('Error initiating video call:', error);
|
|
484
|
-
await client.sendMessage(
|
|
588
|
+
await client.sendMessage(msgFrom, 'Failed to initiate video call');
|
|
485
589
|
}
|
|
486
590
|
break
|
|
487
591
|
|
|
@@ -492,16 +596,16 @@ async function start() {
|
|
|
492
596
|
autoCancelCallTimer = null;
|
|
493
597
|
}
|
|
494
598
|
if (!lastOutgoingCallId) {
|
|
495
|
-
await client.sendMessage(
|
|
599
|
+
await client.sendMessage(msgFrom, 'No outgoing call to cancel');
|
|
496
600
|
break;
|
|
497
601
|
}
|
|
498
|
-
await client.cancelCall(lastOutgoingCallId,
|
|
499
|
-
await client.sendMessage(
|
|
602
|
+
await client.cancelCall(lastOutgoingCallId, msgFrom);
|
|
603
|
+
await client.sendMessage(msgFrom, `Canceled call: ${lastOutgoingCallId}`);
|
|
500
604
|
lastOutgoingCallId = null;
|
|
501
605
|
lastOutgoingCallJid = null;
|
|
502
606
|
} catch (error) {
|
|
503
607
|
console.error('Error canceling call:', error);
|
|
504
|
-
await client.sendMessage(
|
|
608
|
+
await client.sendMessage(msgFrom, 'Failed to cancel call');
|
|
505
609
|
}
|
|
506
610
|
break
|
|
507
611
|
|
|
@@ -564,12 +668,20 @@ async function start() {
|
|
|
564
668
|
|
|
565
669
|
`*šļø Templates & Buttons*\n` +
|
|
566
670
|
`⢠!buttons - Button template\n` +
|
|
567
|
-
`⢠!list - Scrollable list\n` +
|
|
671
|
+
`⢠!list - Scrollable list\n\n` +
|
|
568
672
|
`⢠!quickreplyv2 - Quick reply buttons V2\n` +
|
|
569
673
|
`⢠!urlbuttonv2 - URL button V2\n` +
|
|
570
674
|
`⢠!copycodev2 - Copy code button V2\n` +
|
|
571
675
|
`⢠!combinedv2 - Mixed buttons V2\n` +
|
|
572
|
-
`⢠!listv2 - Interactive list V2\n
|
|
676
|
+
`⢠!listv2 - Interactive list V2\n` +
|
|
677
|
+
`⢠!cards - Interactive cards message\n\n` +
|
|
678
|
+
|
|
679
|
+
`*š¢ Status*\n` +
|
|
680
|
+
`⢠!statustext - Post a text status\n` +
|
|
681
|
+
`⢠!statusimage - Post an image status\n` +
|
|
682
|
+
`⢠!statusvideo - Post a video status\n` +
|
|
683
|
+
`⢠!statusvoice - Post a voice note status\n` +
|
|
684
|
+
`⢠!groupstatus - Post a status directly inside a group (@g.us)\n\n` +
|
|
573
685
|
|
|
574
686
|
`*š Calls*\n` +
|
|
575
687
|
`⢠!call - Initiate a voice call\n` +
|
|
@@ -603,7 +715,7 @@ async function start() {
|
|
|
603
715
|
`⢠!logout - End session\n\n` +
|
|
604
716
|
|
|
605
717
|
`*š Note*:\nReplace <number> with phone number\n(without + or spaces)`
|
|
606
|
-
await client.sendMessage(
|
|
718
|
+
await client.sendMessage(msgFrom, help)
|
|
607
719
|
break
|
|
608
720
|
|
|
609
721
|
case '!groups':
|
|
@@ -619,13 +731,13 @@ async function start() {
|
|
|
619
731
|
if (group.desc) groupList += ` Description: ${group.desc}\n`
|
|
620
732
|
groupList += '\n'
|
|
621
733
|
})
|
|
622
|
-
await client.sendMessage(
|
|
734
|
+
await client.sendMessage(msgFrom, groupList)
|
|
623
735
|
} else {
|
|
624
|
-
await client.sendMessage(
|
|
736
|
+
await client.sendMessage(msgFrom, 'You are not in any groups')
|
|
625
737
|
}
|
|
626
738
|
} catch (error) {
|
|
627
739
|
console.error('Error fetching groups:', error)
|
|
628
|
-
await client.sendMessage(
|
|
740
|
+
await client.sendMessage(msgFrom, 'Failed to fetch groups')
|
|
629
741
|
}
|
|
630
742
|
break
|
|
631
743
|
|
|
@@ -634,7 +746,7 @@ async function start() {
|
|
|
634
746
|
// Use provided group JID or current group
|
|
635
747
|
const groupJid = args.trim() || msg.raw.key.remoteJid
|
|
636
748
|
if (!groupJid || !groupJid.endsWith('@g.us')) {
|
|
637
|
-
await client.sendMessage(
|
|
749
|
+
await client.sendMessage(msgFrom, 'ā Please provide a group JID or use this command in a group.\nUsage: !groupinfo <groupJid>')
|
|
638
750
|
break
|
|
639
751
|
}
|
|
640
752
|
const groupInfo = await client.getGroupMetadata(groupJid)
|
|
@@ -659,18 +771,18 @@ async function start() {
|
|
|
659
771
|
groupList += '\n'
|
|
660
772
|
})
|
|
661
773
|
|
|
662
|
-
await client.sendMessage(
|
|
774
|
+
await client.sendMessage(msgFrom, groupList)
|
|
663
775
|
} else {
|
|
664
|
-
await client.sendMessage(
|
|
776
|
+
await client.sendMessage(msgFrom, 'Group not found')
|
|
665
777
|
}
|
|
666
778
|
} catch (error) {
|
|
667
779
|
console.error('Error fetching group info:', error)
|
|
668
|
-
await client.sendMessage(
|
|
780
|
+
await client.sendMessage(msgFrom, 'Failed to fetch group info')
|
|
669
781
|
}
|
|
670
782
|
break
|
|
671
783
|
case '!logout':
|
|
672
784
|
// Ask for confirmation before logging out
|
|
673
|
-
await client.sendButtons(
|
|
785
|
+
await client.sendButtons(msgFrom, {
|
|
674
786
|
text: 'Are you sure you want to logout?',
|
|
675
787
|
title: 'Logout Confirmation',
|
|
676
788
|
footer: 'Choose Yes to logout or No to cancel',
|
|
@@ -697,26 +809,26 @@ async function start() {
|
|
|
697
809
|
case 'yes':
|
|
698
810
|
case 'logout_yes':
|
|
699
811
|
|
|
700
|
-
await client.sendMessage(
|
|
812
|
+
await client.sendMessage(msgFrom, 'You have been logged out.');
|
|
701
813
|
await client.logout();
|
|
702
814
|
break;
|
|
703
815
|
case 'No':
|
|
704
816
|
case 'no':
|
|
705
817
|
case 'logout_no':
|
|
706
|
-
await client.sendMessage(
|
|
818
|
+
await client.sendMessage(msgFrom, 'Logout cancelled.');
|
|
707
819
|
break;
|
|
708
820
|
case '!lid':
|
|
709
821
|
// Get LID for the user's phone number
|
|
710
822
|
try {
|
|
711
|
-
const lid = await client.getLIDForPN(
|
|
823
|
+
const lid = await client.getLIDForPN(msgFrom);
|
|
712
824
|
if (lid) {
|
|
713
|
-
await client.sendMessage(
|
|
825
|
+
await client.sendMessage(msgFrom, `Your LID: ${lid}\nYour PN: ${msgFrom}`);
|
|
714
826
|
} else {
|
|
715
|
-
await client.sendMessage(
|
|
827
|
+
await client.sendMessage(msgFrom, `No LID found for ${msgFrom}. You might be using a PN-only session.`);
|
|
716
828
|
}
|
|
717
829
|
} catch (error) {
|
|
718
830
|
console.error('Error getting LID:', error);
|
|
719
|
-
await client.sendMessage(
|
|
831
|
+
await client.sendMessage(msgFrom, 'Failed to get LID.');
|
|
720
832
|
}
|
|
721
833
|
break;
|
|
722
834
|
|
|
@@ -725,23 +837,23 @@ async function start() {
|
|
|
725
837
|
try {
|
|
726
838
|
const lidToCheck = args.trim();
|
|
727
839
|
if (!lidToCheck) {
|
|
728
|
-
await client.sendMessage(
|
|
840
|
+
await client.sendMessage(msgFrom, 'Please provide a LID. Example: !pn 123456@lid');
|
|
729
841
|
break;
|
|
730
842
|
}
|
|
731
843
|
const pn = await client.getPNForLID(lidToCheck);
|
|
732
844
|
if (pn) {
|
|
733
|
-
await client.sendMessage(
|
|
845
|
+
await client.sendMessage(msgFrom, `Phone Number for ${lidToCheck}: ${pn}`);
|
|
734
846
|
} else {
|
|
735
|
-
await client.sendMessage(
|
|
847
|
+
await client.sendMessage(msgFrom, `No phone number found for LID: ${lidToCheck}`);
|
|
736
848
|
}
|
|
737
849
|
} catch (error) {
|
|
738
850
|
console.error('Error getting PN from LID:', error);
|
|
739
|
-
await client.sendMessage(
|
|
851
|
+
await client.sendMessage(msgFrom, 'Failed to get phone number.');
|
|
740
852
|
}
|
|
741
853
|
break;
|
|
742
854
|
case '!ad':
|
|
743
855
|
await client.sendAdReply(
|
|
744
|
-
|
|
856
|
+
msgFrom,
|
|
745
857
|
'Ad Message',
|
|
746
858
|
'./example.jpg',
|
|
747
859
|
'Ad Title',
|
|
@@ -754,82 +866,82 @@ async function start() {
|
|
|
754
866
|
if (fs.existsSync('./example.jpg')) {
|
|
755
867
|
const path = './example.jpg';
|
|
756
868
|
const imageBuffer = fs.readFileSync(path);
|
|
757
|
-
await client.sendSticker(
|
|
869
|
+
await client.sendSticker(msgFrom, imageBuffer, { packName: 'Innovators', author: 'Innovators Soft' });
|
|
758
870
|
} else {
|
|
759
|
-
await client.sendMessage(
|
|
871
|
+
await client.sendMessage(msgFrom, 'Example image (jpg) not found')
|
|
760
872
|
}
|
|
761
873
|
break;
|
|
762
874
|
|
|
763
875
|
case '!parse':
|
|
764
876
|
if (args) {
|
|
765
877
|
const info = client.parseJid(args);
|
|
766
|
-
await client.sendMessage(
|
|
878
|
+
await client.sendMessage(msgFrom, `*JID Info:*\n\nUser: ${info.user}\nServer: ${info.server}\nIs LID: ${info.isLid}`);
|
|
767
879
|
} else {
|
|
768
|
-
await client.sendMessage(
|
|
880
|
+
await client.sendMessage(msgFrom, 'Please provide a JID to parse');
|
|
769
881
|
}
|
|
770
882
|
break;
|
|
771
883
|
|
|
772
884
|
case '!normalize':
|
|
773
885
|
if (args) {
|
|
774
886
|
const jid = client.normalizePhoneToJid(args);
|
|
775
|
-
await client.sendMessage(
|
|
887
|
+
await client.sendMessage(msgFrom, `*Normalized JID:* ${jid}`);
|
|
776
888
|
} else {
|
|
777
|
-
await client.sendMessage(
|
|
889
|
+
await client.sendMessage(msgFrom, 'Please provide a phone number');
|
|
778
890
|
}
|
|
779
891
|
break;
|
|
780
892
|
|
|
781
893
|
case '!typing':
|
|
782
|
-
await client.sendStateTyping(
|
|
783
|
-
await client.sendMessage(
|
|
894
|
+
await client.sendStateTyping(msgFrom);
|
|
895
|
+
await client.sendMessage(msgFrom, 'Typing indicator sent!');
|
|
784
896
|
break;
|
|
785
897
|
|
|
786
898
|
case '!recording':
|
|
787
|
-
await client.sendStateRecording(
|
|
788
|
-
await client.sendMessage(
|
|
899
|
+
await client.sendStateRecording(msgFrom);
|
|
900
|
+
await client.sendMessage(msgFrom, 'Recording indicator sent!');
|
|
789
901
|
break;
|
|
790
902
|
|
|
791
903
|
case '!paused':
|
|
792
|
-
await client.clearState(
|
|
793
|
-
await client.sendMessage(
|
|
904
|
+
await client.clearState(msgFrom);
|
|
905
|
+
await client.sendMessage(msgFrom, 'Stopped typing/recording indicator sent!');
|
|
794
906
|
break;
|
|
795
907
|
|
|
796
908
|
case '!typing_simulate':
|
|
797
909
|
// Show "typing..." for 5 seconds, then send the message ā all in one call
|
|
798
|
-
await client.sendMessage(
|
|
910
|
+
await client.sendMessage(msgFrom, 'Simulating typing for 5 seconds...');
|
|
799
911
|
const typing = client.createPresenceController();
|
|
800
|
-
await typing.simulateTyping(
|
|
801
|
-
await client.sendMessage(
|
|
912
|
+
await typing.simulateTyping(msgFrom, 5000, async () => {
|
|
913
|
+
await client.sendMessage(msgFrom, 'This message was sent after 5 seconds of typing! ā
');
|
|
802
914
|
});
|
|
803
915
|
break;
|
|
804
916
|
|
|
805
917
|
case '!typing_start':
|
|
806
918
|
// Manual start (auto-pauses after 5 s by default if not specified)
|
|
807
919
|
const typingStart = client.createPresenceController();
|
|
808
|
-
await typingStart.startTyping(
|
|
809
|
-
await client.sendMessage(
|
|
920
|
+
await typingStart.startTyping(msgFrom, { duration: 10000 }); // Show for 10s
|
|
921
|
+
await client.sendMessage(msgFrom, 'Typing indicator started for 10 seconds.');
|
|
810
922
|
break;
|
|
811
923
|
|
|
812
924
|
case '!typing_stop':
|
|
813
925
|
const typingStop = client.createPresenceController();
|
|
814
|
-
await typingStop.stopTyping(
|
|
815
|
-
await client.sendMessage(
|
|
926
|
+
await typingStop.stopTyping(msgFrom);
|
|
927
|
+
await client.sendMessage(msgFrom, 'Typing indicator stopped.');
|
|
816
928
|
break;
|
|
817
929
|
|
|
818
930
|
case '!recording_start':
|
|
819
931
|
const recordingIndicator = client.createPresenceController();
|
|
820
|
-
await recordingIndicator.startRecording(
|
|
821
|
-
await client.sendMessage(
|
|
932
|
+
await recordingIndicator.startRecording(msgFrom, { duration: 5000 });
|
|
933
|
+
await client.sendMessage(msgFrom, 'Recording indicator started for 5 seconds.');
|
|
822
934
|
break;
|
|
823
935
|
|
|
824
936
|
case '!typing_stop_all':
|
|
825
937
|
const typingStopAll = client.createPresenceController();
|
|
826
938
|
await typingStopAll.stopAll();
|
|
827
|
-
await client.sendMessage(
|
|
939
|
+
await client.sendMessage(msgFrom, 'All active indicators for this controller stopped.');
|
|
828
940
|
break;
|
|
829
941
|
|
|
830
942
|
case '!read':
|
|
831
943
|
await client.readMessage(msg.raw.key);
|
|
832
|
-
await client.sendMessage(
|
|
944
|
+
await client.sendMessage(msgFrom, 'Message marked as read!');
|
|
833
945
|
break;
|
|
834
946
|
|
|
835
947
|
case '!add':
|
|
@@ -838,7 +950,7 @@ async function start() {
|
|
|
838
950
|
case '!demote':
|
|
839
951
|
try {
|
|
840
952
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
841
|
-
await client.sendMessage(
|
|
953
|
+
await client.sendMessage(msgFrom, 'This command can only be used in groups')
|
|
842
954
|
break
|
|
843
955
|
}
|
|
844
956
|
|
|
@@ -846,7 +958,7 @@ async function start() {
|
|
|
846
958
|
|
|
847
959
|
// Validate phone number format
|
|
848
960
|
if (!rawNumber || rawNumber.length < 10) {
|
|
849
|
-
await client.sendMessage(
|
|
961
|
+
await client.sendMessage(msgFrom,
|
|
850
962
|
`ā Invalid phone number format.\n\n` +
|
|
851
963
|
`ā
Correct format: !${command.slice(1)} 923001234567\n` +
|
|
852
964
|
`(Include country code without + or spaces)`
|
|
@@ -856,7 +968,7 @@ async function start() {
|
|
|
856
968
|
|
|
857
969
|
// Ensure country code is present (check if starts with common codes)
|
|
858
970
|
if (rawNumber.startsWith('0')) {
|
|
859
|
-
await client.sendMessage(
|
|
971
|
+
await client.sendMessage(msgFrom,
|
|
860
972
|
`ā Phone number must include country code.\n\n` +
|
|
861
973
|
`Example:\n` +
|
|
862
974
|
`⢠Pakistan: 923001234567 (not 03001234567)\n` +
|
|
@@ -885,18 +997,18 @@ async function start() {
|
|
|
885
997
|
}
|
|
886
998
|
|
|
887
999
|
if (result[0].status == 200) {
|
|
888
|
-
await client.sendMessage(
|
|
1000
|
+
await client.sendMessage(msgFrom, `Successfully ${actionMap[action]} the group`)
|
|
889
1001
|
} else if (result[0].status == 403 && result[0].invitationSent) {
|
|
890
|
-
await client.sendMessage(
|
|
1002
|
+
await client.sendMessage(msgFrom, `ā ļø Could not add directly due to privacy settings.\nā
Group invitation link has been sent to the user instead!`)
|
|
891
1003
|
} else {
|
|
892
|
-
await client.sendMessage(
|
|
1004
|
+
await client.sendMessage(msgFrom, `Failed to ${action} participant: ${result[0].message || result[0].content || result[0].error || 'Unknown error'}`)
|
|
893
1005
|
}
|
|
894
1006
|
} catch (error) {
|
|
895
1007
|
console.error(`Error ${command} participant:`, error)
|
|
896
1008
|
if (error.output?.statusCode === 408) {
|
|
897
|
-
await client.sendMessage(
|
|
1009
|
+
await client.sendMessage(msgFrom, `ā±ļø Request timed out. The number might be invalid or not on WhatsApp.`)
|
|
898
1010
|
} else {
|
|
899
|
-
await client.sendMessage(
|
|
1011
|
+
await client.sendMessage(msgFrom, `Failed to ${command.slice(1)} participant: ${error.message || 'Unknown error'}`)
|
|
900
1012
|
}
|
|
901
1013
|
}
|
|
902
1014
|
break
|
|
@@ -905,7 +1017,7 @@ async function start() {
|
|
|
905
1017
|
case '!invite':
|
|
906
1018
|
try {
|
|
907
1019
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
908
|
-
await client.sendMessage(
|
|
1020
|
+
await client.sendMessage(msgFrom, 'This command can only be used in groups')
|
|
909
1021
|
break
|
|
910
1022
|
}
|
|
911
1023
|
|
|
@@ -913,7 +1025,7 @@ async function start() {
|
|
|
913
1025
|
|
|
914
1026
|
// Validate phone number format
|
|
915
1027
|
if (!rawInviteNumber || rawInviteNumber.length < 10) {
|
|
916
|
-
await client.sendMessage(
|
|
1028
|
+
await client.sendMessage(msgFrom,
|
|
917
1029
|
`ā Invalid phone number format.\n\n` +
|
|
918
1030
|
`ā
Correct format: !invite 923001234567\n` +
|
|
919
1031
|
`(Include country code without + or spaces)`
|
|
@@ -923,7 +1035,7 @@ async function start() {
|
|
|
923
1035
|
|
|
924
1036
|
// Ensure country code is present
|
|
925
1037
|
if (rawInviteNumber.startsWith('0')) {
|
|
926
|
-
await client.sendMessage(
|
|
1038
|
+
await client.sendMessage(msgFrom,
|
|
927
1039
|
`ā Phone number must include country code.\n\n` +
|
|
928
1040
|
`Example:\n` +
|
|
929
1041
|
`⢠Pakistan: 923001234567 (not 03001234567)\n` +
|
|
@@ -936,13 +1048,13 @@ async function start() {
|
|
|
936
1048
|
const inviteNumber = rawInviteNumber + '@s.whatsapp.net'
|
|
937
1049
|
|
|
938
1050
|
await client.sendGroupInvitation(msg.raw.key.remoteJid, inviteNumber)
|
|
939
|
-
await client.sendMessage(
|
|
1051
|
+
await client.sendMessage(msgFrom, `ā
Group invitation sent to ${rawInviteNumber}`)
|
|
940
1052
|
} catch (error) {
|
|
941
1053
|
console.error('Error sending invitation:', error)
|
|
942
1054
|
if (error.output?.statusCode === 408) {
|
|
943
|
-
await client.sendMessage(
|
|
1055
|
+
await client.sendMessage(msgFrom, `ā±ļø Request timed out. The number might be invalid or not on WhatsApp.`)
|
|
944
1056
|
} else {
|
|
945
|
-
await client.sendMessage(
|
|
1057
|
+
await client.sendMessage(msgFrom, `Failed to send group invitation: ${error.message || 'Unknown error'}`)
|
|
946
1058
|
}
|
|
947
1059
|
}
|
|
948
1060
|
break
|
|
@@ -954,61 +1066,61 @@ async function start() {
|
|
|
954
1066
|
case '!creategroup':
|
|
955
1067
|
try {
|
|
956
1068
|
if (!args) {
|
|
957
|
-
await client.sendMessage(
|
|
1069
|
+
await client.sendMessage(msgFrom, 'ā Please provide a group name.\nUsage: !creategroup My New Group');
|
|
958
1070
|
break;
|
|
959
1071
|
}
|
|
960
|
-
const newGroup = await client.createGroup(args, [
|
|
961
|
-
await client.sendMessage(
|
|
1072
|
+
const newGroup = await client.createGroup(args, [msgFrom]);
|
|
1073
|
+
await client.sendMessage(msgFrom, `ā
Group created!\n\nName: *${args}*\nID: ${newGroup.id || newGroup.gid}`);
|
|
962
1074
|
} catch (error) {
|
|
963
1075
|
console.error('Error creating group:', error);
|
|
964
|
-
await client.sendMessage(
|
|
1076
|
+
await client.sendMessage(msgFrom, `ā Failed to create group: ${error.message}`);
|
|
965
1077
|
}
|
|
966
1078
|
break;
|
|
967
1079
|
|
|
968
1080
|
case '!groupsubject':
|
|
969
1081
|
try {
|
|
970
1082
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
971
|
-
await client.sendMessage(
|
|
1083
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
972
1084
|
break;
|
|
973
1085
|
}
|
|
974
1086
|
if (!args) {
|
|
975
|
-
await client.sendMessage(
|
|
1087
|
+
await client.sendMessage(msgFrom, 'ā Please provide a new group name.\nUsage: !groupsubject New Name');
|
|
976
1088
|
break;
|
|
977
1089
|
}
|
|
978
1090
|
await client.changeGroupSubject(msg.raw.key.remoteJid, args);
|
|
979
|
-
await client.sendMessage(
|
|
1091
|
+
await client.sendMessage(msgFrom, `ā
Group name changed to: *${args}*`);
|
|
980
1092
|
} catch (error) {
|
|
981
1093
|
console.error('Error changing group subject:', error);
|
|
982
|
-
await client.sendMessage(
|
|
1094
|
+
await client.sendMessage(msgFrom, `ā Failed to change group name: ${error.message}`);
|
|
983
1095
|
}
|
|
984
1096
|
break;
|
|
985
1097
|
|
|
986
1098
|
case '!groupdesc':
|
|
987
1099
|
try {
|
|
988
1100
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
989
|
-
await client.sendMessage(
|
|
1101
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
990
1102
|
break;
|
|
991
1103
|
}
|
|
992
1104
|
if (!args) {
|
|
993
|
-
await client.sendMessage(
|
|
1105
|
+
await client.sendMessage(msgFrom, 'ā Please provide a new description.\nUsage: !groupdesc New description here');
|
|
994
1106
|
break;
|
|
995
1107
|
}
|
|
996
1108
|
await client.changeGroupDescription(msg.raw.key.remoteJid, args);
|
|
997
|
-
await client.sendMessage(
|
|
1109
|
+
await client.sendMessage(msgFrom, `ā
Group description updated!`);
|
|
998
1110
|
} catch (error) {
|
|
999
1111
|
console.error('Error changing group description:', error);
|
|
1000
|
-
await client.sendMessage(
|
|
1112
|
+
await client.sendMessage(msgFrom, `ā Failed to change description: ${error.message}`);
|
|
1001
1113
|
}
|
|
1002
1114
|
break;
|
|
1003
1115
|
|
|
1004
1116
|
case '!groupsetting':
|
|
1005
1117
|
try {
|
|
1006
1118
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
1007
|
-
await client.sendMessage(
|
|
1119
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
1008
1120
|
break;
|
|
1009
1121
|
}
|
|
1010
1122
|
if (!args || !['announcement', 'not_announcement', 'locked', 'unlocked'].includes(args.trim())) {
|
|
1011
|
-
await client.sendMessage(
|
|
1123
|
+
await client.sendMessage(msgFrom,
|
|
1012
1124
|
`ā Invalid setting.\n\n` +
|
|
1013
1125
|
`Usage: !groupsetting <setting>\n\n` +
|
|
1014
1126
|
`Available settings:\n` +
|
|
@@ -1020,66 +1132,66 @@ async function start() {
|
|
|
1020
1132
|
break;
|
|
1021
1133
|
}
|
|
1022
1134
|
await client.changeGroupSettings(msg.raw.key.remoteJid, args.trim());
|
|
1023
|
-
await client.sendMessage(
|
|
1135
|
+
await client.sendMessage(msgFrom, `ā
Group setting changed to: *${args.trim()}*`);
|
|
1024
1136
|
} catch (error) {
|
|
1025
1137
|
console.error('Error changing group settings:', error);
|
|
1026
|
-
await client.sendMessage(
|
|
1138
|
+
await client.sendMessage(msgFrom, `ā Failed to change setting: ${error.message}`);
|
|
1027
1139
|
}
|
|
1028
1140
|
break;
|
|
1029
1141
|
|
|
1030
1142
|
case '!invitecode':
|
|
1031
1143
|
try {
|
|
1032
1144
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
1033
|
-
await client.sendMessage(
|
|
1145
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
1034
1146
|
break;
|
|
1035
1147
|
}
|
|
1036
1148
|
const inviteCode = await client.getGroupInviteCode(msg.raw.key.remoteJid);
|
|
1037
|
-
await client.sendMessage(
|
|
1149
|
+
await client.sendMessage(msgFrom, `ā
Group Invite Link:\nhttps://chat.whatsapp.com/${inviteCode}`);
|
|
1038
1150
|
} catch (error) {
|
|
1039
1151
|
console.error('Error getting invite code:', error);
|
|
1040
|
-
await client.sendMessage(
|
|
1152
|
+
await client.sendMessage(msgFrom, `ā Failed to get invite code: ${error.message}`);
|
|
1041
1153
|
}
|
|
1042
1154
|
break;
|
|
1043
1155
|
|
|
1044
1156
|
case '!revokeinvite':
|
|
1045
1157
|
try {
|
|
1046
1158
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
1047
|
-
await client.sendMessage(
|
|
1159
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
1048
1160
|
break;
|
|
1049
1161
|
}
|
|
1050
1162
|
const newInviteCode = await client.revokeGroupInviteCode(msg.raw.key.remoteJid);
|
|
1051
|
-
await client.sendMessage(
|
|
1163
|
+
await client.sendMessage(msgFrom, `ā
Invite code revoked!\nNew invite link:\nhttps://chat.whatsapp.com/${newInviteCode}`);
|
|
1052
1164
|
} catch (error) {
|
|
1053
1165
|
console.error('Error revoking invite code:', error);
|
|
1054
|
-
await client.sendMessage(
|
|
1166
|
+
await client.sendMessage(msgFrom, `ā Failed to revoke invite code: ${error.message}`);
|
|
1055
1167
|
}
|
|
1056
1168
|
break;
|
|
1057
1169
|
|
|
1058
1170
|
case '!leavegroup':
|
|
1059
1171
|
try {
|
|
1060
1172
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
1061
|
-
await client.sendMessage(
|
|
1173
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
1062
1174
|
break;
|
|
1063
1175
|
}
|
|
1064
|
-
await client.sendMessage(
|
|
1176
|
+
await client.sendMessage(msgFrom, 'š Leaving group...');
|
|
1065
1177
|
await client.leaveGroup(msg.raw.key.remoteJid);
|
|
1066
1178
|
} catch (error) {
|
|
1067
1179
|
console.error('Error leaving group:', error);
|
|
1068
|
-
await client.sendMessage(
|
|
1180
|
+
await client.sendMessage(msgFrom, `ā Failed to leave group: ${error.message}`);
|
|
1069
1181
|
}
|
|
1070
1182
|
break;
|
|
1071
1183
|
|
|
1072
1184
|
case '!joingroup':
|
|
1073
1185
|
try {
|
|
1074
1186
|
if (!args) {
|
|
1075
|
-
await client.sendMessage(
|
|
1187
|
+
await client.sendMessage(msgFrom, 'ā Please provide an invite code.\nUsage: !joingroup AbCdEfGhIjK\n(or full link: !joingroup https://chat.whatsapp.com/AbCdEfGhIjK)');
|
|
1076
1188
|
break;
|
|
1077
1189
|
}
|
|
1078
1190
|
const joinedGroupId = await client.joinGroupByInviteCode(args.trim());
|
|
1079
|
-
await client.sendMessage(
|
|
1191
|
+
await client.sendMessage(msgFrom, `ā
Successfully joined group!\nGroup ID: ${joinedGroupId}`);
|
|
1080
1192
|
} catch (error) {
|
|
1081
1193
|
console.error('Error joining group:', error);
|
|
1082
|
-
await client.sendMessage(
|
|
1194
|
+
await client.sendMessage(msgFrom, `ā Failed to join group: ${error.message}`);
|
|
1083
1195
|
}
|
|
1084
1196
|
break;
|
|
1085
1197
|
|
|
@@ -1091,7 +1203,7 @@ async function start() {
|
|
|
1091
1203
|
if (!input) {
|
|
1092
1204
|
// No args: use current group
|
|
1093
1205
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
1094
|
-
await client.sendMessage(
|
|
1206
|
+
await client.sendMessage(msgFrom, 'ā Use this command in a group, or provide a group JID / invite code.\nUsage:\n⢠!groupinfo (in a group)\n⢠!groupinfo 120363xxxxx@g.us\n⢠!groupinfo AbCdEfGhIjK')
|
|
1095
1207
|
break
|
|
1096
1208
|
}
|
|
1097
1209
|
groupInfoResult = await client.getGroupMetadata(msg.raw.key.remoteJid)
|
|
@@ -1104,7 +1216,7 @@ async function start() {
|
|
|
1104
1216
|
}
|
|
1105
1217
|
|
|
1106
1218
|
if (!groupInfoResult) {
|
|
1107
|
-
await client.sendMessage(
|
|
1219
|
+
await client.sendMessage(msgFrom, 'ā Group not found.')
|
|
1108
1220
|
break
|
|
1109
1221
|
}
|
|
1110
1222
|
|
|
@@ -1140,17 +1252,17 @@ async function start() {
|
|
|
1140
1252
|
})
|
|
1141
1253
|
}
|
|
1142
1254
|
|
|
1143
|
-
await client.sendMessage(
|
|
1255
|
+
await client.sendMessage(msgFrom, infoText)
|
|
1144
1256
|
} catch (error) {
|
|
1145
1257
|
console.error('Error getting group info:', error)
|
|
1146
|
-
await client.sendMessage(
|
|
1258
|
+
await client.sendMessage(msgFrom, `ā Failed to get group info: ${error.message}`)
|
|
1147
1259
|
}
|
|
1148
1260
|
break;
|
|
1149
1261
|
|
|
1150
1262
|
case '!joinrequests':
|
|
1151
1263
|
try {
|
|
1152
1264
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
1153
|
-
await client.sendMessage(
|
|
1265
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
1154
1266
|
break;
|
|
1155
1267
|
}
|
|
1156
1268
|
const requests = await client.getGroupJoinRequests(msg.raw.key.remoteJid);
|
|
@@ -1161,63 +1273,63 @@ async function start() {
|
|
|
1161
1273
|
if (req.request_time) requestList += ` Requested: ${new Date(req.request_time * 1000).toLocaleString()}\n`;
|
|
1162
1274
|
});
|
|
1163
1275
|
requestList += `\nUse !approvejoin or !rejectjoin <number> to respond`;
|
|
1164
|
-
await client.sendMessage(
|
|
1276
|
+
await client.sendMessage(msgFrom, requestList);
|
|
1165
1277
|
} else {
|
|
1166
|
-
await client.sendMessage(
|
|
1278
|
+
await client.sendMessage(msgFrom, 'ā
No pending join requests.');
|
|
1167
1279
|
}
|
|
1168
1280
|
} catch (error) {
|
|
1169
1281
|
console.error('Error getting join requests:', error);
|
|
1170
|
-
await client.sendMessage(
|
|
1282
|
+
await client.sendMessage(msgFrom, `ā Failed to get join requests: ${error.message}`);
|
|
1171
1283
|
}
|
|
1172
1284
|
break;
|
|
1173
1285
|
|
|
1174
1286
|
case '!approvejoin':
|
|
1175
1287
|
try {
|
|
1176
1288
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
1177
|
-
await client.sendMessage(
|
|
1289
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
1178
1290
|
break;
|
|
1179
1291
|
}
|
|
1180
1292
|
const approveNum = args?.replace(/[^0-9]/g, '');
|
|
1181
1293
|
if (!approveNum || approveNum.length < 10) {
|
|
1182
|
-
await client.sendMessage(
|
|
1294
|
+
await client.sendMessage(msgFrom, 'ā Please provide a valid phone number.\nUsage: !approvejoin 923001234567');
|
|
1183
1295
|
break;
|
|
1184
1296
|
}
|
|
1185
1297
|
const approveResult = await client.handleGroupJoinRequest(msg.raw.key.remoteJid, [approveNum + '@s.whatsapp.net'], 'approve');
|
|
1186
|
-
await client.sendMessage(
|
|
1298
|
+
await client.sendMessage(msgFrom, `ā
Join request approved for ${approveNum}`);
|
|
1187
1299
|
} catch (error) {
|
|
1188
1300
|
console.error('Error approving join request:', error);
|
|
1189
|
-
await client.sendMessage(
|
|
1301
|
+
await client.sendMessage(msgFrom, `ā Failed to approve: ${error.message}`);
|
|
1190
1302
|
}
|
|
1191
1303
|
break;
|
|
1192
1304
|
|
|
1193
1305
|
case '!rejectjoin':
|
|
1194
1306
|
try {
|
|
1195
1307
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
1196
|
-
await client.sendMessage(
|
|
1308
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
1197
1309
|
break;
|
|
1198
1310
|
}
|
|
1199
1311
|
const rejectNum = args?.replace(/[^0-9]/g, '');
|
|
1200
1312
|
if (!rejectNum || rejectNum.length < 10) {
|
|
1201
|
-
await client.sendMessage(
|
|
1313
|
+
await client.sendMessage(msgFrom, 'ā Please provide a valid phone number.\nUsage: !rejectjoin 923001234567');
|
|
1202
1314
|
break;
|
|
1203
1315
|
}
|
|
1204
1316
|
const rejectResult = await client.handleGroupJoinRequest(msg.raw.key.remoteJid, [rejectNum + '@s.whatsapp.net'], 'reject');
|
|
1205
|
-
await client.sendMessage(
|
|
1317
|
+
await client.sendMessage(msgFrom, `ā
Join request rejected for ${rejectNum}`);
|
|
1206
1318
|
} catch (error) {
|
|
1207
1319
|
console.error('Error rejecting join request:', error);
|
|
1208
|
-
await client.sendMessage(
|
|
1320
|
+
await client.sendMessage(msgFrom, `ā Failed to reject: ${error.message}`);
|
|
1209
1321
|
}
|
|
1210
1322
|
break;
|
|
1211
1323
|
|
|
1212
1324
|
case '!ephemeral':
|
|
1213
1325
|
try {
|
|
1214
1326
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
1215
|
-
await client.sendMessage(
|
|
1327
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
1216
1328
|
break;
|
|
1217
1329
|
}
|
|
1218
1330
|
const ephemeralSeconds = parseInt(args);
|
|
1219
1331
|
if (isNaN(ephemeralSeconds)) {
|
|
1220
|
-
await client.sendMessage(
|
|
1332
|
+
await client.sendMessage(msgFrom,
|
|
1221
1333
|
`ā Please provide duration in seconds.\n\n` +
|
|
1222
1334
|
`Usage: !ephemeral <seconds>\n\n` +
|
|
1223
1335
|
`Options:\n` +
|
|
@@ -1230,21 +1342,21 @@ async function start() {
|
|
|
1230
1342
|
}
|
|
1231
1343
|
await client.toggleGroupEphemeral(msg.raw.key.remoteJid, ephemeralSeconds);
|
|
1232
1344
|
const durationText = ephemeralSeconds === 0 ? 'OFF' : `${ephemeralSeconds} seconds`;
|
|
1233
|
-
await client.sendMessage(
|
|
1345
|
+
await client.sendMessage(msgFrom, `ā
Disappearing messages set to: *${durationText}*`);
|
|
1234
1346
|
} catch (error) {
|
|
1235
1347
|
console.error('Error toggling ephemeral:', error);
|
|
1236
|
-
await client.sendMessage(
|
|
1348
|
+
await client.sendMessage(msgFrom, `ā Failed to toggle disappearing messages: ${error.message}`);
|
|
1237
1349
|
}
|
|
1238
1350
|
break;
|
|
1239
1351
|
|
|
1240
1352
|
case '!addmode':
|
|
1241
1353
|
try {
|
|
1242
1354
|
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
1243
|
-
await client.sendMessage(
|
|
1355
|
+
await client.sendMessage(msgFrom, 'ā This command can only be used in groups');
|
|
1244
1356
|
break;
|
|
1245
1357
|
}
|
|
1246
1358
|
if (!args || !['all_member_add', 'admin_add'].includes(args.trim())) {
|
|
1247
|
-
await client.sendMessage(
|
|
1359
|
+
await client.sendMessage(msgFrom,
|
|
1248
1360
|
`ā Invalid mode.\n\n` +
|
|
1249
1361
|
`Usage: !addmode <mode>\n\n` +
|
|
1250
1362
|
`Options:\n` +
|
|
@@ -1254,10 +1366,10 @@ async function start() {
|
|
|
1254
1366
|
break;
|
|
1255
1367
|
}
|
|
1256
1368
|
await client.changeGroupAddMode(msg.raw.key.remoteJid, args.trim());
|
|
1257
|
-
await client.sendMessage(
|
|
1369
|
+
await client.sendMessage(msgFrom, `ā
Group add mode changed to: *${args.trim()}*`);
|
|
1258
1370
|
} catch (error) {
|
|
1259
1371
|
console.error('Error changing add mode:', error);
|
|
1260
|
-
await client.sendMessage(
|
|
1372
|
+
await client.sendMessage(msgFrom, `ā Failed to change add mode: ${error.message}`);
|
|
1261
1373
|
}
|
|
1262
1374
|
break;
|
|
1263
1375
|
|
|
@@ -1269,14 +1381,14 @@ async function start() {
|
|
|
1269
1381
|
try {
|
|
1270
1382
|
const blockNum = args?.replace(/[^0-9]/g, '');
|
|
1271
1383
|
if (!blockNum || blockNum.length < 10) {
|
|
1272
|
-
await client.sendMessage(
|
|
1384
|
+
await client.sendMessage(msgFrom, 'ā Please provide a valid phone number.\nUsage: !block 923001234567');
|
|
1273
1385
|
break;
|
|
1274
1386
|
}
|
|
1275
1387
|
await client.blockUser(blockNum + '@s.whatsapp.net');
|
|
1276
|
-
await client.sendMessage(
|
|
1388
|
+
await client.sendMessage(msgFrom, `ā
User ${blockNum} has been blocked.`);
|
|
1277
1389
|
} catch (error) {
|
|
1278
1390
|
console.error('Error blocking user:', error);
|
|
1279
|
-
await client.sendMessage(
|
|
1391
|
+
await client.sendMessage(msgFrom, `ā Failed to block user: ${error.message}`);
|
|
1280
1392
|
}
|
|
1281
1393
|
break;
|
|
1282
1394
|
|
|
@@ -1284,14 +1396,14 @@ async function start() {
|
|
|
1284
1396
|
try {
|
|
1285
1397
|
const unblockNum = args?.replace(/[^0-9]/g, '');
|
|
1286
1398
|
if (!unblockNum || unblockNum.length < 10) {
|
|
1287
|
-
await client.sendMessage(
|
|
1399
|
+
await client.sendMessage(msgFrom, 'ā Please provide a valid phone number.\nUsage: !unblock 923001234567');
|
|
1288
1400
|
break;
|
|
1289
1401
|
}
|
|
1290
1402
|
await client.unblockUser(unblockNum + '@s.whatsapp.net');
|
|
1291
|
-
await client.sendMessage(
|
|
1403
|
+
await client.sendMessage(msgFrom, `ā
User ${unblockNum} has been unblocked.`);
|
|
1292
1404
|
} catch (error) {
|
|
1293
1405
|
console.error('Error unblocking user:', error);
|
|
1294
|
-
await client.sendMessage(
|
|
1406
|
+
await client.sendMessage(msgFrom, `ā Failed to unblock user: ${error.message}`);
|
|
1295
1407
|
}
|
|
1296
1408
|
break;
|
|
1297
1409
|
|
|
@@ -1302,10 +1414,10 @@ async function start() {
|
|
|
1302
1414
|
for (const [key, value] of Object.entries(privacySettings)) {
|
|
1303
1415
|
privacyText += `⢠${key}: *${value}*\n`;
|
|
1304
1416
|
}
|
|
1305
|
-
await client.sendMessage(
|
|
1417
|
+
await client.sendMessage(msgFrom, privacyText);
|
|
1306
1418
|
} catch (error) {
|
|
1307
1419
|
console.error('Error fetching privacy settings:', error);
|
|
1308
|
-
await client.sendMessage(
|
|
1420
|
+
await client.sendMessage(msgFrom, `ā Failed to get privacy settings: ${error.message}`);
|
|
1309
1421
|
}
|
|
1310
1422
|
break;
|
|
1311
1423
|
|
|
@@ -1317,13 +1429,13 @@ async function start() {
|
|
|
1317
1429
|
blockedList.forEach((jid, i) => {
|
|
1318
1430
|
blockText += `${i + 1}. ${jid}\n`;
|
|
1319
1431
|
});
|
|
1320
|
-
await client.sendMessage(
|
|
1432
|
+
await client.sendMessage(msgFrom, blockText);
|
|
1321
1433
|
} else {
|
|
1322
|
-
await client.sendMessage(
|
|
1434
|
+
await client.sendMessage(msgFrom, 'ā
No blocked contacts.');
|
|
1323
1435
|
}
|
|
1324
1436
|
} catch (error) {
|
|
1325
1437
|
console.error('Error fetching block list:', error);
|
|
1326
|
-
await client.sendMessage(
|
|
1438
|
+
await client.sendMessage(msgFrom, `ā Failed to get block list: ${error.message}`);
|
|
1327
1439
|
}
|
|
1328
1440
|
break;
|
|
1329
1441
|
|
|
@@ -1331,16 +1443,16 @@ async function start() {
|
|
|
1331
1443
|
try {
|
|
1332
1444
|
const lsValues = ['all', 'contacts', 'contact_blacklist', 'none'];
|
|
1333
1445
|
if (!args || !lsValues.includes(args.trim())) {
|
|
1334
|
-
await client.sendMessage(
|
|
1446
|
+
await client.sendMessage(msgFrom,
|
|
1335
1447
|
`ā Invalid value.\n\nUsage: !lastseenprivacy <value>\n\nOptions: ${lsValues.join(', ')}`
|
|
1336
1448
|
);
|
|
1337
1449
|
break;
|
|
1338
1450
|
}
|
|
1339
1451
|
await client.updateLastSeenPrivacy(args.trim());
|
|
1340
|
-
await client.sendMessage(
|
|
1452
|
+
await client.sendMessage(msgFrom, `ā
Last seen privacy updated to: *${args.trim()}*`);
|
|
1341
1453
|
} catch (error) {
|
|
1342
1454
|
console.error('Error updating last seen privacy:', error);
|
|
1343
|
-
await client.sendMessage(
|
|
1455
|
+
await client.sendMessage(msgFrom, `ā Failed to update: ${error.message}`);
|
|
1344
1456
|
}
|
|
1345
1457
|
break;
|
|
1346
1458
|
|
|
@@ -1348,16 +1460,16 @@ async function start() {
|
|
|
1348
1460
|
try {
|
|
1349
1461
|
const onValues = ['all', 'match_last_seen'];
|
|
1350
1462
|
if (!args || !onValues.includes(args.trim())) {
|
|
1351
|
-
await client.sendMessage(
|
|
1463
|
+
await client.sendMessage(msgFrom,
|
|
1352
1464
|
`ā Invalid value.\n\nUsage: !onlineprivacy <value>\n\nOptions: ${onValues.join(', ')}`
|
|
1353
1465
|
);
|
|
1354
1466
|
break;
|
|
1355
1467
|
}
|
|
1356
1468
|
await client.updateOnlinePrivacy(args.trim());
|
|
1357
|
-
await client.sendMessage(
|
|
1469
|
+
await client.sendMessage(msgFrom, `ā
Online privacy updated to: *${args.trim()}*`);
|
|
1358
1470
|
} catch (error) {
|
|
1359
1471
|
console.error('Error updating online privacy:', error);
|
|
1360
|
-
await client.sendMessage(
|
|
1472
|
+
await client.sendMessage(msgFrom, `ā Failed to update: ${error.message}`);
|
|
1361
1473
|
}
|
|
1362
1474
|
break;
|
|
1363
1475
|
|
|
@@ -1365,16 +1477,16 @@ async function start() {
|
|
|
1365
1477
|
try {
|
|
1366
1478
|
const pfpValues = ['all', 'contacts', 'contact_blacklist', 'none'];
|
|
1367
1479
|
if (!args || !pfpValues.includes(args.trim())) {
|
|
1368
|
-
await client.sendMessage(
|
|
1480
|
+
await client.sendMessage(msgFrom,
|
|
1369
1481
|
`ā Invalid value.\n\nUsage: !pfpprivacy <value>\n\nOptions: ${pfpValues.join(', ')}`
|
|
1370
1482
|
);
|
|
1371
1483
|
break;
|
|
1372
1484
|
}
|
|
1373
1485
|
await client.updateProfilePicturePrivacy(args.trim());
|
|
1374
|
-
await client.sendMessage(
|
|
1486
|
+
await client.sendMessage(msgFrom, `ā
Profile picture privacy updated to: *${args.trim()}*`);
|
|
1375
1487
|
} catch (error) {
|
|
1376
1488
|
console.error('Error updating profile picture privacy:', error);
|
|
1377
|
-
await client.sendMessage(
|
|
1489
|
+
await client.sendMessage(msgFrom, `ā Failed to update: ${error.message}`);
|
|
1378
1490
|
}
|
|
1379
1491
|
break;
|
|
1380
1492
|
|
|
@@ -1382,16 +1494,16 @@ async function start() {
|
|
|
1382
1494
|
try {
|
|
1383
1495
|
const stValues = ['all', 'contacts', 'contact_blacklist', 'none'];
|
|
1384
1496
|
if (!args || !stValues.includes(args.trim())) {
|
|
1385
|
-
await client.sendMessage(
|
|
1497
|
+
await client.sendMessage(msgFrom,
|
|
1386
1498
|
`ā Invalid value.\n\nUsage: !statusprivacy <value>\n\nOptions: ${stValues.join(', ')}`
|
|
1387
1499
|
);
|
|
1388
1500
|
break;
|
|
1389
1501
|
}
|
|
1390
1502
|
await client.updateStatusPrivacy(args.trim());
|
|
1391
|
-
await client.sendMessage(
|
|
1503
|
+
await client.sendMessage(msgFrom, `ā
Status privacy updated to: *${args.trim()}*`);
|
|
1392
1504
|
} catch (error) {
|
|
1393
1505
|
console.error('Error updating status privacy:', error);
|
|
1394
|
-
await client.sendMessage(
|
|
1506
|
+
await client.sendMessage(msgFrom, `ā Failed to update: ${error.message}`);
|
|
1395
1507
|
}
|
|
1396
1508
|
break;
|
|
1397
1509
|
|
|
@@ -1399,16 +1511,16 @@ async function start() {
|
|
|
1399
1511
|
try {
|
|
1400
1512
|
const rrValues = ['all', 'none'];
|
|
1401
1513
|
if (!args || !rrValues.includes(args.trim())) {
|
|
1402
|
-
await client.sendMessage(
|
|
1514
|
+
await client.sendMessage(msgFrom,
|
|
1403
1515
|
`ā Invalid value.\n\nUsage: !readreceiptprivacy <value>\n\nOptions: ${rrValues.join(', ')}`
|
|
1404
1516
|
);
|
|
1405
1517
|
break;
|
|
1406
1518
|
}
|
|
1407
1519
|
await client.updateReadReceiptsPrivacy(args.trim());
|
|
1408
|
-
await client.sendMessage(
|
|
1520
|
+
await client.sendMessage(msgFrom, `ā
Read receipts privacy updated to: *${args.trim()}*`);
|
|
1409
1521
|
} catch (error) {
|
|
1410
1522
|
console.error('Error updating read receipts privacy:', error);
|
|
1411
|
-
await client.sendMessage(
|
|
1523
|
+
await client.sendMessage(msgFrom, `ā Failed to update: ${error.message}`);
|
|
1412
1524
|
}
|
|
1413
1525
|
break;
|
|
1414
1526
|
|
|
@@ -1416,16 +1528,16 @@ async function start() {
|
|
|
1416
1528
|
try {
|
|
1417
1529
|
const gaValues = ['all', 'contacts', 'contact_blacklist'];
|
|
1418
1530
|
if (!args || !gaValues.includes(args.trim())) {
|
|
1419
|
-
await client.sendMessage(
|
|
1531
|
+
await client.sendMessage(msgFrom,
|
|
1420
1532
|
`ā Invalid value.\n\nUsage: !groupaddprivacy <value>\n\nOptions: ${gaValues.join(', ')}`
|
|
1421
1533
|
);
|
|
1422
1534
|
break;
|
|
1423
1535
|
}
|
|
1424
1536
|
await client.updateGroupsAddPrivacy(args.trim());
|
|
1425
|
-
await client.sendMessage(
|
|
1537
|
+
await client.sendMessage(msgFrom, `ā
Groups add privacy updated to: *${args.trim()}*`);
|
|
1426
1538
|
} catch (error) {
|
|
1427
1539
|
console.error('Error updating groups add privacy:', error);
|
|
1428
|
-
await client.sendMessage(
|
|
1540
|
+
await client.sendMessage(msgFrom, `ā Failed to update: ${error.message}`);
|
|
1429
1541
|
}
|
|
1430
1542
|
break;
|
|
1431
1543
|
|
|
@@ -1433,7 +1545,7 @@ async function start() {
|
|
|
1433
1545
|
try {
|
|
1434
1546
|
const disappearingSeconds = parseInt(args);
|
|
1435
1547
|
if (isNaN(disappearingSeconds)) {
|
|
1436
|
-
await client.sendMessage(
|
|
1548
|
+
await client.sendMessage(msgFrom,
|
|
1437
1549
|
`ā Please provide duration in seconds.\n\n` +
|
|
1438
1550
|
`Usage: !disappearing <seconds>\n\n` +
|
|
1439
1551
|
`Options:\n` +
|
|
@@ -1446,102 +1558,193 @@ async function start() {
|
|
|
1446
1558
|
}
|
|
1447
1559
|
await client.updateDefaultDisappearingMode(disappearingSeconds);
|
|
1448
1560
|
const disappearText = disappearingSeconds === 0 ? 'OFF' : `${disappearingSeconds} seconds`;
|
|
1449
|
-
await client.sendMessage(
|
|
1561
|
+
await client.sendMessage(msgFrom, `ā
Default disappearing mode set to: *${disappearText}*`);
|
|
1450
1562
|
} catch (error) {
|
|
1451
1563
|
console.error('Error updating default disappearing mode:', error);
|
|
1452
|
-
await client.sendMessage(
|
|
1564
|
+
await client.sendMessage(msgFrom, `ā Failed to update: ${error.message}`);
|
|
1453
1565
|
}
|
|
1454
1566
|
break;
|
|
1455
1567
|
|
|
1456
1568
|
case '!updatestatus':
|
|
1457
1569
|
try {
|
|
1458
1570
|
if (!args) {
|
|
1459
|
-
await client.sendMessage(
|
|
1571
|
+
await client.sendMessage(msgFrom, 'ā Please provide a new status.\nUsage: !updatestatus <text>');
|
|
1460
1572
|
break;
|
|
1461
1573
|
}
|
|
1462
1574
|
await client.updateProfileStatus(args.trim());
|
|
1463
|
-
await client.sendMessage(
|
|
1575
|
+
await client.sendMessage(msgFrom, `ā
Profile status updated successfully!`);
|
|
1464
1576
|
} catch (error) {
|
|
1465
1577
|
console.error('Error updating profile status:', error);
|
|
1466
|
-
await client.sendMessage(
|
|
1578
|
+
await client.sendMessage(msgFrom, `ā Failed to update profile status: ${error.message}`);
|
|
1467
1579
|
}
|
|
1468
1580
|
break;
|
|
1469
1581
|
|
|
1470
1582
|
case '!updatename':
|
|
1471
1583
|
try {
|
|
1472
1584
|
if (!args) {
|
|
1473
|
-
await client.sendMessage(
|
|
1585
|
+
await client.sendMessage(msgFrom, 'ā Please provide a new name.\nUsage: !updatename <text>');
|
|
1474
1586
|
break;
|
|
1475
1587
|
}
|
|
1476
1588
|
const newName = args.trim().toTitleCase();
|
|
1477
1589
|
await client.updateProfileName(newName);
|
|
1478
|
-
await client.sendMessage(
|
|
1590
|
+
await client.sendMessage(msgFrom, `ā
*${newName}* \nProfile name updated successfully!`);
|
|
1479
1591
|
} catch (error) {
|
|
1480
1592
|
console.error('Error updating profile name:', error);
|
|
1481
|
-
await client.sendMessage(
|
|
1593
|
+
await client.sendMessage(msgFrom, `ā Failed to update profile name: ${error.message}`);
|
|
1594
|
+
}
|
|
1595
|
+
break;
|
|
1596
|
+
|
|
1597
|
+
case '!statustext':
|
|
1598
|
+
try {
|
|
1599
|
+
await client.sendStatus({
|
|
1600
|
+
text: 'This is a test status!',
|
|
1601
|
+
backgroundColor: STATUS_BACKGROUNDS.solid.orange,
|
|
1602
|
+
font: STATUS_FONTS.SANS_SERIF
|
|
1603
|
+
}, [msgFrom]);
|
|
1604
|
+
await client.sendMessage(msgFrom, 'ā
Status posted successfully!');
|
|
1605
|
+
} catch (error) {
|
|
1606
|
+
console.error('Error sending text status:', error);
|
|
1607
|
+
await client.sendMessage(msgFrom, `ā Failed to post text status: ${error.message}`);
|
|
1608
|
+
}
|
|
1609
|
+
break;
|
|
1610
|
+
|
|
1611
|
+
case '!statusimage':
|
|
1612
|
+
try {
|
|
1613
|
+
if (fs.existsSync('./example.jpg')) {
|
|
1614
|
+
await client.sendStatus({
|
|
1615
|
+
imagePath: './example.jpg',
|
|
1616
|
+
caption: args || 'Beautiful day from Innovators Soft! āļø'
|
|
1617
|
+
}, [msgFrom]);
|
|
1618
|
+
await client.sendMessage(msgFrom, 'ā
Image status posted successfully!');
|
|
1619
|
+
} else {
|
|
1620
|
+
await client.sendMessage(msgFrom, 'ā example.jpg not found for status demonstration.');
|
|
1621
|
+
}
|
|
1622
|
+
} catch (error) {
|
|
1623
|
+
console.error('Error sending image status:', error);
|
|
1624
|
+
await client.sendMessage(msgFrom, `ā Failed to post image status: ${error.message}`);
|
|
1625
|
+
}
|
|
1626
|
+
break;
|
|
1627
|
+
|
|
1628
|
+
case '!statusvideo':
|
|
1629
|
+
try {
|
|
1630
|
+
if (fs.existsSync('./example.mp4')) {
|
|
1631
|
+
await client.sendStatus({
|
|
1632
|
+
videoPath: './example.mp4',
|
|
1633
|
+
caption: args || 'Check this out! š¬',
|
|
1634
|
+
isGif: false
|
|
1635
|
+
}, [msgFrom]);
|
|
1636
|
+
await client.sendMessage(msgFrom, 'ā
Video status posted successfully!');
|
|
1637
|
+
} else {
|
|
1638
|
+
await client.sendMessage(msgFrom, 'ā example.mp4 not found for status demonstration.');
|
|
1639
|
+
}
|
|
1640
|
+
} catch (error) {
|
|
1641
|
+
console.error('Error sending video status:', error);
|
|
1642
|
+
await client.sendMessage(msgFrom, `ā Failed to post video status: ${error.message}`);
|
|
1643
|
+
}
|
|
1644
|
+
break;
|
|
1645
|
+
|
|
1646
|
+
case '!statusvoice':
|
|
1647
|
+
try {
|
|
1648
|
+
if (fs.existsSync('./example.ogg')) {
|
|
1649
|
+
await client.sendStatus({
|
|
1650
|
+
audioPath: './example.ogg'
|
|
1651
|
+
}, [msgFrom]);
|
|
1652
|
+
await client.sendMessage(msgFrom, 'ā
Voice note status posted successfully!');
|
|
1653
|
+
} else {
|
|
1654
|
+
await client.sendMessage(msgFrom, 'ā example.ogg not found for status demonstration. Try finding a small audio file.');
|
|
1655
|
+
}
|
|
1656
|
+
} catch (error) {
|
|
1657
|
+
console.error('Error sending voice note status:', error);
|
|
1658
|
+
await client.sendMessage(msgFrom, `ā Failed to post voice note status: ${error.message}`);
|
|
1659
|
+
}
|
|
1660
|
+
break;
|
|
1661
|
+
|
|
1662
|
+
case '!groupstatus':
|
|
1663
|
+
try {
|
|
1664
|
+
if (!msgFrom.endsWith('@g.us')) {
|
|
1665
|
+
await client.sendMessage(msgFrom, 'ā This command only works inside a group chat (@g.us).');
|
|
1666
|
+
break;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
await client.sendGroupStatus(msgFrom, {
|
|
1670
|
+
text: 'this is group status'
|
|
1671
|
+
});
|
|
1672
|
+
|
|
1673
|
+
if (fs.existsSync('./example.jpg')) {
|
|
1674
|
+
await client.sendGroupStatus(msgFrom, {
|
|
1675
|
+
image: { url: './example.jpg' },
|
|
1676
|
+
caption: args || 'Hello Group!'
|
|
1677
|
+
});
|
|
1678
|
+
await client.sendMessage(msgFrom, 'ā
Group status posted successfully!');
|
|
1679
|
+
} else {
|
|
1680
|
+
await client.sendMessage(msgFrom, 'ā example.jpg not found for group status demonstration.');
|
|
1681
|
+
}
|
|
1682
|
+
} catch (error) {
|
|
1683
|
+
console.error('Error sending group status:', error);
|
|
1684
|
+
await client.sendMessage(msgFrom, `ā Failed to post group status: ${error.message}`);
|
|
1482
1685
|
}
|
|
1483
1686
|
break;
|
|
1484
1687
|
|
|
1485
1688
|
case '!messages':
|
|
1486
|
-
const history = client.getStoredMessages(
|
|
1689
|
+
const history = client.getStoredMessages(msgFrom);
|
|
1487
1690
|
let historyText = `*š¾ Stored Messages for this chat (${history.length}):*\n\n`;
|
|
1488
1691
|
history.slice(-10).forEach((m, i) => {
|
|
1489
1692
|
const content = m.message.conversation || m.message.extendedTextMessage?.text || "[Media/Other]";
|
|
1490
1693
|
historyText += `${i + 1}. ID: ${m.key.id}\n Text: ${content.substring(0, 50)}${content.length > 50 ? '...' : ''}\n\n`;
|
|
1491
1694
|
});
|
|
1492
|
-
await client.sendMessage(
|
|
1695
|
+
await client.sendMessage(msgFrom, historyText);
|
|
1493
1696
|
break;
|
|
1494
1697
|
|
|
1495
1698
|
case '!message':
|
|
1496
1699
|
if (!args) {
|
|
1497
|
-
await client.sendMessage(
|
|
1700
|
+
await client.sendMessage(msgFrom, "ā Please provide a message ID.");
|
|
1498
1701
|
break;
|
|
1499
1702
|
}
|
|
1500
|
-
const storedMsg = client.getStoredMessage({ remoteJid:
|
|
1703
|
+
const storedMsg = client.getStoredMessage({ remoteJid: msgFrom, id: args.trim(), fromMe: false });
|
|
1501
1704
|
if (storedMsg) {
|
|
1502
|
-
await client.sendMessage(
|
|
1705
|
+
await client.sendMessage(msgFrom, `ā
Found message!\n\nContent: ${JSON.stringify(storedMsg.message, null, 2).substring(0, 1000)}`);
|
|
1503
1706
|
} else {
|
|
1504
|
-
await client.sendMessage(
|
|
1707
|
+
await client.sendMessage(msgFrom, "ā Message not found in store.");
|
|
1505
1708
|
}
|
|
1506
1709
|
break;
|
|
1507
1710
|
|
|
1508
1711
|
case '!stats':
|
|
1509
1712
|
const stats = client.getStoreStats();
|
|
1510
|
-
await client.sendMessage(
|
|
1713
|
+
await client.sendMessage(msgFrom, `*š Message Store Statistics*\n\n⢠Total Chats: ${stats.totalChats}\n⢠Total Messages: ${stats.totalMessages}\n⢠Total Deleted: ${stats.totalDeleted}`);
|
|
1511
1714
|
break;
|
|
1512
1715
|
|
|
1513
1716
|
case '!allmessages':
|
|
1514
1717
|
const allMsgs = client.getAllStoredMessages();
|
|
1515
1718
|
const activeChats = client.getStoredChatIds();
|
|
1516
|
-
await client.sendMessage(
|
|
1719
|
+
await client.sendMessage(msgFrom, `*š Global Message Store*\n\n⢠Total Messages Held: ${allMsgs.length}\n⢠Total Active Chats: ${activeChats.length}\n\n*Active JIDs:* \n${activeChats.join('\n')}`);
|
|
1517
1720
|
break;
|
|
1518
1721
|
|
|
1519
1722
|
case '!savestore':
|
|
1520
|
-
await client.sendMessage(
|
|
1723
|
+
await client.sendMessage(msgFrom, 'š¾ Saving message store to file...');
|
|
1521
1724
|
const saveResult = await client.saveMessageStore();
|
|
1522
1725
|
if (saveResult.success) {
|
|
1523
|
-
await client.sendMessage(
|
|
1726
|
+
await client.sendMessage(msgFrom,
|
|
1524
1727
|
`ā
*Store Saved Successfully*\n\n` +
|
|
1525
1728
|
`⢠Messages: ${saveResult.messageCount}\n` +
|
|
1526
1729
|
`⢠Path: ${saveResult.path}\n` +
|
|
1527
1730
|
`⢠Saved at: ${saveResult.savedAt.toLocaleString()}`
|
|
1528
1731
|
);
|
|
1529
1732
|
} else {
|
|
1530
|
-
await client.sendMessage(
|
|
1733
|
+
await client.sendMessage(msgFrom, `ā Failed to save store: ${saveResult.error}`);
|
|
1531
1734
|
}
|
|
1532
1735
|
break;
|
|
1533
1736
|
|
|
1534
1737
|
case '!loadstore':
|
|
1535
|
-
await client.sendMessage(
|
|
1738
|
+
await client.sendMessage(msgFrom, 'š Loading message store from file...');
|
|
1536
1739
|
const loadResult = await client.loadMessageStore();
|
|
1537
1740
|
if (loadResult.success) {
|
|
1538
|
-
await client.sendMessage(
|
|
1741
|
+
await client.sendMessage(msgFrom,
|
|
1539
1742
|
`ā
*Store Loaded Successfully*\n\n` +
|
|
1540
1743
|
`⢠Messages: ${loadResult.messageCount}\n` +
|
|
1541
1744
|
`⢠Loaded from: ${loadResult.loadedFrom}`
|
|
1542
1745
|
);
|
|
1543
1746
|
} else {
|
|
1544
|
-
await client.sendMessage(
|
|
1747
|
+
await client.sendMessage(msgFrom,
|
|
1545
1748
|
`ā ļø Could not load store\n` +
|
|
1546
1749
|
`Reason: ${loadResult.reason || loadResult.error}`
|
|
1547
1750
|
);
|