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.
- package/README.md +222 -10
- package/example.js +509 -52
- package/index.js +609 -19
- package/package.json +2 -1
package/example.js
CHANGED
|
@@ -76,6 +76,19 @@ async function start() {
|
|
|
76
76
|
console.log('š¦ New LID/PN mappings received')
|
|
77
77
|
})
|
|
78
78
|
|
|
79
|
+
// Handle Contact Events
|
|
80
|
+
client.on('contacts-received', (contacts) => {
|
|
81
|
+
console.log(`\nš„ History Sync: Received ${contacts.length} contacts`);
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
client.on('contacts-upsert', (contacts) => {
|
|
85
|
+
console.log(`\nš„ New Contacts: ${contacts.length} contacts added/updated`);
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
client.on('contacts-update', (updates) => {
|
|
89
|
+
console.log(`\nš„ Contact Updates: ${updates.length} contacts modified`);
|
|
90
|
+
})
|
|
91
|
+
|
|
79
92
|
// Handle Anti-Delete system
|
|
80
93
|
client.on('message-deleted', async (data) => {
|
|
81
94
|
console.log(`\nš”ļø Message from ${data.jid} was deleted!`)
|
|
@@ -91,7 +104,7 @@ async function start() {
|
|
|
91
104
|
console.log('Is Removed:', reaction.isRemoved)
|
|
92
105
|
console.log('Message ID:', reaction.messageKey.id)
|
|
93
106
|
})
|
|
94
|
-
|
|
107
|
+
|
|
95
108
|
client.on('call', (call) => {
|
|
96
109
|
const callData = call[0]; // Get the first call object from the array
|
|
97
110
|
if (callData.status !== 'offer') return;
|
|
@@ -242,29 +255,6 @@ async function start() {
|
|
|
242
255
|
{ title: 'Security', id: 'security', description: 'Security and login options' },
|
|
243
256
|
{ title: 'Payments', id: 'payments', description: 'Manage payment methods' },
|
|
244
257
|
{ title: 'Subscriptions', id: 'subscriptions', description: 'View your subscriptions' },
|
|
245
|
-
{ title: 'Orders', id: 'orders', description: 'View order history' },
|
|
246
|
-
{ title: 'Wishlist', id: 'wishlist', description: 'Your saved items' },
|
|
247
|
-
{ title: 'Addresses', id: 'addresses', description: 'Manage shipping addresses' },
|
|
248
|
-
{ title: 'Help Center', id: 'help', description: 'Get help and support' },
|
|
249
|
-
{ title: 'Contact Us', id: 'contact', description: 'Reach out to our team' },
|
|
250
|
-
{ title: 'FAQs', id: 'faqs', description: 'Frequently asked questions' },
|
|
251
|
-
{ title: 'About Us', id: 'about', description: 'Learn about our company' },
|
|
252
|
-
{ title: 'Careers', id: 'careers', description: 'Join our team' },
|
|
253
|
-
{ title: 'Blog', id: 'blog', description: 'Read our latest articles' },
|
|
254
|
-
{ title: 'Newsletter', id: 'newsletter', description: 'Subscribe to updates' },
|
|
255
|
-
{ title: 'Events', id: 'events', description: 'Upcoming events' },
|
|
256
|
-
{ title: 'Webinars', id: 'webinars', description: 'Join live webinars' },
|
|
257
|
-
{ title: 'Tutorials', id: 'tutorials', description: 'Learn how to use features' },
|
|
258
|
-
{ title: 'Documentation', id: 'docs', description: 'Technical documentation' },
|
|
259
|
-
{ title: 'API', id: 'api', description: 'Developer API' },
|
|
260
|
-
{ title: 'Integrations', id: 'integrations', description: 'Third-party integrations' },
|
|
261
|
-
{ title: 'Download', id: 'download', description: 'Download our app' },
|
|
262
|
-
{ title: 'Pricing', id: 'pricing', description: 'View pricing plans' },
|
|
263
|
-
{ title: 'Upgrade', id: 'upgrade', description: 'Upgrade your plan' },
|
|
264
|
-
{ title: 'Refer a Friend', id: 'refer', description: 'Earn rewards' },
|
|
265
|
-
{ title: 'Feedback', id: 'feedback', description: 'Share your thoughts' },
|
|
266
|
-
{ title: 'Report Issue', id: 'report', description: 'Report a problem' },
|
|
267
|
-
{ title: 'Language', id: 'language', description: 'Change language' }
|
|
268
258
|
]
|
|
269
259
|
},
|
|
270
260
|
{
|
|
@@ -277,29 +267,6 @@ async function start() {
|
|
|
277
267
|
{ title: 'Data Saver', id: 'data_saver', description: 'Reduce data usage' },
|
|
278
268
|
{ title: 'Storage', id: 'storage', description: 'Manage local storage' },
|
|
279
269
|
{ title: 'Cache', id: 'cache', description: 'Clear cached data' },
|
|
280
|
-
{ title: 'Backup', id: 'backup', description: 'Backup your data' },
|
|
281
|
-
{ title: 'Restore', id: 'restore', description: 'Restore from backup' },
|
|
282
|
-
{ title: 'Export Data', id: 'export', description: 'Download your data' },
|
|
283
|
-
{ title: 'Delete Account', id: 'delete', description: 'Permanently remove account' },
|
|
284
|
-
{ title: 'Terms of Service', id: 'tos', description: 'Read terms and conditions' },
|
|
285
|
-
{ title: 'Privacy Policy', id: 'privacy_policy', description: 'How we handle your data' },
|
|
286
|
-
{ title: 'Cookie Policy', id: 'cookies', description: 'About our use of cookies' },
|
|
287
|
-
{ title: 'Accessibility', id: 'accessibility', description: 'Accessibility features' },
|
|
288
|
-
{ title: 'Version', id: 'version', description: 'App version information' },
|
|
289
|
-
{ title: 'Changelog', id: 'changelog', description: 'Recent updates' },
|
|
290
|
-
{ title: 'Roadmap', id: 'roadmap', description: 'Upcoming features' },
|
|
291
|
-
{ title: 'Status', id: 'status', description: 'Service status' },
|
|
292
|
-
{ title: 'Legal', id: 'legal', description: 'Legal information' },
|
|
293
|
-
{ title: 'Partners', id: 'partners', description: 'Our partners' },
|
|
294
|
-
{ title: 'Press', id: 'press', description: 'Press resources' },
|
|
295
|
-
{ title: 'Investors', id: 'investors', description: 'Investor relations' },
|
|
296
|
-
{ title: 'Affiliates', id: 'affiliates', description: 'Become an affiliate' },
|
|
297
|
-
{ title: 'Merchandise', id: 'merch', description: 'Official merchandise' },
|
|
298
|
-
{ title: 'Donate', id: 'donate', description: 'Support our work' },
|
|
299
|
-
{ title: 'Volunteer', id: 'volunteer', description: 'Get involved' },
|
|
300
|
-
{ title: 'Community', id: 'community', description: 'Join our community' },
|
|
301
|
-
{ title: 'Forum', id: 'forum', description: 'Community discussions' },
|
|
302
|
-
{ title: 'Beta Program', id: 'beta', description: 'Try beta features' }
|
|
303
270
|
]
|
|
304
271
|
}
|
|
305
272
|
]
|
|
@@ -334,10 +301,10 @@ async function start() {
|
|
|
334
301
|
|
|
335
302
|
await client.sendButtons(msg.from, {
|
|
336
303
|
imagePath: './example.jpg',
|
|
337
|
-
caption: '', // Keep it short and concise
|
|
338
|
-
title: '', // Max 24 chars
|
|
339
|
-
subtitle: '', // Optional, appears below title
|
|
340
|
-
footer: '',
|
|
304
|
+
caption: 'here is captions of image\nwith linebreaks', // Keep it short and concise
|
|
305
|
+
title: 'Image Title', // Max 24 chars
|
|
306
|
+
subtitle: 'Image Subtitle (but optional)', // Optional, appears below title
|
|
307
|
+
footer: 'Image Footer',
|
|
341
308
|
interactiveButtons: [
|
|
342
309
|
{
|
|
343
310
|
name: 'quick_reply',
|
|
@@ -406,7 +373,34 @@ async function start() {
|
|
|
406
373
|
`⢠!invite <number> - Send group invite link\n` +
|
|
407
374
|
`⢠!remove <number> - Remove participant\n` +
|
|
408
375
|
`⢠!promote <number> - Make admin\n` +
|
|
409
|
-
`⢠!demote <number> - Remove admin\n
|
|
376
|
+
`⢠!demote <number> - Remove admin\n` +
|
|
377
|
+
`⢠!creategroup <name> - Create a new group\n` +
|
|
378
|
+
`⢠!groupsubject <name> - Change group name\n` +
|
|
379
|
+
`⢠!groupdesc <text> - Change group description\n` +
|
|
380
|
+
`⢠!groupsetting <setting> - Change group settings\n` +
|
|
381
|
+
`⢠!invitecode - Get group invite code\n` +
|
|
382
|
+
`⢠!revokeinvite - Revoke group invite code\n` +
|
|
383
|
+
`⢠!leavegroup - Leave the group\n` +
|
|
384
|
+
`⢠!joingroup <code> - Join group by invite code\n` +
|
|
385
|
+
`⢠!groupinfo <code> - Get group info by invite code\n` +
|
|
386
|
+
`⢠!joinrequests - List pending join requests\n` +
|
|
387
|
+
`⢠!approvejoin <number> - Approve join request\n` +
|
|
388
|
+
`⢠!rejectjoin <number> - Reject join request\n` +
|
|
389
|
+
`⢠!ephemeral <seconds> - Toggle disappearing msgs\n` +
|
|
390
|
+
`⢠!addmode <mode> - Change who can add members\n\n` +
|
|
391
|
+
|
|
392
|
+
`*š Privacy*\n` +
|
|
393
|
+
`⢠!block <number> - Block a user\n` +
|
|
394
|
+
`⢠!unblock <number> - Unblock a user\n` +
|
|
395
|
+
`⢠!privacy - Get privacy settings\n` +
|
|
396
|
+
`⢠!blocklist - Get blocked contacts\n` +
|
|
397
|
+
`⢠!lastseenprivacy <value> - Update last seen\n` +
|
|
398
|
+
`⢠!onlineprivacy <value> - Update online status\n` +
|
|
399
|
+
`⢠!pfpprivacy <value> - Update profile pic privacy\n` +
|
|
400
|
+
`⢠!statusprivacy <value> - Update status privacy\n` +
|
|
401
|
+
`⢠!readreceiptprivacy <value> - Update read receipts\n` +
|
|
402
|
+
`⢠!groupaddprivacy <value> - Who can add to groups\n` +
|
|
403
|
+
`⢠!disappearing <seconds> - Default disappearing mode\n\n` +
|
|
410
404
|
|
|
411
405
|
`*šļø Templates & Buttons*\n` +
|
|
412
406
|
`⢠!buttons - Button template\n` +
|
|
@@ -698,6 +692,469 @@ async function start() {
|
|
|
698
692
|
}
|
|
699
693
|
}
|
|
700
694
|
break
|
|
695
|
+
|
|
696
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
697
|
+
// š GROUP MANAGEMENT COMMANDS
|
|
698
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
699
|
+
|
|
700
|
+
case '!creategroup':
|
|
701
|
+
try {
|
|
702
|
+
if (!args) {
|
|
703
|
+
await client.sendMessage(msg.from, 'ā Please provide a group name.\nUsage: !creategroup My New Group');
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
const newGroup = await client.createGroup(args, [msg.sender]);
|
|
707
|
+
await client.sendMessage(msg.from, `ā
Group created!\n\nName: *${args}*\nID: ${newGroup.id || newGroup.gid}`);
|
|
708
|
+
} catch (error) {
|
|
709
|
+
console.error('Error creating group:', error);
|
|
710
|
+
await client.sendMessage(msg.from, `ā Failed to create group: ${error.message}`);
|
|
711
|
+
}
|
|
712
|
+
break;
|
|
713
|
+
|
|
714
|
+
case '!groupsubject':
|
|
715
|
+
try {
|
|
716
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
717
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
720
|
+
if (!args) {
|
|
721
|
+
await client.sendMessage(msg.from, 'ā Please provide a new group name.\nUsage: !groupsubject New Name');
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
724
|
+
await client.changeGroupSubject(msg.raw.key.remoteJid, args);
|
|
725
|
+
await client.sendMessage(msg.from, `ā
Group name changed to: *${args}*`);
|
|
726
|
+
} catch (error) {
|
|
727
|
+
console.error('Error changing group subject:', error);
|
|
728
|
+
await client.sendMessage(msg.from, `ā Failed to change group name: ${error.message}`);
|
|
729
|
+
}
|
|
730
|
+
break;
|
|
731
|
+
|
|
732
|
+
case '!groupdesc':
|
|
733
|
+
try {
|
|
734
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
735
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
736
|
+
break;
|
|
737
|
+
}
|
|
738
|
+
if (!args) {
|
|
739
|
+
await client.sendMessage(msg.from, 'ā Please provide a new description.\nUsage: !groupdesc New description here');
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
await client.changeGroupDescription(msg.raw.key.remoteJid, args);
|
|
743
|
+
await client.sendMessage(msg.from, `ā
Group description updated!`);
|
|
744
|
+
} catch (error) {
|
|
745
|
+
console.error('Error changing group description:', error);
|
|
746
|
+
await client.sendMessage(msg.from, `ā Failed to change description: ${error.message}`);
|
|
747
|
+
}
|
|
748
|
+
break;
|
|
749
|
+
|
|
750
|
+
case '!groupsetting':
|
|
751
|
+
try {
|
|
752
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
753
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
if (!args || !['announcement', 'not_announcement', 'locked', 'unlocked'].includes(args.trim())) {
|
|
757
|
+
await client.sendMessage(msg.from,
|
|
758
|
+
`ā Invalid setting.\n\n` +
|
|
759
|
+
`Usage: !groupsetting <setting>\n\n` +
|
|
760
|
+
`Available settings:\n` +
|
|
761
|
+
`⢠announcement - Only admins can send messages\n` +
|
|
762
|
+
`⢠not_announcement - Everyone can send messages\n` +
|
|
763
|
+
`⢠locked - Only admins can edit group info\n` +
|
|
764
|
+
`⢠unlocked - Everyone can edit group info`
|
|
765
|
+
);
|
|
766
|
+
break;
|
|
767
|
+
}
|
|
768
|
+
await client.changeGroupSettings(msg.raw.key.remoteJid, args.trim());
|
|
769
|
+
await client.sendMessage(msg.from, `ā
Group setting changed to: *${args.trim()}*`);
|
|
770
|
+
} catch (error) {
|
|
771
|
+
console.error('Error changing group settings:', error);
|
|
772
|
+
await client.sendMessage(msg.from, `ā Failed to change setting: ${error.message}`);
|
|
773
|
+
}
|
|
774
|
+
break;
|
|
775
|
+
|
|
776
|
+
case '!invitecode':
|
|
777
|
+
try {
|
|
778
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
779
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
const inviteCode = await client.getGroupInviteCode(msg.raw.key.remoteJid);
|
|
783
|
+
await client.sendMessage(msg.from, `ā
Group Invite Link:\nhttps://chat.whatsapp.com/${inviteCode}`);
|
|
784
|
+
} catch (error) {
|
|
785
|
+
console.error('Error getting invite code:', error);
|
|
786
|
+
await client.sendMessage(msg.from, `ā Failed to get invite code: ${error.message}`);
|
|
787
|
+
}
|
|
788
|
+
break;
|
|
789
|
+
|
|
790
|
+
case '!revokeinvite':
|
|
791
|
+
try {
|
|
792
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
793
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
const newInviteCode = await client.revokeGroupInviteCode(msg.raw.key.remoteJid);
|
|
797
|
+
await client.sendMessage(msg.from, `ā
Invite code revoked!\nNew invite link:\nhttps://chat.whatsapp.com/${newInviteCode}`);
|
|
798
|
+
} catch (error) {
|
|
799
|
+
console.error('Error revoking invite code:', error);
|
|
800
|
+
await client.sendMessage(msg.from, `ā Failed to revoke invite code: ${error.message}`);
|
|
801
|
+
}
|
|
802
|
+
break;
|
|
803
|
+
|
|
804
|
+
case '!leavegroup':
|
|
805
|
+
try {
|
|
806
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
807
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
await client.sendMessage(msg.from, 'š Leaving group...');
|
|
811
|
+
await client.leaveGroup(msg.raw.key.remoteJid);
|
|
812
|
+
} catch (error) {
|
|
813
|
+
console.error('Error leaving group:', error);
|
|
814
|
+
await client.sendMessage(msg.from, `ā Failed to leave group: ${error.message}`);
|
|
815
|
+
}
|
|
816
|
+
break;
|
|
817
|
+
|
|
818
|
+
case '!joingroup':
|
|
819
|
+
try {
|
|
820
|
+
if (!args) {
|
|
821
|
+
await client.sendMessage(msg.from, 'ā Please provide an invite code.\nUsage: !joingroup AbCdEfGhIjK\n(or full link: !joingroup https://chat.whatsapp.com/AbCdEfGhIjK)');
|
|
822
|
+
break;
|
|
823
|
+
}
|
|
824
|
+
const joinedGroupId = await client.joinGroupByInviteCode(args.trim());
|
|
825
|
+
await client.sendMessage(msg.from, `ā
Successfully joined group!\nGroup ID: ${joinedGroupId}`);
|
|
826
|
+
} catch (error) {
|
|
827
|
+
console.error('Error joining group:', error);
|
|
828
|
+
await client.sendMessage(msg.from, `ā Failed to join group: ${error.message}`);
|
|
829
|
+
}
|
|
830
|
+
break;
|
|
831
|
+
|
|
832
|
+
case '!groupinfo':
|
|
833
|
+
try {
|
|
834
|
+
if (!args) {
|
|
835
|
+
await client.sendMessage(msg.from, 'ā Please provide an invite code.\nUsage: !groupinfo AbCdEfGhIjK');
|
|
836
|
+
break;
|
|
837
|
+
}
|
|
838
|
+
const groupInfoResult = await client.getGroupInfoByInviteCode(args.trim());
|
|
839
|
+
let infoText = `*š Group Info*\n\n`;
|
|
840
|
+
infoText += `Name: *${groupInfoResult.subject || 'N/A'}*\n`;
|
|
841
|
+
infoText += `ID: ${groupInfoResult.id || 'N/A'}\n`;
|
|
842
|
+
infoText += `Creator: ${groupInfoResult.owner || 'N/A'}\n`;
|
|
843
|
+
infoText += `Description: ${groupInfoResult.desc || 'No description'}\n`;
|
|
844
|
+
infoText += `Members: ${groupInfoResult.size || groupInfoResult.participants?.length || 'N/A'}\n`;
|
|
845
|
+
infoText += `Created: ${groupInfoResult.creation ? new Date(groupInfoResult.creation * 1000).toLocaleString() : 'N/A'}`;
|
|
846
|
+
await client.sendMessage(msg.from, infoText);
|
|
847
|
+
} catch (error) {
|
|
848
|
+
console.error('Error getting group info:', error);
|
|
849
|
+
await client.sendMessage(msg.from, `ā Failed to get group info: ${error.message}`);
|
|
850
|
+
}
|
|
851
|
+
break;
|
|
852
|
+
|
|
853
|
+
case '!joinrequests':
|
|
854
|
+
try {
|
|
855
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
856
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
const requests = await client.getGroupJoinRequests(msg.raw.key.remoteJid);
|
|
860
|
+
if (requests && requests.length > 0) {
|
|
861
|
+
let requestList = `*š Pending Join Requests (${requests.length}):*\n\n`;
|
|
862
|
+
requests.forEach((req, i) => {
|
|
863
|
+
requestList += `${i + 1}. ${req.jid}\n`;
|
|
864
|
+
if (req.request_time) requestList += ` Requested: ${new Date(req.request_time * 1000).toLocaleString()}\n`;
|
|
865
|
+
});
|
|
866
|
+
requestList += `\nUse !approvejoin or !rejectjoin <number> to respond`;
|
|
867
|
+
await client.sendMessage(msg.from, requestList);
|
|
868
|
+
} else {
|
|
869
|
+
await client.sendMessage(msg.from, 'ā
No pending join requests.');
|
|
870
|
+
}
|
|
871
|
+
} catch (error) {
|
|
872
|
+
console.error('Error getting join requests:', error);
|
|
873
|
+
await client.sendMessage(msg.from, `ā Failed to get join requests: ${error.message}`);
|
|
874
|
+
}
|
|
875
|
+
break;
|
|
876
|
+
|
|
877
|
+
case '!approvejoin':
|
|
878
|
+
try {
|
|
879
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
880
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
883
|
+
const approveNum = args?.replace(/[^0-9]/g, '');
|
|
884
|
+
if (!approveNum || approveNum.length < 10) {
|
|
885
|
+
await client.sendMessage(msg.from, 'ā Please provide a valid phone number.\nUsage: !approvejoin 923001234567');
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
888
|
+
const approveResult = await client.handleGroupJoinRequest(msg.raw.key.remoteJid, [approveNum + '@s.whatsapp.net'], 'approve');
|
|
889
|
+
await client.sendMessage(msg.from, `ā
Join request approved for ${approveNum}`);
|
|
890
|
+
} catch (error) {
|
|
891
|
+
console.error('Error approving join request:', error);
|
|
892
|
+
await client.sendMessage(msg.from, `ā Failed to approve: ${error.message}`);
|
|
893
|
+
}
|
|
894
|
+
break;
|
|
895
|
+
|
|
896
|
+
case '!rejectjoin':
|
|
897
|
+
try {
|
|
898
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
899
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
900
|
+
break;
|
|
901
|
+
}
|
|
902
|
+
const rejectNum = args?.replace(/[^0-9]/g, '');
|
|
903
|
+
if (!rejectNum || rejectNum.length < 10) {
|
|
904
|
+
await client.sendMessage(msg.from, 'ā Please provide a valid phone number.\nUsage: !rejectjoin 923001234567');
|
|
905
|
+
break;
|
|
906
|
+
}
|
|
907
|
+
const rejectResult = await client.handleGroupJoinRequest(msg.raw.key.remoteJid, [rejectNum + '@s.whatsapp.net'], 'reject');
|
|
908
|
+
await client.sendMessage(msg.from, `ā
Join request rejected for ${rejectNum}`);
|
|
909
|
+
} catch (error) {
|
|
910
|
+
console.error('Error rejecting join request:', error);
|
|
911
|
+
await client.sendMessage(msg.from, `ā Failed to reject: ${error.message}`);
|
|
912
|
+
}
|
|
913
|
+
break;
|
|
914
|
+
|
|
915
|
+
case '!ephemeral':
|
|
916
|
+
try {
|
|
917
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
918
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
919
|
+
break;
|
|
920
|
+
}
|
|
921
|
+
const ephemeralSeconds = parseInt(args);
|
|
922
|
+
if (isNaN(ephemeralSeconds)) {
|
|
923
|
+
await client.sendMessage(msg.from,
|
|
924
|
+
`ā Please provide duration in seconds.\n\n` +
|
|
925
|
+
`Usage: !ephemeral <seconds>\n\n` +
|
|
926
|
+
`Options:\n` +
|
|
927
|
+
`⢠0 - Turn off\n` +
|
|
928
|
+
`⢠86400 - 24 hours\n` +
|
|
929
|
+
`⢠604800 - 7 days\n` +
|
|
930
|
+
`⢠7776000 - 90 days`
|
|
931
|
+
);
|
|
932
|
+
break;
|
|
933
|
+
}
|
|
934
|
+
await client.toggleGroupEphemeral(msg.raw.key.remoteJid, ephemeralSeconds);
|
|
935
|
+
const durationText = ephemeralSeconds === 0 ? 'OFF' : `${ephemeralSeconds} seconds`;
|
|
936
|
+
await client.sendMessage(msg.from, `ā
Disappearing messages set to: *${durationText}*`);
|
|
937
|
+
} catch (error) {
|
|
938
|
+
console.error('Error toggling ephemeral:', error);
|
|
939
|
+
await client.sendMessage(msg.from, `ā Failed to toggle disappearing messages: ${error.message}`);
|
|
940
|
+
}
|
|
941
|
+
break;
|
|
942
|
+
|
|
943
|
+
case '!addmode':
|
|
944
|
+
try {
|
|
945
|
+
if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
|
|
946
|
+
await client.sendMessage(msg.from, 'ā This command can only be used in groups');
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
if (!args || !['all_member_add', 'admin_add'].includes(args.trim())) {
|
|
950
|
+
await client.sendMessage(msg.from,
|
|
951
|
+
`ā Invalid mode.\n\n` +
|
|
952
|
+
`Usage: !addmode <mode>\n\n` +
|
|
953
|
+
`Options:\n` +
|
|
954
|
+
`⢠all_member_add - All members can add\n` +
|
|
955
|
+
`⢠admin_add - Only admins can add`
|
|
956
|
+
);
|
|
957
|
+
break;
|
|
958
|
+
}
|
|
959
|
+
await client.changeGroupAddMode(msg.raw.key.remoteJid, args.trim());
|
|
960
|
+
await client.sendMessage(msg.from, `ā
Group add mode changed to: *${args.trim()}*`);
|
|
961
|
+
} catch (error) {
|
|
962
|
+
console.error('Error changing add mode:', error);
|
|
963
|
+
await client.sendMessage(msg.from, `ā Failed to change add mode: ${error.message}`);
|
|
964
|
+
}
|
|
965
|
+
break;
|
|
966
|
+
|
|
967
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
968
|
+
// š PRIVACY COMMANDS
|
|
969
|
+
// āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
970
|
+
|
|
971
|
+
case '!block':
|
|
972
|
+
try {
|
|
973
|
+
const blockNum = args?.replace(/[^0-9]/g, '');
|
|
974
|
+
if (!blockNum || blockNum.length < 10) {
|
|
975
|
+
await client.sendMessage(msg.from, 'ā Please provide a valid phone number.\nUsage: !block 923001234567');
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
await client.blockUser(blockNum + '@s.whatsapp.net');
|
|
979
|
+
await client.sendMessage(msg.from, `ā
User ${blockNum} has been blocked.`);
|
|
980
|
+
} catch (error) {
|
|
981
|
+
console.error('Error blocking user:', error);
|
|
982
|
+
await client.sendMessage(msg.from, `ā Failed to block user: ${error.message}`);
|
|
983
|
+
}
|
|
984
|
+
break;
|
|
985
|
+
|
|
986
|
+
case '!unblock':
|
|
987
|
+
try {
|
|
988
|
+
const unblockNum = args?.replace(/[^0-9]/g, '');
|
|
989
|
+
if (!unblockNum || unblockNum.length < 10) {
|
|
990
|
+
await client.sendMessage(msg.from, 'ā Please provide a valid phone number.\nUsage: !unblock 923001234567');
|
|
991
|
+
break;
|
|
992
|
+
}
|
|
993
|
+
await client.unblockUser(unblockNum + '@s.whatsapp.net');
|
|
994
|
+
await client.sendMessage(msg.from, `ā
User ${unblockNum} has been unblocked.`);
|
|
995
|
+
} catch (error) {
|
|
996
|
+
console.error('Error unblocking user:', error);
|
|
997
|
+
await client.sendMessage(msg.from, `ā Failed to unblock user: ${error.message}`);
|
|
998
|
+
}
|
|
999
|
+
break;
|
|
1000
|
+
|
|
1001
|
+
case '!privacy':
|
|
1002
|
+
try {
|
|
1003
|
+
const privacySettings = await client.getPrivacySettings();
|
|
1004
|
+
let privacyText = `*š Privacy Settings*\n\n`;
|
|
1005
|
+
for (const [key, value] of Object.entries(privacySettings)) {
|
|
1006
|
+
privacyText += `⢠${key}: *${value}*\n`;
|
|
1007
|
+
}
|
|
1008
|
+
await client.sendMessage(msg.from, privacyText);
|
|
1009
|
+
} catch (error) {
|
|
1010
|
+
console.error('Error fetching privacy settings:', error);
|
|
1011
|
+
await client.sendMessage(msg.from, `ā Failed to get privacy settings: ${error.message}`);
|
|
1012
|
+
}
|
|
1013
|
+
break;
|
|
1014
|
+
|
|
1015
|
+
case '!blocklist':
|
|
1016
|
+
try {
|
|
1017
|
+
const blockedList = await client.getBlockList();
|
|
1018
|
+
if (blockedList && blockedList.length > 0) {
|
|
1019
|
+
let blockText = `*š« Blocked Contacts (${blockedList.length}):*\n\n`;
|
|
1020
|
+
blockedList.forEach((jid, i) => {
|
|
1021
|
+
blockText += `${i + 1}. ${jid}\n`;
|
|
1022
|
+
});
|
|
1023
|
+
await client.sendMessage(msg.from, blockText);
|
|
1024
|
+
} else {
|
|
1025
|
+
await client.sendMessage(msg.from, 'ā
No blocked contacts.');
|
|
1026
|
+
}
|
|
1027
|
+
} catch (error) {
|
|
1028
|
+
console.error('Error fetching block list:', error);
|
|
1029
|
+
await client.sendMessage(msg.from, `ā Failed to get block list: ${error.message}`);
|
|
1030
|
+
}
|
|
1031
|
+
break;
|
|
1032
|
+
|
|
1033
|
+
case '!lastseenprivacy':
|
|
1034
|
+
try {
|
|
1035
|
+
const lsValues = ['all', 'contacts', 'contact_blacklist', 'none'];
|
|
1036
|
+
if (!args || !lsValues.includes(args.trim())) {
|
|
1037
|
+
await client.sendMessage(msg.from,
|
|
1038
|
+
`ā Invalid value.\n\nUsage: !lastseenprivacy <value>\n\nOptions: ${lsValues.join(', ')}`
|
|
1039
|
+
);
|
|
1040
|
+
break;
|
|
1041
|
+
}
|
|
1042
|
+
await client.updateLastSeenPrivacy(args.trim());
|
|
1043
|
+
await client.sendMessage(msg.from, `ā
Last seen privacy updated to: *${args.trim()}*`);
|
|
1044
|
+
} catch (error) {
|
|
1045
|
+
console.error('Error updating last seen privacy:', error);
|
|
1046
|
+
await client.sendMessage(msg.from, `ā Failed to update: ${error.message}`);
|
|
1047
|
+
}
|
|
1048
|
+
break;
|
|
1049
|
+
|
|
1050
|
+
case '!onlineprivacy':
|
|
1051
|
+
try {
|
|
1052
|
+
const onValues = ['all', 'match_last_seen'];
|
|
1053
|
+
if (!args || !onValues.includes(args.trim())) {
|
|
1054
|
+
await client.sendMessage(msg.from,
|
|
1055
|
+
`ā Invalid value.\n\nUsage: !onlineprivacy <value>\n\nOptions: ${onValues.join(', ')}`
|
|
1056
|
+
);
|
|
1057
|
+
break;
|
|
1058
|
+
}
|
|
1059
|
+
await client.updateOnlinePrivacy(args.trim());
|
|
1060
|
+
await client.sendMessage(msg.from, `ā
Online privacy updated to: *${args.trim()}*`);
|
|
1061
|
+
} catch (error) {
|
|
1062
|
+
console.error('Error updating online privacy:', error);
|
|
1063
|
+
await client.sendMessage(msg.from, `ā Failed to update: ${error.message}`);
|
|
1064
|
+
}
|
|
1065
|
+
break;
|
|
1066
|
+
|
|
1067
|
+
case '!pfpprivacy':
|
|
1068
|
+
try {
|
|
1069
|
+
const pfpValues = ['all', 'contacts', 'contact_blacklist', 'none'];
|
|
1070
|
+
if (!args || !pfpValues.includes(args.trim())) {
|
|
1071
|
+
await client.sendMessage(msg.from,
|
|
1072
|
+
`ā Invalid value.\n\nUsage: !pfpprivacy <value>\n\nOptions: ${pfpValues.join(', ')}`
|
|
1073
|
+
);
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
await client.updateProfilePicturePrivacy(args.trim());
|
|
1077
|
+
await client.sendMessage(msg.from, `ā
Profile picture privacy updated to: *${args.trim()}*`);
|
|
1078
|
+
} catch (error) {
|
|
1079
|
+
console.error('Error updating profile picture privacy:', error);
|
|
1080
|
+
await client.sendMessage(msg.from, `ā Failed to update: ${error.message}`);
|
|
1081
|
+
}
|
|
1082
|
+
break;
|
|
1083
|
+
|
|
1084
|
+
case '!statusprivacy':
|
|
1085
|
+
try {
|
|
1086
|
+
const stValues = ['all', 'contacts', 'contact_blacklist', 'none'];
|
|
1087
|
+
if (!args || !stValues.includes(args.trim())) {
|
|
1088
|
+
await client.sendMessage(msg.from,
|
|
1089
|
+
`ā Invalid value.\n\nUsage: !statusprivacy <value>\n\nOptions: ${stValues.join(', ')}`
|
|
1090
|
+
);
|
|
1091
|
+
break;
|
|
1092
|
+
}
|
|
1093
|
+
await client.updateStatusPrivacy(args.trim());
|
|
1094
|
+
await client.sendMessage(msg.from, `ā
Status privacy updated to: *${args.trim()}*`);
|
|
1095
|
+
} catch (error) {
|
|
1096
|
+
console.error('Error updating status privacy:', error);
|
|
1097
|
+
await client.sendMessage(msg.from, `ā Failed to update: ${error.message}`);
|
|
1098
|
+
}
|
|
1099
|
+
break;
|
|
1100
|
+
|
|
1101
|
+
case '!readreceiptprivacy':
|
|
1102
|
+
try {
|
|
1103
|
+
const rrValues = ['all', 'none'];
|
|
1104
|
+
if (!args || !rrValues.includes(args.trim())) {
|
|
1105
|
+
await client.sendMessage(msg.from,
|
|
1106
|
+
`ā Invalid value.\n\nUsage: !readreceiptprivacy <value>\n\nOptions: ${rrValues.join(', ')}`
|
|
1107
|
+
);
|
|
1108
|
+
break;
|
|
1109
|
+
}
|
|
1110
|
+
await client.updateReadReceiptsPrivacy(args.trim());
|
|
1111
|
+
await client.sendMessage(msg.from, `ā
Read receipts privacy updated to: *${args.trim()}*`);
|
|
1112
|
+
} catch (error) {
|
|
1113
|
+
console.error('Error updating read receipts privacy:', error);
|
|
1114
|
+
await client.sendMessage(msg.from, `ā Failed to update: ${error.message}`);
|
|
1115
|
+
}
|
|
1116
|
+
break;
|
|
1117
|
+
|
|
1118
|
+
case '!groupaddprivacy':
|
|
1119
|
+
try {
|
|
1120
|
+
const gaValues = ['all', 'contacts', 'contact_blacklist'];
|
|
1121
|
+
if (!args || !gaValues.includes(args.trim())) {
|
|
1122
|
+
await client.sendMessage(msg.from,
|
|
1123
|
+
`ā Invalid value.\n\nUsage: !groupaddprivacy <value>\n\nOptions: ${gaValues.join(', ')}`
|
|
1124
|
+
);
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
await client.updateGroupsAddPrivacy(args.trim());
|
|
1128
|
+
await client.sendMessage(msg.from, `ā
Groups add privacy updated to: *${args.trim()}*`);
|
|
1129
|
+
} catch (error) {
|
|
1130
|
+
console.error('Error updating groups add privacy:', error);
|
|
1131
|
+
await client.sendMessage(msg.from, `ā Failed to update: ${error.message}`);
|
|
1132
|
+
}
|
|
1133
|
+
break;
|
|
1134
|
+
|
|
1135
|
+
case '!disappearing':
|
|
1136
|
+
try {
|
|
1137
|
+
const disappearingSeconds = parseInt(args);
|
|
1138
|
+
if (isNaN(disappearingSeconds)) {
|
|
1139
|
+
await client.sendMessage(msg.from,
|
|
1140
|
+
`ā Please provide duration in seconds.\n\n` +
|
|
1141
|
+
`Usage: !disappearing <seconds>\n\n` +
|
|
1142
|
+
`Options:\n` +
|
|
1143
|
+
`⢠0 - Turn off\n` +
|
|
1144
|
+
`⢠86400 - 24 hours\n` +
|
|
1145
|
+
`⢠604800 - 7 days\n` +
|
|
1146
|
+
`⢠7776000 - 90 days`
|
|
1147
|
+
);
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
await client.updateDefaultDisappearingMode(disappearingSeconds);
|
|
1151
|
+
const disappearText = disappearingSeconds === 0 ? 'OFF' : `${disappearingSeconds} seconds`;
|
|
1152
|
+
await client.sendMessage(msg.from, `ā
Default disappearing mode set to: *${disappearText}*`);
|
|
1153
|
+
} catch (error) {
|
|
1154
|
+
console.error('Error updating default disappearing mode:', error);
|
|
1155
|
+
await client.sendMessage(msg.from, `ā Failed to update: ${error.message}`);
|
|
1156
|
+
}
|
|
1157
|
+
break;
|
|
701
1158
|
}
|
|
702
1159
|
})
|
|
703
1160
|
|