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,143 @@
|
|
|
1
|
+
const { getGroupConfig, setGroupConfig, parseToggleCommand, parseActionCommand } = require('../../Database/settingsStore');
|
|
2
|
+
const db = require('../../Database/database');
|
|
3
|
+
const isAdmin = require('../../davelib/isAdmin');
|
|
4
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
5
|
+
|
|
6
|
+
async function antimentionCommand(sock, chatId, message, senderId) {
|
|
7
|
+
try {
|
|
8
|
+
const fake = createFakeContact(senderId);
|
|
9
|
+
const botName = getBotName();
|
|
10
|
+
|
|
11
|
+
const { isSenderAdmin } = await isAdmin(sock, chatId, senderId);
|
|
12
|
+
|
|
13
|
+
if (!isSenderAdmin && !message.key.fromMe && !db.isSudo(senderId)) {
|
|
14
|
+
await sock.sendMessage(chatId, { text: `*${botName}*\nAdmin only command!` }, { quoted: fake });
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const text = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
|
|
19
|
+
const args = text.trim().split(' ').slice(1);
|
|
20
|
+
const action = args[0]?.toLowerCase();
|
|
21
|
+
|
|
22
|
+
const config = getGroupConfig(chatId, 'antimention') || { enabled: false, action: 'delete', maxMentions: 5 };
|
|
23
|
+
|
|
24
|
+
if (!action) {
|
|
25
|
+
const helpText = `*${botName} ANTIMENTION*\n\n` +
|
|
26
|
+
`Status: ${config.enabled ? 'ON' : 'OFF'}\n` +
|
|
27
|
+
`Action: ${config.action || 'delete'}\n` +
|
|
28
|
+
`Max Mentions: ${config.maxMentions || 5}\n\n` +
|
|
29
|
+
`*Commands:*\n` +
|
|
30
|
+
`.antimention on - Enable\n` +
|
|
31
|
+
`.antimention off - Disable\n` +
|
|
32
|
+
`.antimention delete - Delete messages\n` +
|
|
33
|
+
`.antimention warn - Warn user\n` +
|
|
34
|
+
`.antimention kick - Kick user\n` +
|
|
35
|
+
`.antimention max <num> - Set max mentions`;
|
|
36
|
+
await sock.sendMessage(chatId, { text: helpText }, { quoted: fake });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let newConfig = { ...config };
|
|
41
|
+
let responseText = '';
|
|
42
|
+
|
|
43
|
+
const toggle = parseToggleCommand(action);
|
|
44
|
+
if (toggle === 'on') {
|
|
45
|
+
newConfig.enabled = true;
|
|
46
|
+
responseText = `*${botName}*\nAntimention ENABLED`;
|
|
47
|
+
} else if (toggle === 'off') {
|
|
48
|
+
newConfig.enabled = false;
|
|
49
|
+
responseText = `*${botName}*\nAntimention DISABLED`;
|
|
50
|
+
} else {
|
|
51
|
+
const parsedAction = parseActionCommand(action);
|
|
52
|
+
if (parsedAction === 'delete' || parsedAction === 'warn' || parsedAction === 'kick') {
|
|
53
|
+
newConfig.action = parsedAction;
|
|
54
|
+
newConfig.enabled = true;
|
|
55
|
+
responseText = `*${botName}*\nAntimention action: ${parsedAction.toUpperCase()}`;
|
|
56
|
+
} else if (action === 'max' && args[1]) {
|
|
57
|
+
const max = parseInt(args[1]);
|
|
58
|
+
if (max >= 1 && max <= 20) {
|
|
59
|
+
newConfig.maxMentions = max;
|
|
60
|
+
responseText = `*${botName}*\nMax mentions set to ${max}`;
|
|
61
|
+
} else {
|
|
62
|
+
responseText = `*${botName}*\nMax mentions must be 1-20`;
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
responseText = `*${botName}*\nInvalid command! Use: on, off, delete, warn, kick, max`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (responseText && !responseText.includes('Invalid') && !responseText.includes('must be')) {
|
|
70
|
+
setGroupConfig(chatId, 'antimention', newConfig);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('Error in antimention command:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function handleMentionDetection(sock, chatId, message, senderId) {
|
|
80
|
+
try {
|
|
81
|
+
if (!chatId.endsWith('@g.us')) return;
|
|
82
|
+
|
|
83
|
+
const config = getGroupConfig(chatId, 'antimention');
|
|
84
|
+
if (!config?.enabled) return;
|
|
85
|
+
|
|
86
|
+
const { isSenderAdmin, isBotAdmin } = await isAdmin(sock, chatId, senderId);
|
|
87
|
+
if (!isBotAdmin) return;
|
|
88
|
+
if (isSenderAdmin) return;
|
|
89
|
+
if (db.isSudo(senderId)) return;
|
|
90
|
+
|
|
91
|
+
const mentionedJids = message.message?.extendedTextMessage?.contextInfo?.mentionedJid || [];
|
|
92
|
+
const maxMentions = config.maxMentions || 5;
|
|
93
|
+
|
|
94
|
+
if (mentionedJids.length <= maxMentions) return;
|
|
95
|
+
|
|
96
|
+
const botName = getBotName();
|
|
97
|
+
const userTag = `@${senderId.split('@')[0]}`;
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
await sock.sendMessage(chatId, {
|
|
101
|
+
delete: {
|
|
102
|
+
remoteJid: chatId,
|
|
103
|
+
fromMe: false,
|
|
104
|
+
id: message.key.id,
|
|
105
|
+
participant: senderId
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
} catch (e) {
|
|
109
|
+
console.error('Antimention delete failed:', e.message, 'Line:', e.stack?.split('\n')[1]);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (config.action === 'kick') {
|
|
114
|
+
await sock.sendMessage(chatId, {
|
|
115
|
+
text: `*${botName}*\n${userTag} kicked for mass mentioning.`,
|
|
116
|
+
mentions: [senderId]
|
|
117
|
+
});
|
|
118
|
+
await sock.groupParticipantsUpdate(chatId, [senderId], 'remove');
|
|
119
|
+
} else if (config.action === 'warn') {
|
|
120
|
+
const warnings = db.incrementWarning(chatId, senderId);
|
|
121
|
+
await sock.sendMessage(chatId, {
|
|
122
|
+
text: `*${botName}*\n${userTag}, too many mentions!\nWarning ${warnings}/3`,
|
|
123
|
+
mentions: [senderId]
|
|
124
|
+
});
|
|
125
|
+
if (warnings >= 3) {
|
|
126
|
+
await sock.groupParticipantsUpdate(chatId, [senderId], 'remove');
|
|
127
|
+
db.resetWarning(chatId, senderId);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
await sock.sendMessage(chatId, {
|
|
131
|
+
text: `*${botName}*\n${userTag}, max ${maxMentions} mentions allowed!`,
|
|
132
|
+
mentions: [senderId]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.error('Error in antimention detection:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
module.exports = {
|
|
141
|
+
antimentionCommand,
|
|
142
|
+
handleMentionDetection
|
|
143
|
+
};
|
|
@@ -0,0 +1,320 @@
|
|
|
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 handleAntipromote(sock, groupId, participants, author) {
|
|
44
|
+
try {
|
|
45
|
+
const config = getGroupConfig(groupId, 'antipromote');
|
|
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('Antipromote: 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
|
+
const authorNum = author?.split('@')[0]?.split(':')[0];
|
|
72
|
+
const botNum = sock.user?.id?.split(':')[0]?.split('@')[0];
|
|
73
|
+
const botLidNum = sock.user?.lid?.split(':')[0]?.split('@')[0];
|
|
74
|
+
if (authorNum === botNum || (botLidNum && authorNum === botLidNum)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const botParticipant = groupMetadata.participants.find(p =>
|
|
79
|
+
normalizeJid(p.id) === botJid || p.id === botJid
|
|
80
|
+
);
|
|
81
|
+
const isBotAdmin = !botParticipant || (botParticipant.admin === 'admin' || botParticipant.admin === 'superadmin');
|
|
82
|
+
if (!isBotAdmin) {
|
|
83
|
+
await sock.sendMessage(groupId, {
|
|
84
|
+
text: `┌─ *${botName}* ─┐\n│\n│ Cannot reverse promotion - bot needs admin!\n│\n└─────────────┘`
|
|
85
|
+
}, { quoted: fake });
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const participantJids = participants.map(p => typeof p === 'string' ? p : (p.id || String(p)));
|
|
90
|
+
const mode = config.mode || 'revert';
|
|
91
|
+
|
|
92
|
+
const authorNumber = await resolveToPhone(sock, author);
|
|
93
|
+
const targetNumber = await resolveToPhone(sock, participantJids[0]);
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
await sock.groupParticipantsUpdate(groupId, participantJids, "demote");
|
|
97
|
+
console.log(`[ANTIPROMOTE] Reverted promotion of ${targetNumber} in ${groupId}`);
|
|
98
|
+
} catch (demoteErr) {
|
|
99
|
+
console.log('[ANTIPROMOTE] Demote call returned:', demoteErr.message, '(action may still have succeeded)');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (mode === 'kick') {
|
|
103
|
+
try {
|
|
104
|
+
await sock.groupParticipantsUpdate(groupId, [author], "remove");
|
|
105
|
+
} catch (e) {}
|
|
106
|
+
await sock.sendMessage(groupId, {
|
|
107
|
+
text: `┌─ *${botName}* ─┐
|
|
108
|
+
│
|
|
109
|
+
│ Promotion attempt blocked!
|
|
110
|
+
│ • Offender: @${authorNumber}
|
|
111
|
+
│ • Target: @${targetNumber}
|
|
112
|
+
│ • Action: Reverted + kicked
|
|
113
|
+
│
|
|
114
|
+
└─────────────┘`,
|
|
115
|
+
mentions: [author, ...participantJids]
|
|
116
|
+
}, { quoted: fake });
|
|
117
|
+
} else if (mode === 'warn') {
|
|
118
|
+
const maxWarnings = config.maxWarnings || 3;
|
|
119
|
+
const warningCount = db.incrementWarning(groupId, author);
|
|
120
|
+
if (warningCount >= maxWarnings) {
|
|
121
|
+
try {
|
|
122
|
+
await sock.groupParticipantsUpdate(groupId, [author], "remove");
|
|
123
|
+
} catch (e) {}
|
|
124
|
+
db.resetWarning(groupId, author);
|
|
125
|
+
await sock.sendMessage(groupId, {
|
|
126
|
+
text: `┌─ *${botName}* ─┐
|
|
127
|
+
│
|
|
128
|
+
│ Promotion attempt blocked!
|
|
129
|
+
│ • Offender: @${authorNumber}
|
|
130
|
+
│ • Target: @${targetNumber}
|
|
131
|
+
│ • Action: Reverted + kicked (${maxWarnings}/3 warnings)
|
|
132
|
+
│
|
|
133
|
+
└─────────────┘`,
|
|
134
|
+
mentions: [author, ...participantJids]
|
|
135
|
+
}, { quoted: fake });
|
|
136
|
+
} else {
|
|
137
|
+
await sock.sendMessage(groupId, {
|
|
138
|
+
text: `┌─ *${botName}* ─┐
|
|
139
|
+
│
|
|
140
|
+
│ Promotion attempt blocked!
|
|
141
|
+
│ • Offender: @${authorNumber}
|
|
142
|
+
│ • Target: @${targetNumber}
|
|
143
|
+
│ • Action: Reverted
|
|
144
|
+
│ • Warning: ${warningCount}/${maxWarnings}
|
|
145
|
+
│
|
|
146
|
+
└─────────────┘`,
|
|
147
|
+
mentions: [author, ...participantJids]
|
|
148
|
+
}, { quoted: fake });
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
try {
|
|
152
|
+
await sock.groupParticipantsUpdate(groupId, [author], "demote");
|
|
153
|
+
} catch (e) {}
|
|
154
|
+
await sock.sendMessage(groupId, {
|
|
155
|
+
text: `┌─ *${botName}* ─┐
|
|
156
|
+
│
|
|
157
|
+
│ Promotion attempt blocked!
|
|
158
|
+
│ • Offender: @${authorNumber}
|
|
159
|
+
│ • Target: @${targetNumber}
|
|
160
|
+
│ • Action: Reverted + demoted
|
|
161
|
+
│
|
|
162
|
+
└─────────────┘`,
|
|
163
|
+
mentions: [author, ...participantJids]
|
|
164
|
+
}, { quoted: fake });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return true;
|
|
168
|
+
} catch (error) {
|
|
169
|
+
console.error('Error in handleAntipromote:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function antipromoteCommand(sock, chatId, message, senderId) {
|
|
175
|
+
try {
|
|
176
|
+
const fake = createFakeContact(senderId);
|
|
177
|
+
const botName = getBotName();
|
|
178
|
+
const prefix = getPrefix();
|
|
179
|
+
|
|
180
|
+
const userMessage = message.message?.conversation ||
|
|
181
|
+
message.message?.extendedTextMessage?.text || '';
|
|
182
|
+
const args = userMessage.split(' ');
|
|
183
|
+
const subCmd = args[1]?.toLowerCase();
|
|
184
|
+
|
|
185
|
+
if (!chatId.endsWith('@g.us')) {
|
|
186
|
+
await sock.sendMessage(chatId, {
|
|
187
|
+
text: `┌─ *${botName}* ─┐\n│\n│ Group command only!\n│\n└─────────────┘`
|
|
188
|
+
}, { quoted: fake });
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const adminStatus = await isAdmin(sock, chatId, senderId);
|
|
193
|
+
const isSenderAdmin = adminStatus.isSenderAdmin;
|
|
194
|
+
const isBotAdmin = adminStatus.isBotAdmin;
|
|
195
|
+
|
|
196
|
+
if (!isBotAdmin) {
|
|
197
|
+
await sock.sendMessage(chatId, {
|
|
198
|
+
text: `┌─ *${botName}* ─┐\n│\n│ Bot needs to be admin!\n│\n└─────────────┘`
|
|
199
|
+
}, { quoted: fake });
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (!isSenderAdmin && !message.key.fromMe && !db.isSudo(senderId)) {
|
|
204
|
+
await sock.sendMessage(chatId, {
|
|
205
|
+
text: `┌─ *${botName}* ─┐\n│\n│ Admin only command!\n│\n└─────────────┘`
|
|
206
|
+
}, { quoted: fake });
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const config = getGroupConfig(chatId, 'antipromote') || { enabled: false, mode: 'revert' };
|
|
211
|
+
|
|
212
|
+
if (!subCmd || subCmd === 'help') {
|
|
213
|
+
await sock.sendMessage(chatId, {
|
|
214
|
+
text: `┌─ *${botName}* ─┐
|
|
215
|
+
│
|
|
216
|
+
│ Status: ${config.enabled ? 'ON' : 'OFF'}
|
|
217
|
+
│ Mode: ${(config.mode || 'revert').toUpperCase()}
|
|
218
|
+
│
|
|
219
|
+
│ Commands:
|
|
220
|
+
│ ${prefix}antipromote on
|
|
221
|
+
│ ${prefix}antipromote off
|
|
222
|
+
│ ${prefix}antipromote revert
|
|
223
|
+
│ ${prefix}antipromote warn
|
|
224
|
+
│ ${prefix}antipromote kick
|
|
225
|
+
│ ${prefix}antipromote setwarn <num>
|
|
226
|
+
│ ${prefix}antipromote status
|
|
227
|
+
│
|
|
228
|
+
│ Modes:
|
|
229
|
+
│ REVERT - Undo promotion
|
|
230
|
+
│ WARN - Revert + warn
|
|
231
|
+
│ KICK - Revert + kick
|
|
232
|
+
│
|
|
233
|
+
└─────────────┘`
|
|
234
|
+
}, { quoted: fake });
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (subCmd === 'status') {
|
|
239
|
+
await sock.sendMessage(chatId, {
|
|
240
|
+
text: `┌─ *${botName}* ─┐
|
|
241
|
+
│
|
|
242
|
+
│ Antipromote: ${config.enabled ? 'ACTIVE' : 'INACTIVE'}
|
|
243
|
+
│ Mode: ${(config.mode || 'revert').toUpperCase()}
|
|
244
|
+
│
|
|
245
|
+
└─────────────┘`
|
|
246
|
+
}, { quoted: fake });
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (subCmd === 'setwarn') {
|
|
251
|
+
const num = parseInt(args[2]);
|
|
252
|
+
if (num > 0 && num <= 10) {
|
|
253
|
+
setGroupConfig(chatId, 'antipromote', { ...config, maxWarnings: num });
|
|
254
|
+
await sock.sendMessage(chatId, {
|
|
255
|
+
text: `┌─ *${botName}* ─┐
|
|
256
|
+
│
|
|
257
|
+
│ Max warnings set to: ${num}
|
|
258
|
+
│
|
|
259
|
+
└─────────────┘`
|
|
260
|
+
}, { quoted: fake });
|
|
261
|
+
} else {
|
|
262
|
+
await sock.sendMessage(chatId, {
|
|
263
|
+
text: `┌─ *${botName}* ─┐
|
|
264
|
+
│
|
|
265
|
+
│ Invalid number! Use 1-10
|
|
266
|
+
│
|
|
267
|
+
└─────────────┘`
|
|
268
|
+
}, { quoted: fake });
|
|
269
|
+
}
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (subCmd === 'on') {
|
|
274
|
+
setGroupConfig(chatId, 'antipromote', { ...config, enabled: true });
|
|
275
|
+
await sock.sendMessage(chatId, {
|
|
276
|
+
text: `┌─ *${botName}* ─┐
|
|
277
|
+
│
|
|
278
|
+
│ Antipromote ENABLED
|
|
279
|
+
│ Mode: ${(config.mode || 'revert').toUpperCase()}
|
|
280
|
+
│
|
|
281
|
+
└─────────────┘`
|
|
282
|
+
}, { quoted: fake });
|
|
283
|
+
} else if (subCmd === 'off') {
|
|
284
|
+
setGroupConfig(chatId, 'antipromote', { ...config, enabled: false });
|
|
285
|
+
await sock.sendMessage(chatId, {
|
|
286
|
+
text: `┌─ *${botName}* ─┐
|
|
287
|
+
│
|
|
288
|
+
│ Antipromote DISABLED
|
|
289
|
+
│
|
|
290
|
+
└─────────────┘`
|
|
291
|
+
}, { quoted: fake });
|
|
292
|
+
} else if (['revert', 'kick', 'warn'].includes(subCmd)) {
|
|
293
|
+
setGroupConfig(chatId, 'antipromote', { ...config, enabled: true, mode: subCmd });
|
|
294
|
+
await sock.sendMessage(chatId, {
|
|
295
|
+
text: `┌─ *${botName}* ─┐
|
|
296
|
+
│
|
|
297
|
+
│ Mode set to: ${subCmd.toUpperCase()}
|
|
298
|
+
│ Antipromote ENABLED
|
|
299
|
+
│
|
|
300
|
+
└─────────────┘`
|
|
301
|
+
}, { quoted: fake });
|
|
302
|
+
} else {
|
|
303
|
+
await sock.sendMessage(chatId, {
|
|
304
|
+
text: `┌─ *${botName}* ─┐
|
|
305
|
+
│
|
|
306
|
+
│ Invalid option!
|
|
307
|
+
│ Use: on, off, revert, kick, warn, status
|
|
308
|
+
│
|
|
309
|
+
└─────────────┘`
|
|
310
|
+
}, { quoted: fake });
|
|
311
|
+
}
|
|
312
|
+
} catch (error) {
|
|
313
|
+
console.error('Error in antipromoteCommand:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
module.exports = {
|
|
318
|
+
handleAntipromote,
|
|
319
|
+
antipromoteCommand
|
|
320
|
+
};
|
|
@@ -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 antistickerCommand(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(12).toLowerCase().trim().split(' ');
|
|
17
|
+
const action = args[0];
|
|
18
|
+
|
|
19
|
+
if (!action) {
|
|
20
|
+
const config = getGroupConfig(chatId, 'antisticker') || { enabled: false };
|
|
21
|
+
const currentMode = config.enabled ? (config.action || 'delete') : 'off';
|
|
22
|
+
|
|
23
|
+
const usage = `*${botName} ANTI-STICKER*\n\nCurrent Mode: ${currentMode.toUpperCase()}\n\n*Commands:*\n.antisticker off - Disable\n.antisticker delete - Delete sticker\n.antisticker warn - Delete + warn\n.antisticker 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, 'antisticker');
|
|
40
|
+
await sock.sendMessage(chatId, {
|
|
41
|
+
text: `*${botName}*\nAnti-Sticker DISABLED`
|
|
42
|
+
}, { quoted: fake });
|
|
43
|
+
} else {
|
|
44
|
+
setGroupConfig(chatId, 'antisticker', { enabled: true, action: action });
|
|
45
|
+
await sock.sendMessage(chatId, {
|
|
46
|
+
text: `*${botName}*\nAnti-Sticker: ${action.toUpperCase()}`
|
|
47
|
+
}, { quoted: fake });
|
|
48
|
+
}
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('Error in antisticker command:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function handleStickerDetection(sock, chatId, message, senderId) {
|
|
55
|
+
try {
|
|
56
|
+
const isSticker = message.type === 'stickerMessage' ||
|
|
57
|
+
(message.message && message.message.stickerMessage);
|
|
58
|
+
|
|
59
|
+
if (!isSticker) return;
|
|
60
|
+
if (!chatId.endsWith('@g.us')) return;
|
|
61
|
+
|
|
62
|
+
const config = getGroupConfig(chatId, 'antisticker');
|
|
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-STICKER] 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 sticker.`,
|
|
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}, stickers are not allowed!`,
|
|
94
|
+
mentions: [senderId]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error('Error in handleStickerDetection:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = {
|
|
103
|
+
antistickerCommand,
|
|
104
|
+
handleStickerDetection
|
|
105
|
+
};
|