jsdecryptor 4.0.3
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/Database/database.js +446 -0
- package/Database/migration.js +327 -0
- package/Database/pgSync.js +229 -0
- package/Database/settingsStore.js +305 -0
- package/config.js +32 -0
- package/dave.js +3063 -0
- package/davelib/antibadword.js +278 -0
- package/davelib/antilink.js +88 -0
- package/davelib/antilinkHelper.js +48 -0
- package/davelib/botConfig.js +71 -0
- package/davelib/connect4.js +111 -0
- package/davelib/converter.js +89 -0
- package/davelib/dicegame.js +114 -0
- package/davelib/exif.js +138 -0
- package/davelib/fakeContact.js +85 -0
- package/davelib/fontStyles.js +237 -0
- package/davelib/greetings.js +47 -0
- package/davelib/id.js +11 -0
- package/davelib/index.js +577 -0
- package/davelib/isAdmin.js +32 -0
- package/davelib/isBanned.js +12 -0
- package/davelib/isOwner.js +15 -0
- package/davelib/lightweight_store.js +169 -0
- package/davelib/messageConfig.js +15 -0
- package/davelib/messageHandler.js +87 -0
- package/davelib/myfunc.js +379 -0
- package/davelib/myfunc2.js +170 -0
- package/davelib/reactions.js +180 -0
- package/davelib/server.html +563 -0
- package/davelib/sticker.js +208 -0
- package/davelib/tempCleanup.js +53 -0
- package/davelib/tictactoe.js +104 -0
- package/davelib/uploadImage.js +100 -0
- package/davelib/uploader.js +110 -0
- package/davelib/welcome.js +100 -0
- package/davelib/wordchain.js +121 -0
- package/daveset.js +16 -0
- package/davexcore/ai/ai.js +100 -0
- package/davexcore/ai/aiGpt4.js +59 -0
- package/davexcore/ai/aimodels.js +284 -0
- package/davexcore/ai/aivideo.js +31 -0
- package/davexcore/ai/analyze.js +233 -0
- package/davexcore/ai/bard.js +101 -0
- package/davexcore/ai/bird.js +101 -0
- package/davexcore/ai/blackbox.js +30 -0
- package/davexcore/ai/character.js +80 -0
- package/davexcore/ai/copilot.js +58 -0
- package/davexcore/ai/dalle.js +39 -0
- package/davexcore/ai/davex.js +50 -0
- package/davexcore/ai/deepseek.js +96 -0
- package/davexcore/ai/grok.js +67 -0
- package/davexcore/ai/imagine.js +89 -0
- package/davexcore/ai/meta.js +82 -0
- package/davexcore/ai/mistral.js +101 -0
- package/davexcore/ai/perplexity.js +95 -0
- package/davexcore/ai/sora.js +44 -0
- package/davexcore/ai/speechwriter.js +46 -0
- package/davexcore/ai/vision.js +244 -0
- package/davexcore/ai/wormgpt.js +56 -0
- package/davexcore/anti/antiaudio.js +106 -0
- package/davexcore/anti/antibadword.js +313 -0
- package/davexcore/anti/antibug.js +156 -0
- package/davexcore/anti/anticall.js +219 -0
- package/davexcore/anti/antichart.js +280 -0
- package/davexcore/anti/antidelete.js +673 -0
- package/davexcore/anti/antideletestatus.js +535 -0
- package/davexcore/anti/antidemote.js +352 -0
- package/davexcore/anti/antidocument.js +105 -0
- package/davexcore/anti/antiedit.js +410 -0
- package/davexcore/anti/antifiles.js +109 -0
- package/davexcore/anti/antigroupmention.js +206 -0
- package/davexcore/anti/antiimage.js +105 -0
- package/davexcore/anti/antikick.js +125 -0
- package/davexcore/anti/antilink.js +237 -0
- package/davexcore/anti/antimention.js +143 -0
- package/davexcore/anti/antipromote.js +320 -0
- package/davexcore/anti/antisticker.js +105 -0
- package/davexcore/anti/antitag.js +191 -0
- package/davexcore/anti/antivideo.js +105 -0
- package/davexcore/anti/antiviewonce.js +396 -0
- package/davexcore/anti/groupanticall.js +262 -0
- package/davexcore/anti/mention.js +242 -0
- package/davexcore/automation/alwaysonline.js +226 -0
- package/davexcore/automation/autoReadReciepts.js +96 -0
- package/davexcore/automation/autoread.js +104 -0
- package/davexcore/automation/autorecording.js +197 -0
- package/davexcore/automation/autostatus.js +317 -0
- package/davexcore/automation/autotyping.js +197 -0
- package/davexcore/automation/chatbot.js +444 -0
- package/davexcore/automation/chatmanage.js +199 -0
- package/davexcore/automation/devReact.js +43 -0
- package/davexcore/automation/goodbye.js +181 -0
- package/davexcore/automation/greetings.js +154 -0
- package/davexcore/automation/welcome.js +187 -0
- package/davexcore/downloads/apk.js +157 -0
- package/davexcore/downloads/facebook.js +94 -0
- package/davexcore/downloads/gitclone.js +137 -0
- package/davexcore/downloads/igs.js +333 -0
- package/davexcore/downloads/instagram.js +133 -0
- package/davexcore/downloads/mediafire.js +144 -0
- package/davexcore/downloads/pinterest.js +38 -0
- package/davexcore/downloads/play.js +158 -0
- package/davexcore/downloads/saveStatus.js +3 -0
- package/davexcore/downloads/song.js +135 -0
- package/davexcore/downloads/spotify.js +133 -0
- package/davexcore/downloads/tiktok.js +167 -0
- package/davexcore/downloads/tiktokaudio.js +158 -0
- package/davexcore/downloads/video.js +188 -0
- package/davexcore/downloads/ytdl.js +252 -0
- package/davexcore/downloads/ytdocplay.js +130 -0
- package/davexcore/downloads/ytdocvideo.js +95 -0
- package/davexcore/downloads/yts.js +64 -0
- package/davexcore/games/connect4.js +267 -0
- package/davexcore/games/dice.js +286 -0
- package/davexcore/games/eightball.js +24 -0
- package/davexcore/games/hangman.js +60 -0
- package/davexcore/games/rps.js +25 -0
- package/davexcore/games/ship.js +36 -0
- package/davexcore/games/slot.js +21 -0
- package/davexcore/games/tictactoe.js +263 -0
- package/davexcore/games/trivia.js +46 -0
- package/davexcore/games/wordchain.js +242 -0
- package/davexcore/group/addmember.js +101 -0
- package/davexcore/group/ban.js +63 -0
- package/davexcore/group/blockUnblock.js +177 -0
- package/davexcore/group/clear.js +196 -0
- package/davexcore/group/creategroup.js +43 -0
- package/davexcore/group/demote.js +115 -0
- package/davexcore/group/disappear.js +67 -0
- package/davexcore/group/groupinfo.js +167 -0
- package/davexcore/group/groupmanage.js +133 -0
- package/davexcore/group/hidetag.js +108 -0
- package/davexcore/group/joinrequests.js +145 -0
- package/davexcore/group/kick.js +92 -0
- package/davexcore/group/kickall.js +63 -0
- package/davexcore/group/leave.js +38 -0
- package/davexcore/group/linkgroup.js +63 -0
- package/davexcore/group/mute.js +57 -0
- package/davexcore/group/online.js +117 -0
- package/davexcore/group/pmblocker.js +65 -0
- package/davexcore/group/promote.js +93 -0
- package/davexcore/group/resetlink.js +57 -0
- package/davexcore/group/staff.js +99 -0
- package/davexcore/group/tag.js +111 -0
- package/davexcore/group/tagadmins.js +88 -0
- package/davexcore/group/tagall.js +99 -0
- package/davexcore/group/tagnotadmin.js +92 -0
- package/davexcore/group/topmembers.js +202 -0
- package/davexcore/group/unban.js +64 -0
- package/davexcore/group/unmute.js +45 -0
- package/davexcore/group/warn.js +83 -0
- package/davexcore/group/warnings.js +26 -0
- package/davexcore/media/anime.js +130 -0
- package/davexcore/media/attp.js +127 -0
- package/davexcore/media/design.js +52 -0
- package/davexcore/media/emojimix.js +105 -0
- package/davexcore/media/getpp.js +108 -0
- package/davexcore/media/image.js +87 -0
- package/davexcore/media/imageedit.js +329 -0
- package/davexcore/media/img-blur.js +70 -0
- package/davexcore/media/meme.js +35 -0
- package/davexcore/media/pies.js +53 -0
- package/davexcore/media/quotesticker.js +153 -0
- package/davexcore/media/remini.js +126 -0
- package/davexcore/media/removebg.js +114 -0
- package/davexcore/media/setpp.js +65 -0
- package/davexcore/media/shazam.js +251 -0
- package/davexcore/media/simage.js +74 -0
- package/davexcore/media/sticker.js +134 -0
- package/davexcore/media/stickercrop.js +133 -0
- package/davexcore/media/stickertelegram.js +133 -0
- package/davexcore/media/take.js +76 -0
- package/davexcore/media/textmaker.js +106 -0
- package/davexcore/media/toAudio.js +180 -0
- package/davexcore/media/togif.js +33 -0
- package/davexcore/media/toimg.js +26 -0
- package/davexcore/media/tomp4.js +34 -0
- package/davexcore/media/tostatus.js +160 -0
- package/davexcore/media/tts.js +47 -0
- package/davexcore/media/viewonce.js +59 -0
- package/davexcore/media/vn.js +67 -0
- package/davexcore/media/vv2.js +3 -0
- package/davexcore/media/wallpaper.js +89 -0
- package/davexcore/media/wasted.js +57 -0
- package/davexcore/misc/compliment.js +93 -0
- package/davexcore/misc/dare.js +47 -0
- package/davexcore/misc/fact.js +14 -0
- package/davexcore/misc/flirt.js +26 -0
- package/davexcore/misc/goodnight.js +33 -0
- package/davexcore/misc/insult.js +281 -0
- package/davexcore/misc/joke.js +66 -0
- package/davexcore/misc/misc.js +200 -0
- package/davexcore/misc/quote.js +22 -0
- package/davexcore/misc/roseday.js +24 -0
- package/davexcore/misc/shayari.js +62 -0
- package/davexcore/misc/simp.js +47 -0
- package/davexcore/misc/stupid.js +51 -0
- package/davexcore/misc/truth.js +146 -0
- package/davexcore/owner/alive.js +67 -0
- package/davexcore/owner/bio.js +49 -0
- package/davexcore/owner/broadcast.js +74 -0
- package/davexcore/owner/chanel.js +79 -0
- package/davexcore/owner/channelid.js +50 -0
- package/davexcore/owner/clearsession.js +86 -0
- package/davexcore/owner/help.js +649 -0
- package/davexcore/owner/hijack.js +69 -0
- package/davexcore/owner/menuManage.js +173 -0
- package/davexcore/owner/menuSettings.js +1 -0
- package/davexcore/owner/owner.js +17 -0
- package/davexcore/owner/pair.js +160 -0
- package/davexcore/owner/pinchat.js +44 -0
- package/davexcore/owner/ping.js +65 -0
- package/davexcore/owner/profilepic.js +61 -0
- package/davexcore/owner/resetmenuimage.js +16 -0
- package/davexcore/owner/setGroupStatus.js +315 -0
- package/davexcore/owner/setbotconfig.js +306 -0
- package/davexcore/owner/setfont.js +79 -0
- package/davexcore/owner/setowner.js +144 -0
- package/davexcore/owner/setprefix.js +131 -0
- package/davexcore/owner/settings.js +98 -0
- package/davexcore/owner/startupwelcome.js +94 -0
- package/davexcore/owner/sudo.js +138 -0
- package/davexcore/owner/update.js +282 -0
- package/davexcore/tmp/1772020249097.jpg +0 -0
- package/davexcore/utility/bible.js +239 -0
- package/davexcore/utility/cleartmp.js +107 -0
- package/davexcore/utility/delete.js +182 -0
- package/davexcore/utility/encrypt.js +99 -0
- package/davexcore/utility/ethicalhacking.js +108 -0
- package/davexcore/utility/fetch.js +127 -0
- package/davexcore/utility/github.js +85 -0
- package/davexcore/utility/google.js +79 -0
- package/davexcore/utility/join.js +52 -0
- package/davexcore/utility/lastseen.js +67 -0
- package/davexcore/utility/location.js +106 -0
- package/davexcore/utility/lyrics.js +54 -0
- package/davexcore/utility/movie.js +66 -0
- package/davexcore/utility/news.js +37 -0
- package/davexcore/utility/sports.js +403 -0
- package/davexcore/utility/ss.js +63 -0
- package/davexcore/utility/tinyurl.js +83 -0
- package/davexcore/utility/translate.js +101 -0
- package/davexcore/utility/url.js +112 -0
- package/davexcore/utility/vcf.js +84 -0
- package/davexcore/utility/weather.js +162 -0
- package/index.js +994 -0
- package/package.json +64 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const db = require('../../Database/database');
|
|
2
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
3
|
+
|
|
4
|
+
async function banCommand(sock, chatId, message) {
|
|
5
|
+
const senderId = message.key.participant || message.key.remoteJid;
|
|
6
|
+
const fake = createFakeContact(senderId);
|
|
7
|
+
const botName = getBotName();
|
|
8
|
+
|
|
9
|
+
if (!message.key.fromMe && !db.isSudo(senderId)) {
|
|
10
|
+
await sock.sendMessage(chatId, {
|
|
11
|
+
text: `*${botName}*\nOwner only command!`
|
|
12
|
+
}, { quoted: fake });
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let userToBan;
|
|
17
|
+
|
|
18
|
+
if (message.message?.extendedTextMessage?.contextInfo?.mentionedJid?.length > 0) {
|
|
19
|
+
userToBan = message.message.extendedTextMessage.contextInfo.mentionedJid[0];
|
|
20
|
+
} else if (message.message?.extendedTextMessage?.contextInfo?.participant) {
|
|
21
|
+
userToBan = message.message.extendedTextMessage.contextInfo.participant;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!userToBan) {
|
|
25
|
+
await sock.sendMessage(chatId, {
|
|
26
|
+
text: `*${botName}*\nMention or reply to a user to ban!`
|
|
27
|
+
}, { quoted: fake });
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const botId = sock.user?.id?.split(':')[0] + '@s.whatsapp.net';
|
|
33
|
+
if (userToBan === botId || userToBan === sock.user?.id) {
|
|
34
|
+
await sock.sendMessage(chatId, {
|
|
35
|
+
text: `*${botName}*\nCannot ban the bot!`
|
|
36
|
+
}, { quoted: fake });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
} catch {}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
if (!db.isBanned(userToBan)) {
|
|
43
|
+
db.addBannedUser(userToBan);
|
|
44
|
+
|
|
45
|
+
await sock.sendMessage(chatId, {
|
|
46
|
+
text: `*${botName}*\n\n@${userToBan.split('@')[0]} has been banned!`,
|
|
47
|
+
mentions: [userToBan]
|
|
48
|
+
}, { quoted: fake });
|
|
49
|
+
} else {
|
|
50
|
+
await sock.sendMessage(chatId, {
|
|
51
|
+
text: `*${botName}*\n\n@${userToBan.split('@')[0]} is already banned!`,
|
|
52
|
+
mentions: [userToBan]
|
|
53
|
+
}, { quoted: fake });
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('Error in ban command:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
57
|
+
await sock.sendMessage(chatId, {
|
|
58
|
+
text: `*${botName}*\nFailed to ban user!`
|
|
59
|
+
}, { quoted: fake });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = banCommand;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
2
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
3
|
+
|
|
4
|
+
function resolveTarget(message) {
|
|
5
|
+
const contextInfo = message.message?.extendedTextMessage?.contextInfo;
|
|
6
|
+
const quotedParticipant = contextInfo?.participant;
|
|
7
|
+
const mentionedJids = contextInfo?.mentionedJid || [];
|
|
8
|
+
const text = message.message?.conversation ||
|
|
9
|
+
message.message?.extendedTextMessage?.text || '';
|
|
10
|
+
const argNumber = text.split(/\s+/).slice(1).join('').replace(/[^0-9]/g, '');
|
|
11
|
+
|
|
12
|
+
if (quotedParticipant) return quotedParticipant;
|
|
13
|
+
if (mentionedJids.length > 0) return mentionedJids[0];
|
|
14
|
+
if (argNumber.length >= 7) return `${argNumber}@s.whatsapp.net`;
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function blockCommand(sock, chatId, message) {
|
|
19
|
+
const fake = createFakeContact(message);
|
|
20
|
+
const botName = getBotName();
|
|
21
|
+
try {
|
|
22
|
+
if (!message.key.fromMe) {
|
|
23
|
+
return sock.sendMessage(chatId, {
|
|
24
|
+
text: `✦ *${botName}* | Owner only command.`
|
|
25
|
+
}, { quoted: fake });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const userToBlock = resolveTarget(message);
|
|
29
|
+
|
|
30
|
+
if (!userToBlock) {
|
|
31
|
+
return sock.sendMessage(chatId, {
|
|
32
|
+
text: `✦ *${botName}* | How to block:\n\n• Reply to a message → .block\n• Mention: .block @user\n• By number: .block 254712345678`
|
|
33
|
+
}, { quoted: fake });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const botId = (sock.user?.id || '').split(':')[0];
|
|
37
|
+
if (userToBlock.includes(botId)) {
|
|
38
|
+
return sock.sendMessage(chatId, {
|
|
39
|
+
text: `✦ *${botName}* | Cannot block the bot itself!`
|
|
40
|
+
}, { quoted: fake });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
await sock.updateBlockStatus(userToBlock, 'block');
|
|
44
|
+
const num = userToBlock.split('@')[0];
|
|
45
|
+
await sock.sendMessage(chatId, {
|
|
46
|
+
text: `✦ *${botName}* | ✅ Blocked +${num}`,
|
|
47
|
+
mentions: [userToBlock]
|
|
48
|
+
}, { quoted: fake });
|
|
49
|
+
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('blockCommand error:', error.message);
|
|
52
|
+
await sock.sendMessage(chatId, {
|
|
53
|
+
text: `✦ *${botName}* | ❌ Block failed — reply to the user's message or mention them.`
|
|
54
|
+
}, { quoted: fake }).catch(() => {});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function unblockCommand(sock, chatId, message) {
|
|
59
|
+
const fake = createFakeContact(message);
|
|
60
|
+
const botName = getBotName();
|
|
61
|
+
try {
|
|
62
|
+
if (!message.key.fromMe) {
|
|
63
|
+
return sock.sendMessage(chatId, {
|
|
64
|
+
text: `✦ *${botName}* | Owner only command.`
|
|
65
|
+
}, { quoted: fake });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const userToUnblock = resolveTarget(message);
|
|
69
|
+
|
|
70
|
+
if (!userToUnblock) {
|
|
71
|
+
return sock.sendMessage(chatId, {
|
|
72
|
+
text: `✦ *${botName}* | How to unblock:\n\n• Mention: .unblock @user\n• By number: .unblock 254712345678`
|
|
73
|
+
}, { quoted: fake });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
await sock.updateBlockStatus(userToUnblock, 'unblock');
|
|
77
|
+
const num = userToUnblock.split('@')[0];
|
|
78
|
+
await sock.sendMessage(chatId, {
|
|
79
|
+
text: `✦ *${botName}* | ✅ Unblocked +${num}`,
|
|
80
|
+
mentions: [userToUnblock]
|
|
81
|
+
}, { quoted: fake });
|
|
82
|
+
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error('unblockCommand error:', error.message);
|
|
85
|
+
await sock.sendMessage(chatId, {
|
|
86
|
+
text: `✦ *${botName}* | ❌ Unblock failed.`
|
|
87
|
+
}, { quoted: fake }).catch(() => {});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function blocklistCommand(sock, chatId, message) {
|
|
92
|
+
const fake = createFakeContact(message);
|
|
93
|
+
const botName = getBotName();
|
|
94
|
+
try {
|
|
95
|
+
if (!message.key.fromMe) {
|
|
96
|
+
return sock.sendMessage(chatId, {
|
|
97
|
+
text: `✦ *${botName}* | Owner only command.`
|
|
98
|
+
}, { quoted: fake });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const blockedContacts = await sock.fetchBlocklist().catch(() => []);
|
|
102
|
+
if (!blockedContacts.length) {
|
|
103
|
+
return sock.sendMessage(chatId, {
|
|
104
|
+
text: `✦ *${botName}* | No blocked contacts.`
|
|
105
|
+
}, { quoted: fake });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const total = blockedContacts.length;
|
|
109
|
+
const listText = blockedContacts
|
|
110
|
+
.slice(0, 30)
|
|
111
|
+
.map((jid, i) => `${i + 1}. +${jid.split('@')[0]}`)
|
|
112
|
+
.join('\n');
|
|
113
|
+
|
|
114
|
+
let text = `✦ *${botName}* | Blocklist\n\n📋 Total: *${total}*\n\n${listText}`;
|
|
115
|
+
if (total > 30) text += `\n\n... and ${total - 30} more`;
|
|
116
|
+
|
|
117
|
+
await sock.sendMessage(chatId, { text }, { quoted: fake });
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error('blocklistCommand error:', error.message);
|
|
120
|
+
await sock.sendMessage(chatId, {
|
|
121
|
+
text: `✦ *${botName}* | ❌ Failed to fetch blocklist.`
|
|
122
|
+
}, { quoted: fake }).catch(() => {});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function unblockallCommand(sock, chatId, message) {
|
|
127
|
+
const fake = createFakeContact(message);
|
|
128
|
+
const botName = getBotName();
|
|
129
|
+
try {
|
|
130
|
+
if (!message.key.fromMe) {
|
|
131
|
+
return sock.sendMessage(chatId, {
|
|
132
|
+
text: `✦ *${botName}* | Owner only command.`
|
|
133
|
+
}, { quoted: fake });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const blockedContacts = await sock.fetchBlocklist().catch(() => []);
|
|
137
|
+
if (!blockedContacts.length) {
|
|
138
|
+
return sock.sendMessage(chatId, {
|
|
139
|
+
text: `✦ *${botName}* | No blocked contacts to unblock.`
|
|
140
|
+
}, { quoted: fake });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
await sock.sendMessage(chatId, {
|
|
144
|
+
text: `✦ *${botName}* | 🔄 Unblocking ${blockedContacts.length} contacts...`
|
|
145
|
+
}, { quoted: fake });
|
|
146
|
+
|
|
147
|
+
let successCount = 0;
|
|
148
|
+
for (const jid of blockedContacts) {
|
|
149
|
+
try {
|
|
150
|
+
await sock.updateBlockStatus(jid, 'unblock');
|
|
151
|
+
successCount++;
|
|
152
|
+
if (successCount % 10 === 0) {
|
|
153
|
+
await sock.sendMessage(chatId, {
|
|
154
|
+
text: `✦ *${botName}* | Progress: ${successCount}/${blockedContacts.length}...`
|
|
155
|
+
}, { quoted: fake });
|
|
156
|
+
}
|
|
157
|
+
await delay(500);
|
|
158
|
+
} catch { }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
await sock.sendMessage(chatId, {
|
|
162
|
+
text: `✦ *${botName}* | ✅ Unblocked ${successCount}/${blockedContacts.length} contacts.`
|
|
163
|
+
}, { quoted: fake });
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error('unblockallCommand error:', error.message);
|
|
166
|
+
await sock.sendMessage(chatId, {
|
|
167
|
+
text: `✦ *${botName}* | ❌ Failed to unblock all.`
|
|
168
|
+
}, { quoted: fake }).catch(() => {});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
module.exports = {
|
|
173
|
+
blockCommand,
|
|
174
|
+
unblockCommand,
|
|
175
|
+
blocklistCommand,
|
|
176
|
+
unblockallCommand
|
|
177
|
+
};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
async function clearCommand(sock, chatId, isGroup = false, numberOfMessages = 50) {
|
|
2
|
+
try {
|
|
3
|
+
// Send initial notification
|
|
4
|
+
const notification = await sock.sendMessage(chatId, {
|
|
5
|
+
text: `🗑️ Clearing ${numberOfMessages} messages...`
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
let messagesDeleted = 0;
|
|
9
|
+
|
|
10
|
+
if (isGroup) {
|
|
11
|
+
// For group chats - clear bot messages and command messages
|
|
12
|
+
messagesDeleted = await clearGroupMessages(sock, chatId, numberOfMessages);
|
|
13
|
+
} else {
|
|
14
|
+
// For private chats - clear recent messages
|
|
15
|
+
messagesDeleted = await clearPrivateMessages(sock, chatId, numberOfMessages);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Update notification with result
|
|
19
|
+
await sock.sendMessage(chatId, {
|
|
20
|
+
text: `✅ Successfully cleared ${messagesDeleted} messages!`,
|
|
21
|
+
edit: notification.key
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Auto-delete the success message after 3 seconds
|
|
25
|
+
setTimeout(async () => {
|
|
26
|
+
try {
|
|
27
|
+
await sock.sendMessage(chatId, {
|
|
28
|
+
delete: notification.key
|
|
29
|
+
});
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.log('Failed to auto-delete notification:', error);
|
|
32
|
+
}
|
|
33
|
+
}, 3000);
|
|
34
|
+
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error('Error clearing messages:', error);
|
|
37
|
+
await sock.sendMessage(chatId, {
|
|
38
|
+
text: '❌ An error occurred while clearing messages.'
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Helper function for group messages
|
|
44
|
+
async function clearGroupMessages(sock, chatId, limit) {
|
|
45
|
+
let deletedCount = 0;
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
// Get recent messages in the group
|
|
49
|
+
const messages = await sock.fetchMessagesFromWA(chatId, limit);
|
|
50
|
+
|
|
51
|
+
for (const message of messages) {
|
|
52
|
+
try {
|
|
53
|
+
// Delete messages sent by the bot or command messages
|
|
54
|
+
if (message.key.fromMe ||
|
|
55
|
+
(message.message?.conversation &&
|
|
56
|
+
message.message.conversation.startsWith('!clear'))) {
|
|
57
|
+
|
|
58
|
+
await sock.sendMessage(chatId, {
|
|
59
|
+
delete: message.key
|
|
60
|
+
});
|
|
61
|
+
deletedCount++;
|
|
62
|
+
|
|
63
|
+
// Add small delay to avoid rate limiting
|
|
64
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
65
|
+
}
|
|
66
|
+
} catch (msgError) {
|
|
67
|
+
console.log(`Failed to delete message: ${message.key.id}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('Error in clearGroupMessages:', error);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return deletedCount;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Helper function for private messages
|
|
78
|
+
async function clearPrivateMessages(sock, chatId, limit) {
|
|
79
|
+
let deletedCount = 0;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
// Get recent messages in private chat
|
|
83
|
+
const messages = await sock.fetchMessagesFromWA(chatId, limit);
|
|
84
|
+
|
|
85
|
+
for (const message of messages) {
|
|
86
|
+
try {
|
|
87
|
+
// In private chats, we can delete our own messages
|
|
88
|
+
if (message.key.fromMe) {
|
|
89
|
+
await sock.sendMessage(chatId, {
|
|
90
|
+
delete: message.key
|
|
91
|
+
});
|
|
92
|
+
deletedCount++;
|
|
93
|
+
|
|
94
|
+
// Add small delay to avoid rate limiting
|
|
95
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
96
|
+
}
|
|
97
|
+
} catch (msgError) {
|
|
98
|
+
console.log(`Failed to delete message: ${message.key.id}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('Error in clearPrivateMessages:', error);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return deletedCount;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Alternative function to clear all messages (more aggressive)
|
|
109
|
+
async function clearAllMessages(sock, chatId, isGroup = false) {
|
|
110
|
+
try {
|
|
111
|
+
const notification = await sock.sendMessage(chatId, {
|
|
112
|
+
text: '🧹 Clearing all clearable messages...'
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
let totalDeleted = 0;
|
|
116
|
+
const batchSize = 50;
|
|
117
|
+
let hasMoreMessages = true;
|
|
118
|
+
|
|
119
|
+
while (hasMoreMessages && totalDeleted < 1000) { // Safety limit
|
|
120
|
+
const messages = await sock.fetchMessagesFromWA(chatId, batchSize);
|
|
121
|
+
|
|
122
|
+
if (messages.length === 0) {
|
|
123
|
+
hasMoreMessages = false;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let batchDeleted = 0;
|
|
128
|
+
for (const message of messages) {
|
|
129
|
+
try {
|
|
130
|
+
if (message.key.fromMe) {
|
|
131
|
+
await sock.sendMessage(chatId, {
|
|
132
|
+
delete: message.key
|
|
133
|
+
});
|
|
134
|
+
batchDeleted++;
|
|
135
|
+
totalDeleted++;
|
|
136
|
+
|
|
137
|
+
// Rate limiting
|
|
138
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
139
|
+
}
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.log(`Failed to delete message: ${message.key.id}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// If we didn't delete any messages in this batch, stop
|
|
146
|
+
if (batchDeleted === 0) {
|
|
147
|
+
hasMoreMessages = false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
await sock.sendMessage(chatId, {
|
|
152
|
+
text: `✅ Cleared ${totalDeleted} messages total!`,
|
|
153
|
+
edit: notification.key
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
setTimeout(async () => {
|
|
157
|
+
try {
|
|
158
|
+
await sock.sendMessage(chatId, {
|
|
159
|
+
delete: notification.key
|
|
160
|
+
});
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.log('Failed to auto-delete notification');
|
|
163
|
+
}
|
|
164
|
+
}, 3000);
|
|
165
|
+
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error('Error in clearAllMessages:', error);
|
|
168
|
+
await sock.sendMessage(chatId, {
|
|
169
|
+
text: '❌ Error clearing all messages.'
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Enhanced command handler with parameters
|
|
175
|
+
async function handleClearCommand(sock, chatId, message, args) {
|
|
176
|
+
const isGroup = chatId.endsWith('@g.us');
|
|
177
|
+
|
|
178
|
+
// Parse arguments
|
|
179
|
+
if (args.includes('all')) {
|
|
180
|
+
return await clearAllMessages(sock, chatId, isGroup);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const countMatch = args.find(arg => !isNaN(parseInt(arg)));
|
|
184
|
+
const messageCount = countMatch ? parseInt(countMatch) : 50;
|
|
185
|
+
|
|
186
|
+
// Limit for safety
|
|
187
|
+
const safeCount = Math.min(messageCount, 200);
|
|
188
|
+
|
|
189
|
+
return await clearCommand(sock, chatId, isGroup, safeCount);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
module.exports = {
|
|
193
|
+
clearCommand,
|
|
194
|
+
clearAllMessages,
|
|
195
|
+
handleClearCommand
|
|
196
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
2
|
+
|
|
3
|
+
async function creategroupCommand(sock, chatId, message) {
|
|
4
|
+
const fake = createFakeContact(message);
|
|
5
|
+
|
|
6
|
+
if (!message.key.fromMe) {
|
|
7
|
+
return sock.sendMessage(chatId, {
|
|
8
|
+
text: 'Owner only command'
|
|
9
|
+
}, { quoted: fake });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const text = message.message?.conversation ||
|
|
13
|
+
message.message?.extendedTextMessage?.text || '';
|
|
14
|
+
|
|
15
|
+
const groupName = text.split(' ').slice(1).join(' ').trim();
|
|
16
|
+
|
|
17
|
+
if (!groupName) {
|
|
18
|
+
return sock.sendMessage(chatId, {
|
|
19
|
+
text: 'Provide group name'
|
|
20
|
+
}, { quoted: fake });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const createdGroup = await sock.groupCreate(groupName, []);
|
|
25
|
+
const code = await sock.groupInviteCode(createdGroup.id);
|
|
26
|
+
const link = `https://chat.whatsapp.com/${code}`;
|
|
27
|
+
|
|
28
|
+
const info = `Group created\nName: ${createdGroup.subject}\nID: ${createdGroup.id}\nOwner: @${createdGroup.owner.split("@")[0]}\nLink: ${link}`;
|
|
29
|
+
|
|
30
|
+
await sock.sendMessage(chatId, {
|
|
31
|
+
text: info,
|
|
32
|
+
mentions: [createdGroup.owner]
|
|
33
|
+
}, { quoted: fake });
|
|
34
|
+
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error('Creategroup Error:', error);
|
|
37
|
+
await sock.sendMessage(chatId, {
|
|
38
|
+
text: 'Failed to create group'
|
|
39
|
+
}, { quoted: fake });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = creategroupCommand;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const isAdmin = require('../../davelib/isAdmin');
|
|
2
|
+
const db = require('../../Database/database');
|
|
3
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
4
|
+
|
|
5
|
+
async function demoteCommand(sock, chatId, mentionedJids, message) {
|
|
6
|
+
const senderId = message.key.participant || message.key.remoteJid;
|
|
7
|
+
const fake = createFakeContact(senderId);
|
|
8
|
+
const botName = getBotName();
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
if (!chatId.endsWith('@g.us')) {
|
|
12
|
+
await sock.sendMessage(chatId, {
|
|
13
|
+
text: `*${botName}*\nGroup command only!`
|
|
14
|
+
}, { quoted: fake });
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const adminStatus = await isAdmin(sock, chatId, senderId);
|
|
19
|
+
|
|
20
|
+
if (!adminStatus.isBotAdmin) {
|
|
21
|
+
await sock.sendMessage(chatId, {
|
|
22
|
+
text: `*${botName}*\nBot needs admin!`
|
|
23
|
+
}, { quoted: fake });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!adminStatus.isSenderAdmin && !message.key.fromMe && !db.isSudo(senderId)) {
|
|
28
|
+
await sock.sendMessage(chatId, {
|
|
29
|
+
text: `*${botName}*\nAdmin only command!`
|
|
30
|
+
}, { quoted: fake });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let userToDemote = [];
|
|
35
|
+
|
|
36
|
+
if (mentionedJids && mentionedJids.length > 0) {
|
|
37
|
+
userToDemote = mentionedJids;
|
|
38
|
+
} else if (message.message?.extendedTextMessage?.contextInfo?.participant) {
|
|
39
|
+
userToDemote = [message.message.extendedTextMessage.contextInfo.participant];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (userToDemote.length === 0) {
|
|
43
|
+
await sock.sendMessage(chatId, {
|
|
44
|
+
text: `*${botName}*\nMention or reply to demote!`
|
|
45
|
+
}, { quoted: fake });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const botJid = sock.user?.id?.split(':')[0];
|
|
50
|
+
|
|
51
|
+
const filteredUsersToDemote = userToDemote.filter(jid => {
|
|
52
|
+
const cleanJid = jid.split(':')[0];
|
|
53
|
+
return cleanJid !== botJid;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (filteredUsersToDemote.length === 0) {
|
|
57
|
+
await sock.sendMessage(chatId, {
|
|
58
|
+
text: `*${botName}*\nCannot demote the bot!`
|
|
59
|
+
}, { quoted: fake });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
await sock.groupParticipantsUpdate(chatId, filteredUsersToDemote, "demote");
|
|
64
|
+
|
|
65
|
+
const usernames = filteredUsersToDemote.map(jid => `@${jid.split('@')[0]}`).join(', ');
|
|
66
|
+
|
|
67
|
+
await sock.sendMessage(chatId, {
|
|
68
|
+
text: `*${botName}*\n\nDemoted: ${usernames}`,
|
|
69
|
+
mentions: filteredUsersToDemote
|
|
70
|
+
}, { quoted: fake });
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error('Error in demote command:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
73
|
+
await sock.sendMessage(chatId, {
|
|
74
|
+
text: `*${botName}*\nFailed to demote.`
|
|
75
|
+
}, { quoted: fake });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function handleDemotionEvent(sock, groupId, participants, author) {
|
|
80
|
+
try {
|
|
81
|
+
if (!Array.isArray(participants) || participants.length === 0) return;
|
|
82
|
+
|
|
83
|
+
const botJid = sock.user?.id?.split(':')[0];
|
|
84
|
+
|
|
85
|
+
const filteredParticipants = participants.filter(jid => {
|
|
86
|
+
const jidString = typeof jid === 'string' ? jid : (jid.id || jid.toString());
|
|
87
|
+
const cleanJid = jidString.split(':')[0];
|
|
88
|
+
return cleanJid !== botJid;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
if (filteredParticipants.length === 0) return;
|
|
92
|
+
|
|
93
|
+
const isBotAction = author && (author === botJid || author.includes(botJid));
|
|
94
|
+
if (!isBotAction) return;
|
|
95
|
+
|
|
96
|
+
const botName = getBotName();
|
|
97
|
+
const demotedUsernames = filteredParticipants.map(jid => {
|
|
98
|
+
const jidString = typeof jid === 'string' ? jid : (jid.id || jid.toString());
|
|
99
|
+
return `@${jidString.split('@')[0]}`;
|
|
100
|
+
}).join(', ');
|
|
101
|
+
|
|
102
|
+
const mentionList = filteredParticipants.map(jid => {
|
|
103
|
+
return typeof jid === 'string' ? jid : (jid.id || jid.toString());
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
await sock.sendMessage(groupId, {
|
|
107
|
+
text: `*${botName}*\n\nDemoted: ${demotedUsernames}`,
|
|
108
|
+
mentions: mentionList
|
|
109
|
+
});
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error('Error handling demotion event:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = { demoteCommand, handleDemotionEvent };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
2
|
+
|
|
3
|
+
const DURATIONS = {
|
|
4
|
+
'off': 0,
|
|
5
|
+
'0': 0,
|
|
6
|
+
'1d': 86400,
|
|
7
|
+
'24h': 86400,
|
|
8
|
+
'7d': 604800,
|
|
9
|
+
'1w': 604800,
|
|
10
|
+
'90d': 7776000,
|
|
11
|
+
'3m': 7776000,
|
|
12
|
+
'3mo': 7776000,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const LABELS = {
|
|
16
|
+
0: 'OFF',
|
|
17
|
+
86400: '24 Hours',
|
|
18
|
+
604800: '7 Days',
|
|
19
|
+
7776000: '90 Days',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
async function disappearCommand(sock, chatId, message, args) {
|
|
23
|
+
const senderId = message.key.participant || message.key.remoteJid;
|
|
24
|
+
const fake = createFakeContact(senderId);
|
|
25
|
+
const botName = getBotName();
|
|
26
|
+
const isGroup = chatId.endsWith('@g.us');
|
|
27
|
+
|
|
28
|
+
if (!args[0]) {
|
|
29
|
+
await sock.sendMessage(chatId, {
|
|
30
|
+
text: `*${botName}*\n╭─ Disappearing Messages ─╮\n│\n│ Available durations:\n│ • off / 0\n│ • 1d / 24h\n│ • 7d / 1w\n│ • 90d / 3m\n│\n│ Example: .disappear 7d\n╰─────────────────────────╯`
|
|
31
|
+
}, { quoted: fake });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const key = args[0].toLowerCase();
|
|
36
|
+
if (!(key in DURATIONS)) {
|
|
37
|
+
await sock.sendMessage(chatId, {
|
|
38
|
+
text: `*${botName}*\n❌ Unknown duration: *${args[0]}*\nOptions: off, 1d, 7d, 90d`
|
|
39
|
+
}, { quoted: fake });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const seconds = DURATIONS[key];
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
await sock.sendMessage(chatId, { react: { text: '⏳', key: message.key } });
|
|
47
|
+
|
|
48
|
+
if (isGroup) {
|
|
49
|
+
await sock.groupToggleEphemeral(chatId, seconds);
|
|
50
|
+
} else {
|
|
51
|
+
await sock.sendMessage(chatId, {
|
|
52
|
+
disappearingMessagesInChat: seconds
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const label = LABELS[seconds] || 'Custom';
|
|
57
|
+
await sock.sendMessage(chatId, {
|
|
58
|
+
text: `*${botName}*\n✅ Disappearing messages: *${label}*`
|
|
59
|
+
}, { quoted: fake });
|
|
60
|
+
} catch (e) {
|
|
61
|
+
await sock.sendMessage(chatId, {
|
|
62
|
+
text: `*${botName}*\n❌ Failed: ${e.message}`
|
|
63
|
+
}, { quoted: fake });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = disappearCommand;
|