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,352 @@
|
|
|
1
|
+
const { getGroupConfig, setGroupConfig } = require('../../Database/settingsStore');
|
|
2
|
+
const db = require('../../Database/database');
|
|
3
|
+
const isAdmin = require('../../davelib/isAdmin');
|
|
4
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
5
|
+
const { getPrefix } = require('../owner/setprefix');
|
|
6
|
+
|
|
7
|
+
function normalizeJid(jid) {
|
|
8
|
+
if (!jid) return '';
|
|
9
|
+
const str = typeof jid === 'string' ? jid : (jid.id || jid.toString());
|
|
10
|
+
const num = str.split('@')[0].split(':')[0];
|
|
11
|
+
return num + '@s.whatsapp.net';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function resolveToPhone(sock, jid) {
|
|
15
|
+
if (!jid) return 'unknown';
|
|
16
|
+
const raw = jid.split('@')[0].split(':')[0];
|
|
17
|
+
if (/^\d{7,15}$/.test(raw)) return raw;
|
|
18
|
+
try {
|
|
19
|
+
if (sock?.signalRepository?.lidMapping?.getPNForLID) {
|
|
20
|
+
const formats = [jid, `${raw}:0@lid`, `${raw}@lid`];
|
|
21
|
+
for (const fmt of formats) {
|
|
22
|
+
try {
|
|
23
|
+
const pn = await sock.signalRepository.lidMapping.getPNForLID(fmt);
|
|
24
|
+
if (pn) {
|
|
25
|
+
const num = String(pn).split('@')[0].replace(/[^0-9]/g, '');
|
|
26
|
+
if (num.length >= 7 && num.length <= 15 && num !== raw) return num;
|
|
27
|
+
}
|
|
28
|
+
} catch {}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const groups = await sock.groupFetchAllParticipating();
|
|
32
|
+
for (const gid of Object.keys(groups)) {
|
|
33
|
+
for (const p of (groups[gid].participants || [])) {
|
|
34
|
+
const pid = (p.id || '').split('@')[0].split(':')[0];
|
|
35
|
+
const pLid = (p.lid || '').split('@')[0].split(':')[0];
|
|
36
|
+
if ((pLid === raw || pid === raw) && pid && /^\d{7,15}$/.test(pid) && pid !== raw) return pid;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} catch {}
|
|
40
|
+
return raw;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function handleAntidemote(sock, groupId, participants, author) {
|
|
44
|
+
try {
|
|
45
|
+
const config = getGroupConfig(groupId, 'antidemote');
|
|
46
|
+
if (!config || !config.enabled) return false;
|
|
47
|
+
|
|
48
|
+
const botName = getBotName();
|
|
49
|
+
const fake = createFakeContact();
|
|
50
|
+
const botJid = normalizeJid(sock.user?.id);
|
|
51
|
+
|
|
52
|
+
let groupMetadata;
|
|
53
|
+
try {
|
|
54
|
+
groupMetadata = await sock.groupMetadata(groupId);
|
|
55
|
+
} catch (metaErr) {
|
|
56
|
+
console.error('Antidemote: Failed to fetch group metadata:', metaErr.message);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const ownerJid = normalizeJid(groupMetadata.owner);
|
|
61
|
+
const normalizedAuthor = normalizeJid(author);
|
|
62
|
+
const isAuthorOwner = normalizedAuthor === ownerJid ||
|
|
63
|
+
(author && groupMetadata.owner && author === groupMetadata.owner);
|
|
64
|
+
|
|
65
|
+
const isAuthorSudo = db.isSudo(author) || db.isSudo(normalizedAuthor);
|
|
66
|
+
|
|
67
|
+
if (isAuthorOwner || isAuthorSudo) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Bot's own actions should not trigger antidemote
|
|
72
|
+
const authorNum = author?.split('@')[0]?.split(':')[0];
|
|
73
|
+
const botNum = sock.user?.id?.split(':')[0]?.split('@')[0];
|
|
74
|
+
const botLidNum = sock.user?.lid?.split(':')[0]?.split('@')[0];
|
|
75
|
+
if (authorNum === botNum || (botLidNum && authorNum === botLidNum)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const participantJids = participants.map(p => typeof p === 'string' ? p : (p.id || String(p)));
|
|
80
|
+
const mode = config.mode || 'revert';
|
|
81
|
+
|
|
82
|
+
const botLid = sock.user?.lid;
|
|
83
|
+
const botLidNorm = botLid ? normalizeJid(botLid) : null;
|
|
84
|
+
const isBotDemoted = participantJids.some(p => {
|
|
85
|
+
const norm = normalizeJid(p);
|
|
86
|
+
if (norm === botJid) return true;
|
|
87
|
+
if (botLidNorm && norm === botLidNorm) return true;
|
|
88
|
+
const pNum = p.split('@')[0].split(':')[0];
|
|
89
|
+
if (pNum === botNum) return true;
|
|
90
|
+
if (botLidNum && pNum === botLidNum) return true;
|
|
91
|
+
return false;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const botParticipant = groupMetadata.participants.find(p => {
|
|
95
|
+
if (normalizeJid(p.id) === botJid || p.id === botJid) return true;
|
|
96
|
+
if (botLidNorm && (normalizeJid(p.id) === botLidNorm || p.id === botLid)) return true;
|
|
97
|
+
const pNum = (p.id || '').split('@')[0].split(':')[0];
|
|
98
|
+
if (pNum === botNum) return true;
|
|
99
|
+
if (botLidNum && pNum === botLidNum) return true;
|
|
100
|
+
return false;
|
|
101
|
+
});
|
|
102
|
+
// Fallback: if bot not found in participant list, assume it's still admin
|
|
103
|
+
const isBotAdmin = !botParticipant || botParticipant.admin === 'admin' || botParticipant.admin === 'superadmin';
|
|
104
|
+
|
|
105
|
+
// If the BOT itself was demoted, alert owner immediately regardless of current admin state
|
|
106
|
+
if (isBotDemoted) {
|
|
107
|
+
const authorNumber = await resolveToPhone(sock, author);
|
|
108
|
+
let groupName = '';
|
|
109
|
+
try { groupName = groupMetadata.subject || groupId; } catch {}
|
|
110
|
+
const ownerNumber = sock.user.id.split(':')[0] + '@s.whatsapp.net';
|
|
111
|
+
// Alert owner in DM
|
|
112
|
+
try {
|
|
113
|
+
await sock.sendMessage(ownerNumber, {
|
|
114
|
+
text: `⚠️ *${botName} - BOT DEMOTED*\n\n*Group:* ${groupName}\n*Demoted by:* @${authorNumber}\n\nAntidemote cannot protect the group until you re-promote me!\nRe-add me as admin to restore protection.`,
|
|
115
|
+
mentions: [author]
|
|
116
|
+
});
|
|
117
|
+
} catch {}
|
|
118
|
+
// Warn in the group
|
|
119
|
+
await sock.sendMessage(groupId, {
|
|
120
|
+
text: `┌─ *${botName}* ─┐\n│\n│ ⚠️ I was demoted by @${authorNumber}!\n│ I can no longer protect this group.\n│ Owner has been notified.\n│\n└─────────────┘`,
|
|
121
|
+
mentions: [author]
|
|
122
|
+
}, { quoted: fake });
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!isBotAdmin) {
|
|
127
|
+
await sock.sendMessage(groupId, {
|
|
128
|
+
text: `┌─ *${botName}* ─┐\n│\n│ Cannot reverse demotion - bot needs admin!\n│\n└─────────────┘`
|
|
129
|
+
}, { quoted: fake });
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const authorNumber = await resolveToPhone(sock, author);
|
|
134
|
+
const targetNumber = await resolveToPhone(sock, participantJids[0]);
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
await sock.groupParticipantsUpdate(groupId, participantJids, "promote");
|
|
138
|
+
console.log(`[ANTIDEMOTE] Reverted demotion of ${targetNumber} in ${groupId}`);
|
|
139
|
+
} catch (promoteErr) {
|
|
140
|
+
console.log('[ANTIDEMOTE] Promote call returned:', promoteErr.message, '(action may still have succeeded)');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (mode === 'kick') {
|
|
144
|
+
try {
|
|
145
|
+
await sock.groupParticipantsUpdate(groupId, [author], "remove");
|
|
146
|
+
} catch (e) {}
|
|
147
|
+
await sock.sendMessage(groupId, {
|
|
148
|
+
text: `┌─ *${botName}* ─┐
|
|
149
|
+
│
|
|
150
|
+
│ @${authorNumber} tried to demote @${targetNumber}
|
|
151
|
+
│ Demotion reverted & offender kicked!
|
|
152
|
+
│
|
|
153
|
+
└─────────────┘`,
|
|
154
|
+
mentions: [author, ...participantJids]
|
|
155
|
+
}, { quoted: fake });
|
|
156
|
+
} else if (mode === 'warn') {
|
|
157
|
+
const maxWarnings = config.maxWarnings || 3;
|
|
158
|
+
const warningCount = db.incrementWarning(groupId, author);
|
|
159
|
+
if (warningCount >= maxWarnings) {
|
|
160
|
+
try {
|
|
161
|
+
await sock.groupParticipantsUpdate(groupId, [author], "remove");
|
|
162
|
+
} catch (e) {}
|
|
163
|
+
db.resetWarning(groupId, author);
|
|
164
|
+
await sock.sendMessage(groupId, {
|
|
165
|
+
text: `┌─ *${botName}* ─┐
|
|
166
|
+
│
|
|
167
|
+
│ @${authorNumber} tried to demote @${targetNumber}
|
|
168
|
+
│ Demotion reverted & kicked after ${maxWarnings} warnings!
|
|
169
|
+
│
|
|
170
|
+
└─────────────┘`,
|
|
171
|
+
mentions: [author, ...participantJids]
|
|
172
|
+
}, { quoted: fake });
|
|
173
|
+
} else {
|
|
174
|
+
await sock.sendMessage(groupId, {
|
|
175
|
+
text: `┌─ *${botName}* ─┐
|
|
176
|
+
│
|
|
177
|
+
│ @${authorNumber} tried to demote @${targetNumber}
|
|
178
|
+
│ Demotion reverted! Warning ${warningCount}/${maxWarnings}
|
|
179
|
+
│
|
|
180
|
+
└─────────────┘`,
|
|
181
|
+
mentions: [author, ...participantJids]
|
|
182
|
+
}, { quoted: fake });
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
try {
|
|
186
|
+
await sock.groupParticipantsUpdate(groupId, [author], "demote");
|
|
187
|
+
} catch (e) {}
|
|
188
|
+
await sock.sendMessage(groupId, {
|
|
189
|
+
text: `┌─ *${botName}* ─┐
|
|
190
|
+
│
|
|
191
|
+
│ @${authorNumber} tried to demote @${targetNumber}
|
|
192
|
+
│ Demotion reverted & offender demoted!
|
|
193
|
+
│
|
|
194
|
+
└─────────────┘`,
|
|
195
|
+
mentions: [author, ...participantJids]
|
|
196
|
+
}, { quoted: fake });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return true;
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error('Error in handleAntidemote:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async function antidemoteCommand(sock, chatId, message, senderId) {
|
|
207
|
+
try {
|
|
208
|
+
const fake = createFakeContact(senderId);
|
|
209
|
+
const botName = getBotName();
|
|
210
|
+
const prefix = getPrefix();
|
|
211
|
+
|
|
212
|
+
const userMessage = message.message?.conversation ||
|
|
213
|
+
message.message?.extendedTextMessage?.text || '';
|
|
214
|
+
const args = userMessage.split(' ');
|
|
215
|
+
const subCmd = args[1]?.toLowerCase();
|
|
216
|
+
|
|
217
|
+
if (!chatId.endsWith('@g.us')) {
|
|
218
|
+
await sock.sendMessage(chatId, {
|
|
219
|
+
text: `┌─ *${botName}* ─┐\n│\n│ Group command only!\n│\n└─────────────┘`
|
|
220
|
+
}, { quoted: fake });
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const adminStatus = await isAdmin(sock, chatId, senderId);
|
|
225
|
+
const isSenderAdmin = adminStatus.isSenderAdmin;
|
|
226
|
+
const isBotAdmin = adminStatus.isBotAdmin;
|
|
227
|
+
|
|
228
|
+
if (!isBotAdmin) {
|
|
229
|
+
await sock.sendMessage(chatId, {
|
|
230
|
+
text: `┌─ *${botName}* ─┐\n│\n│ Bot needs to be admin!\n│\n└─────────────┘`
|
|
231
|
+
}, { quoted: fake });
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (!isSenderAdmin && !message.key.fromMe && !db.isSudo(senderId)) {
|
|
236
|
+
await sock.sendMessage(chatId, {
|
|
237
|
+
text: `┌─ *${botName}* ─┐\n│\n│ Admin only command!\n│\n└─────────────┘`
|
|
238
|
+
}, { quoted: fake });
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const config = getGroupConfig(chatId, 'antidemote') || { enabled: false, mode: 'revert' };
|
|
243
|
+
|
|
244
|
+
if (!subCmd || subCmd === 'help') {
|
|
245
|
+
await sock.sendMessage(chatId, {
|
|
246
|
+
text: `┌─ *${botName}* ─┐
|
|
247
|
+
│
|
|
248
|
+
│ Status: ${config.enabled ? 'ON' : 'OFF'}
|
|
249
|
+
│ Mode: ${(config.mode || 'revert').toUpperCase()}
|
|
250
|
+
│
|
|
251
|
+
│ Commands:
|
|
252
|
+
│ ${prefix}antidemote on
|
|
253
|
+
│ ${prefix}antidemote off
|
|
254
|
+
│ ${prefix}antidemote revert
|
|
255
|
+
│ ${prefix}antidemote warn
|
|
256
|
+
│ ${prefix}antidemote kick
|
|
257
|
+
│ ${prefix}antidemote setwarn <num>
|
|
258
|
+
│ ${prefix}antidemote status
|
|
259
|
+
│
|
|
260
|
+
│ Modes:
|
|
261
|
+
│ REVERT - Undo demotion
|
|
262
|
+
│ WARN - Revert + warn
|
|
263
|
+
│ KICK - Revert + kick
|
|
264
|
+
│
|
|
265
|
+
└─────────────┘`
|
|
266
|
+
}, { quoted: fake });
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (subCmd === 'status') {
|
|
271
|
+
await sock.sendMessage(chatId, {
|
|
272
|
+
text: `┌─ *${botName}* ─┐
|
|
273
|
+
│
|
|
274
|
+
│ Antidemote: ${config.enabled ? 'ACTIVE' : 'INACTIVE'}
|
|
275
|
+
│ Mode: ${(config.mode || 'revert').toUpperCase()}
|
|
276
|
+
│
|
|
277
|
+
└─────────────┘`
|
|
278
|
+
}, { quoted: fake });
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (subCmd === 'setwarn') {
|
|
283
|
+
const num = parseInt(args[2]);
|
|
284
|
+
if (num > 0 && num <= 10) {
|
|
285
|
+
setGroupConfig(chatId, 'antidemote', { ...config, maxWarnings: num });
|
|
286
|
+
await sock.sendMessage(chatId, {
|
|
287
|
+
text: `┌─ *${botName}* ─┐
|
|
288
|
+
│
|
|
289
|
+
│ Max warnings set to: ${num}
|
|
290
|
+
│
|
|
291
|
+
└─────────────┘`
|
|
292
|
+
}, { quoted: fake });
|
|
293
|
+
} else {
|
|
294
|
+
await sock.sendMessage(chatId, {
|
|
295
|
+
text: `┌─ *${botName}* ─┐
|
|
296
|
+
│
|
|
297
|
+
│ Invalid number! Use 1-10
|
|
298
|
+
│
|
|
299
|
+
└─────────────┘`
|
|
300
|
+
}, { quoted: fake });
|
|
301
|
+
}
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (subCmd === 'on') {
|
|
306
|
+
setGroupConfig(chatId, 'antidemote', { ...config, enabled: true });
|
|
307
|
+
await sock.sendMessage(chatId, {
|
|
308
|
+
text: `┌─ *${botName}* ─┐
|
|
309
|
+
│
|
|
310
|
+
│ Antidemote ENABLED
|
|
311
|
+
│ Mode: ${(config.mode || 'revert').toUpperCase()}
|
|
312
|
+
│
|
|
313
|
+
└─────────────┘`
|
|
314
|
+
}, { quoted: fake });
|
|
315
|
+
} else if (subCmd === 'off') {
|
|
316
|
+
setGroupConfig(chatId, 'antidemote', { ...config, enabled: false });
|
|
317
|
+
await sock.sendMessage(chatId, {
|
|
318
|
+
text: `┌─ *${botName}* ─┐
|
|
319
|
+
│
|
|
320
|
+
│ Antidemote DISABLED
|
|
321
|
+
│
|
|
322
|
+
└─────────────┘`
|
|
323
|
+
}, { quoted: fake });
|
|
324
|
+
} else if (['revert', 'kick', 'warn'].includes(subCmd)) {
|
|
325
|
+
setGroupConfig(chatId, 'antidemote', { ...config, enabled: true, mode: subCmd });
|
|
326
|
+
await sock.sendMessage(chatId, {
|
|
327
|
+
text: `┌─ *${botName}* ─┐
|
|
328
|
+
│
|
|
329
|
+
│ Mode set to: ${subCmd.toUpperCase()}
|
|
330
|
+
│ Antidemote ENABLED
|
|
331
|
+
│
|
|
332
|
+
└─────────────┘`
|
|
333
|
+
}, { quoted: fake });
|
|
334
|
+
} else {
|
|
335
|
+
await sock.sendMessage(chatId, {
|
|
336
|
+
text: `┌─ *${botName}* ─┐
|
|
337
|
+
│
|
|
338
|
+
│ Invalid option!
|
|
339
|
+
│ Use: on, off, revert, kick, warn, status
|
|
340
|
+
│
|
|
341
|
+
└─────────────┘`
|
|
342
|
+
}, { quoted: fake });
|
|
343
|
+
}
|
|
344
|
+
} catch (error) {
|
|
345
|
+
console.error('Error in antidemoteCommand:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
module.exports = {
|
|
350
|
+
handleAntidemote,
|
|
351
|
+
antidemoteCommand
|
|
352
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const { getGroupConfig, setGroupConfig, deleteGroupToggle } = require('../../Database/settingsStore');
|
|
2
|
+
const isAdmin = require('../../davelib/isAdmin');
|
|
3
|
+
const db = require('../../Database/database');
|
|
4
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
5
|
+
|
|
6
|
+
async function antidocumentCommand(sock, chatId, userMessage, senderId, isSenderAdmin, message) {
|
|
7
|
+
try {
|
|
8
|
+
const fake = createFakeContact(senderId);
|
|
9
|
+
const botName = getBotName();
|
|
10
|
+
|
|
11
|
+
if (!isSenderAdmin && !message?.key?.fromMe && !db.isSudo(senderId)) {
|
|
12
|
+
await sock.sendMessage(chatId, { text: `*${botName}*\nAdmin only command!` }, { quoted: fake });
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const args = userMessage.slice(13).toLowerCase().trim().split(' ');
|
|
17
|
+
const action = args[0];
|
|
18
|
+
|
|
19
|
+
if (!action) {
|
|
20
|
+
const config = getGroupConfig(chatId, 'antidocument') || { enabled: false };
|
|
21
|
+
const currentMode = config.enabled ? (config.action || 'delete') : 'off';
|
|
22
|
+
|
|
23
|
+
const usage = `*${botName} ANTI-DOCUMENT*\n\nCurrent Mode: ${currentMode.toUpperCase()}\n\n*Commands:*\n.antidocument off - Disable\n.antidocument delete - Delete document\n.antidocument warn - Delete + warn\n.antidocument kick - Delete + kick`;
|
|
24
|
+
|
|
25
|
+
await sock.sendMessage(chatId, { text: usage }, { quoted: fake });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const validModes = ["off", "delete", "warn", "kick"];
|
|
30
|
+
|
|
31
|
+
if (!validModes.includes(action)) {
|
|
32
|
+
await sock.sendMessage(chatId, {
|
|
33
|
+
text: `*${botName}*\nInvalid mode! Use: off, delete, warn, kick`
|
|
34
|
+
}, { quoted: fake });
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (action === 'off') {
|
|
39
|
+
deleteGroupToggle(chatId, 'antidocument');
|
|
40
|
+
await sock.sendMessage(chatId, {
|
|
41
|
+
text: `*${botName}*\nAnti-Document DISABLED`
|
|
42
|
+
}, { quoted: fake });
|
|
43
|
+
} else {
|
|
44
|
+
setGroupConfig(chatId, 'antidocument', { enabled: true, action: action });
|
|
45
|
+
await sock.sendMessage(chatId, {
|
|
46
|
+
text: `*${botName}*\nAnti-Document: ${action.toUpperCase()}`
|
|
47
|
+
}, { quoted: fake });
|
|
48
|
+
}
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('Error in antidocument command:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function handleDocumentDetection(sock, chatId, message, senderId) {
|
|
55
|
+
try {
|
|
56
|
+
const isDocument = message.type === 'documentMessage' ||
|
|
57
|
+
(message.message && message.message.documentMessage);
|
|
58
|
+
|
|
59
|
+
if (!isDocument) return;
|
|
60
|
+
if (!chatId.endsWith('@g.us')) return;
|
|
61
|
+
|
|
62
|
+
const config = getGroupConfig(chatId, 'antidocument');
|
|
63
|
+
if (!config || !config.enabled) return;
|
|
64
|
+
|
|
65
|
+
const { isSenderAdmin, isBotAdmin } = await isAdmin(sock, chatId, senderId);
|
|
66
|
+
if (!isBotAdmin || isSenderAdmin || db.isSudo(senderId)) return;
|
|
67
|
+
|
|
68
|
+
const botName = getBotName();
|
|
69
|
+
const userTag = `@${senderId.split("@")[0]}`;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
await sock.sendMessage(chatId, {
|
|
73
|
+
delete: {
|
|
74
|
+
remoteJid: chatId,
|
|
75
|
+
fromMe: false,
|
|
76
|
+
id: message.key.id,
|
|
77
|
+
participant: senderId
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.error("[ANTI-DOCUMENT] Delete failed:", e.message);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (config.action === 'kick') {
|
|
86
|
+
await sock.sendMessage(chatId, {
|
|
87
|
+
text: `*${botName}*\n\n${userTag} kicked for sending document.`,
|
|
88
|
+
mentions: [senderId]
|
|
89
|
+
});
|
|
90
|
+
await sock.groupParticipantsUpdate(chatId, [senderId], 'remove');
|
|
91
|
+
} else if (config.action === 'warn') {
|
|
92
|
+
await sock.sendMessage(chatId, {
|
|
93
|
+
text: `*${botName}*\n\n${userTag}, documents are not allowed!`,
|
|
94
|
+
mentions: [senderId]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error('Error in handleDocumentDetection:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = {
|
|
103
|
+
antidocumentCommand,
|
|
104
|
+
handleDocumentDetection
|
|
105
|
+
};
|