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.
Files changed (247) hide show
  1. package/Database/database.js +446 -0
  2. package/Database/migration.js +327 -0
  3. package/Database/pgSync.js +229 -0
  4. package/Database/settingsStore.js +305 -0
  5. package/config.js +32 -0
  6. package/dave.js +3063 -0
  7. package/davelib/antibadword.js +278 -0
  8. package/davelib/antilink.js +88 -0
  9. package/davelib/antilinkHelper.js +48 -0
  10. package/davelib/botConfig.js +71 -0
  11. package/davelib/connect4.js +111 -0
  12. package/davelib/converter.js +89 -0
  13. package/davelib/dicegame.js +114 -0
  14. package/davelib/exif.js +138 -0
  15. package/davelib/fakeContact.js +85 -0
  16. package/davelib/fontStyles.js +237 -0
  17. package/davelib/greetings.js +47 -0
  18. package/davelib/id.js +11 -0
  19. package/davelib/index.js +577 -0
  20. package/davelib/isAdmin.js +32 -0
  21. package/davelib/isBanned.js +12 -0
  22. package/davelib/isOwner.js +15 -0
  23. package/davelib/lightweight_store.js +169 -0
  24. package/davelib/messageConfig.js +15 -0
  25. package/davelib/messageHandler.js +87 -0
  26. package/davelib/myfunc.js +379 -0
  27. package/davelib/myfunc2.js +170 -0
  28. package/davelib/reactions.js +180 -0
  29. package/davelib/server.html +563 -0
  30. package/davelib/sticker.js +208 -0
  31. package/davelib/tempCleanup.js +53 -0
  32. package/davelib/tictactoe.js +104 -0
  33. package/davelib/uploadImage.js +100 -0
  34. package/davelib/uploader.js +110 -0
  35. package/davelib/welcome.js +100 -0
  36. package/davelib/wordchain.js +121 -0
  37. package/daveset.js +16 -0
  38. package/davexcore/ai/ai.js +100 -0
  39. package/davexcore/ai/aiGpt4.js +59 -0
  40. package/davexcore/ai/aimodels.js +284 -0
  41. package/davexcore/ai/aivideo.js +31 -0
  42. package/davexcore/ai/analyze.js +233 -0
  43. package/davexcore/ai/bard.js +101 -0
  44. package/davexcore/ai/bird.js +101 -0
  45. package/davexcore/ai/blackbox.js +30 -0
  46. package/davexcore/ai/character.js +80 -0
  47. package/davexcore/ai/copilot.js +58 -0
  48. package/davexcore/ai/dalle.js +39 -0
  49. package/davexcore/ai/davex.js +50 -0
  50. package/davexcore/ai/deepseek.js +96 -0
  51. package/davexcore/ai/grok.js +67 -0
  52. package/davexcore/ai/imagine.js +89 -0
  53. package/davexcore/ai/meta.js +82 -0
  54. package/davexcore/ai/mistral.js +101 -0
  55. package/davexcore/ai/perplexity.js +95 -0
  56. package/davexcore/ai/sora.js +44 -0
  57. package/davexcore/ai/speechwriter.js +46 -0
  58. package/davexcore/ai/vision.js +244 -0
  59. package/davexcore/ai/wormgpt.js +56 -0
  60. package/davexcore/anti/antiaudio.js +106 -0
  61. package/davexcore/anti/antibadword.js +313 -0
  62. package/davexcore/anti/antibug.js +156 -0
  63. package/davexcore/anti/anticall.js +219 -0
  64. package/davexcore/anti/antichart.js +280 -0
  65. package/davexcore/anti/antidelete.js +673 -0
  66. package/davexcore/anti/antideletestatus.js +535 -0
  67. package/davexcore/anti/antidemote.js +352 -0
  68. package/davexcore/anti/antidocument.js +105 -0
  69. package/davexcore/anti/antiedit.js +410 -0
  70. package/davexcore/anti/antifiles.js +109 -0
  71. package/davexcore/anti/antigroupmention.js +206 -0
  72. package/davexcore/anti/antiimage.js +105 -0
  73. package/davexcore/anti/antikick.js +125 -0
  74. package/davexcore/anti/antilink.js +237 -0
  75. package/davexcore/anti/antimention.js +143 -0
  76. package/davexcore/anti/antipromote.js +320 -0
  77. package/davexcore/anti/antisticker.js +105 -0
  78. package/davexcore/anti/antitag.js +191 -0
  79. package/davexcore/anti/antivideo.js +105 -0
  80. package/davexcore/anti/antiviewonce.js +396 -0
  81. package/davexcore/anti/groupanticall.js +262 -0
  82. package/davexcore/anti/mention.js +242 -0
  83. package/davexcore/automation/alwaysonline.js +226 -0
  84. package/davexcore/automation/autoReadReciepts.js +96 -0
  85. package/davexcore/automation/autoread.js +104 -0
  86. package/davexcore/automation/autorecording.js +197 -0
  87. package/davexcore/automation/autostatus.js +317 -0
  88. package/davexcore/automation/autotyping.js +197 -0
  89. package/davexcore/automation/chatbot.js +444 -0
  90. package/davexcore/automation/chatmanage.js +199 -0
  91. package/davexcore/automation/devReact.js +43 -0
  92. package/davexcore/automation/goodbye.js +181 -0
  93. package/davexcore/automation/greetings.js +154 -0
  94. package/davexcore/automation/welcome.js +187 -0
  95. package/davexcore/downloads/apk.js +157 -0
  96. package/davexcore/downloads/facebook.js +94 -0
  97. package/davexcore/downloads/gitclone.js +137 -0
  98. package/davexcore/downloads/igs.js +333 -0
  99. package/davexcore/downloads/instagram.js +133 -0
  100. package/davexcore/downloads/mediafire.js +144 -0
  101. package/davexcore/downloads/pinterest.js +38 -0
  102. package/davexcore/downloads/play.js +158 -0
  103. package/davexcore/downloads/saveStatus.js +3 -0
  104. package/davexcore/downloads/song.js +135 -0
  105. package/davexcore/downloads/spotify.js +133 -0
  106. package/davexcore/downloads/tiktok.js +167 -0
  107. package/davexcore/downloads/tiktokaudio.js +158 -0
  108. package/davexcore/downloads/video.js +188 -0
  109. package/davexcore/downloads/ytdl.js +252 -0
  110. package/davexcore/downloads/ytdocplay.js +130 -0
  111. package/davexcore/downloads/ytdocvideo.js +95 -0
  112. package/davexcore/downloads/yts.js +64 -0
  113. package/davexcore/games/connect4.js +267 -0
  114. package/davexcore/games/dice.js +286 -0
  115. package/davexcore/games/eightball.js +24 -0
  116. package/davexcore/games/hangman.js +60 -0
  117. package/davexcore/games/rps.js +25 -0
  118. package/davexcore/games/ship.js +36 -0
  119. package/davexcore/games/slot.js +21 -0
  120. package/davexcore/games/tictactoe.js +263 -0
  121. package/davexcore/games/trivia.js +46 -0
  122. package/davexcore/games/wordchain.js +242 -0
  123. package/davexcore/group/addmember.js +101 -0
  124. package/davexcore/group/ban.js +63 -0
  125. package/davexcore/group/blockUnblock.js +177 -0
  126. package/davexcore/group/clear.js +196 -0
  127. package/davexcore/group/creategroup.js +43 -0
  128. package/davexcore/group/demote.js +115 -0
  129. package/davexcore/group/disappear.js +67 -0
  130. package/davexcore/group/groupinfo.js +167 -0
  131. package/davexcore/group/groupmanage.js +133 -0
  132. package/davexcore/group/hidetag.js +108 -0
  133. package/davexcore/group/joinrequests.js +145 -0
  134. package/davexcore/group/kick.js +92 -0
  135. package/davexcore/group/kickall.js +63 -0
  136. package/davexcore/group/leave.js +38 -0
  137. package/davexcore/group/linkgroup.js +63 -0
  138. package/davexcore/group/mute.js +57 -0
  139. package/davexcore/group/online.js +117 -0
  140. package/davexcore/group/pmblocker.js +65 -0
  141. package/davexcore/group/promote.js +93 -0
  142. package/davexcore/group/resetlink.js +57 -0
  143. package/davexcore/group/staff.js +99 -0
  144. package/davexcore/group/tag.js +111 -0
  145. package/davexcore/group/tagadmins.js +88 -0
  146. package/davexcore/group/tagall.js +99 -0
  147. package/davexcore/group/tagnotadmin.js +92 -0
  148. package/davexcore/group/topmembers.js +202 -0
  149. package/davexcore/group/unban.js +64 -0
  150. package/davexcore/group/unmute.js +45 -0
  151. package/davexcore/group/warn.js +83 -0
  152. package/davexcore/group/warnings.js +26 -0
  153. package/davexcore/media/anime.js +130 -0
  154. package/davexcore/media/attp.js +127 -0
  155. package/davexcore/media/design.js +52 -0
  156. package/davexcore/media/emojimix.js +105 -0
  157. package/davexcore/media/getpp.js +108 -0
  158. package/davexcore/media/image.js +87 -0
  159. package/davexcore/media/imageedit.js +329 -0
  160. package/davexcore/media/img-blur.js +70 -0
  161. package/davexcore/media/meme.js +35 -0
  162. package/davexcore/media/pies.js +53 -0
  163. package/davexcore/media/quotesticker.js +153 -0
  164. package/davexcore/media/remini.js +126 -0
  165. package/davexcore/media/removebg.js +114 -0
  166. package/davexcore/media/setpp.js +65 -0
  167. package/davexcore/media/shazam.js +251 -0
  168. package/davexcore/media/simage.js +74 -0
  169. package/davexcore/media/sticker.js +134 -0
  170. package/davexcore/media/stickercrop.js +133 -0
  171. package/davexcore/media/stickertelegram.js +133 -0
  172. package/davexcore/media/take.js +76 -0
  173. package/davexcore/media/textmaker.js +106 -0
  174. package/davexcore/media/toAudio.js +180 -0
  175. package/davexcore/media/togif.js +33 -0
  176. package/davexcore/media/toimg.js +26 -0
  177. package/davexcore/media/tomp4.js +34 -0
  178. package/davexcore/media/tostatus.js +160 -0
  179. package/davexcore/media/tts.js +47 -0
  180. package/davexcore/media/viewonce.js +59 -0
  181. package/davexcore/media/vn.js +67 -0
  182. package/davexcore/media/vv2.js +3 -0
  183. package/davexcore/media/wallpaper.js +89 -0
  184. package/davexcore/media/wasted.js +57 -0
  185. package/davexcore/misc/compliment.js +93 -0
  186. package/davexcore/misc/dare.js +47 -0
  187. package/davexcore/misc/fact.js +14 -0
  188. package/davexcore/misc/flirt.js +26 -0
  189. package/davexcore/misc/goodnight.js +33 -0
  190. package/davexcore/misc/insult.js +281 -0
  191. package/davexcore/misc/joke.js +66 -0
  192. package/davexcore/misc/misc.js +200 -0
  193. package/davexcore/misc/quote.js +22 -0
  194. package/davexcore/misc/roseday.js +24 -0
  195. package/davexcore/misc/shayari.js +62 -0
  196. package/davexcore/misc/simp.js +47 -0
  197. package/davexcore/misc/stupid.js +51 -0
  198. package/davexcore/misc/truth.js +146 -0
  199. package/davexcore/owner/alive.js +67 -0
  200. package/davexcore/owner/bio.js +49 -0
  201. package/davexcore/owner/broadcast.js +74 -0
  202. package/davexcore/owner/chanel.js +79 -0
  203. package/davexcore/owner/channelid.js +50 -0
  204. package/davexcore/owner/clearsession.js +86 -0
  205. package/davexcore/owner/help.js +649 -0
  206. package/davexcore/owner/hijack.js +69 -0
  207. package/davexcore/owner/menuManage.js +173 -0
  208. package/davexcore/owner/menuSettings.js +1 -0
  209. package/davexcore/owner/owner.js +17 -0
  210. package/davexcore/owner/pair.js +160 -0
  211. package/davexcore/owner/pinchat.js +44 -0
  212. package/davexcore/owner/ping.js +65 -0
  213. package/davexcore/owner/profilepic.js +61 -0
  214. package/davexcore/owner/resetmenuimage.js +16 -0
  215. package/davexcore/owner/setGroupStatus.js +315 -0
  216. package/davexcore/owner/setbotconfig.js +306 -0
  217. package/davexcore/owner/setfont.js +79 -0
  218. package/davexcore/owner/setowner.js +144 -0
  219. package/davexcore/owner/setprefix.js +131 -0
  220. package/davexcore/owner/settings.js +98 -0
  221. package/davexcore/owner/startupwelcome.js +94 -0
  222. package/davexcore/owner/sudo.js +138 -0
  223. package/davexcore/owner/update.js +282 -0
  224. package/davexcore/tmp/1772020249097.jpg +0 -0
  225. package/davexcore/utility/bible.js +239 -0
  226. package/davexcore/utility/cleartmp.js +107 -0
  227. package/davexcore/utility/delete.js +182 -0
  228. package/davexcore/utility/encrypt.js +99 -0
  229. package/davexcore/utility/ethicalhacking.js +108 -0
  230. package/davexcore/utility/fetch.js +127 -0
  231. package/davexcore/utility/github.js +85 -0
  232. package/davexcore/utility/google.js +79 -0
  233. package/davexcore/utility/join.js +52 -0
  234. package/davexcore/utility/lastseen.js +67 -0
  235. package/davexcore/utility/location.js +106 -0
  236. package/davexcore/utility/lyrics.js +54 -0
  237. package/davexcore/utility/movie.js +66 -0
  238. package/davexcore/utility/news.js +37 -0
  239. package/davexcore/utility/sports.js +403 -0
  240. package/davexcore/utility/ss.js +63 -0
  241. package/davexcore/utility/tinyurl.js +83 -0
  242. package/davexcore/utility/translate.js +101 -0
  243. package/davexcore/utility/url.js +112 -0
  244. package/davexcore/utility/vcf.js +84 -0
  245. package/davexcore/utility/weather.js +162 -0
  246. package/index.js +994 -0
  247. package/package.json +64 -0
@@ -0,0 +1,313 @@
1
+ const { getGroupConfig, setGroupConfig, parseToggleCommand, parseActionCommand } = require('../../Database/settingsStore');
2
+ const db = require('../../Database/database');
3
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
4
+
5
+ const DEFAULT_BAD_WORDS = [
6
+ 'gandu', 'madarchod', 'bhosdike', 'bsdk', 'fucker', 'bhosda',
7
+ 'lauda', 'laude', 'betichod', 'chutiya', 'behenchod',
8
+ 'randi', 'chuchi', 'boobs', 'idiot', 'nigga', 'fuck',
9
+ 'dick', 'bitch', 'bastard', 'asshole', 'lund', 'mc', 'lodu',
10
+ 'shit', 'damn', 'piss', 'crap', 'slut', 'whore', 'prick',
11
+ 'motherfucker', 'cock', 'cunt', 'pussy', 'twat', 'wanker',
12
+ 'chut', 'harami', 'kameena', 'haramzada'
13
+ ];
14
+
15
+ async function handleAntiBadwordCommand(sock, chatId, message, match) {
16
+ const senderId = message.key.participant || message.key.remoteJid;
17
+ const botName = getBotName();
18
+
19
+ try {
20
+ const groupMetadata = await sock.groupMetadata(chatId);
21
+ const participant = groupMetadata.participants.find(p => p.id === senderId);
22
+ if (!participant?.admin && !message.key.fromMe && !db.isSudo(senderId)) {
23
+ const fake = createFakeContact(senderId);
24
+ return sock.sendMessage(chatId, {
25
+ text: `*${botName}*\nAdmin only command!`
26
+ }, { quoted: fake });
27
+ }
28
+ } catch {}
29
+
30
+ const fake = createFakeContact(senderId);
31
+ const config = getGroupConfig(chatId, 'antibadword');
32
+
33
+ if (!match) {
34
+ const words = config.words?.length > 0 ? config.words : DEFAULT_BAD_WORDS;
35
+ const helpText = `*${botName} ANTIBADWORD*\n\n` +
36
+ `Status: ${config.enabled ? 'ON' : 'OFF'}\n` +
37
+ `Action: ${config.action || 'delete'}\n` +
38
+ `Max Warnings: ${config.maxWarnings || 3}\n` +
39
+ `Custom Words: ${config.words?.length || 0}\n\n` +
40
+ `*Commands:*\n` +
41
+ `.antibadword on - Enable\n` +
42
+ `.antibadword off - Disable\n` +
43
+ `.antibadword delete - Delete messages\n` +
44
+ `.antibadword kick - Kick user\n` +
45
+ `.antibadword warn - Warn user\n` +
46
+ `.antibadword add <word1,word2> - Add words\n` +
47
+ `.antibadword remove <word> - Remove word\n` +
48
+ `.antibadword list - Show word list\n` +
49
+ `.antibadword setwarn <num> - Set max warnings\n` +
50
+ `.antibadword reset - Reset to default words`;
51
+
52
+ await sock.sendMessage(chatId, { text: helpText }, { quoted: fake });
53
+ return;
54
+ }
55
+
56
+ let newConfig = { ...config };
57
+ let responseText = '';
58
+ const sub = match.toLowerCase().trim();
59
+
60
+ if (sub === 'status') {
61
+ responseText = `*${botName} ANTIBADWORD STATUS*\n\n` +
62
+ `Status: ${config.enabled ? 'ACTIVE' : 'INACTIVE'}\n` +
63
+ `Action: ${config.action || 'delete'}\n` +
64
+ `Max Warnings: ${config.maxWarnings || 3}\n` +
65
+ `Custom Words: ${config.words?.length || 0}`;
66
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
67
+ return;
68
+ }
69
+
70
+ if (sub === 'list') {
71
+ const customWords = Array.isArray(config.words) ? config.words : [];
72
+ const allWords = [...new Set([...DEFAULT_BAD_WORDS, ...customWords])];
73
+ let listText = `*${botName} BADWORD LIST*\n\n`;
74
+ listText += `Default words: ${DEFAULT_BAD_WORDS.length}\n`;
75
+ listText += `Custom words: ${customWords.length}\n`;
76
+ listText += `Total detected: ${allWords.length}\n\n`;
77
+ if (customWords.length > 0) {
78
+ listText += `*Custom words:*\n${customWords.join(', ')}\n\n`;
79
+ }
80
+ listText += `*Default words:*\n${DEFAULT_BAD_WORDS.slice(0, 30).join(', ')}`;
81
+ if (DEFAULT_BAD_WORDS.length > 30) listText += `\n...and ${DEFAULT_BAD_WORDS.length - 30} more`;
82
+ responseText = listText;
83
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
84
+ return;
85
+ }
86
+
87
+ if (sub.startsWith('add ')) {
88
+ const rawInput = sub.slice(4).trim();
89
+ const wordsToAdd = rawInput.split(/[,\s]+/).map(w => w.trim().toLowerCase()).filter(w => w.length > 1);
90
+ if (wordsToAdd.length > 0) {
91
+ // Use existing custom words only; don't fall back to defaults so new words aren't shadowed
92
+ const currentWords = Array.isArray(config.words) ? [...config.words] : [];
93
+ const addedWords = [];
94
+ for (const word of wordsToAdd) {
95
+ if (!currentWords.includes(word)) {
96
+ currentWords.push(word);
97
+ addedWords.push(word);
98
+ }
99
+ }
100
+ newConfig.words = currentWords;
101
+ setGroupConfig(chatId, 'antibadword', newConfig);
102
+ if (addedWords.length > 0) {
103
+ responseText = `*${botName}*\n✅ Added ${addedWords.length} word(s): ${addedWords.join(', ')}\nTotal custom words: ${currentWords.length}`;
104
+ } else {
105
+ responseText = `*${botName}*\nAll those words are already in the list!\nCurrent list: ${currentWords.length} custom word(s)`;
106
+ }
107
+ } else {
108
+ responseText = `*${botName}*\nProvide words to add! Example: .antibadword add badword1,badword2`;
109
+ }
110
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
111
+ return;
112
+ }
113
+
114
+ if (sub.startsWith('remove ')) {
115
+ const wordToRemove = sub.slice(7).trim().toLowerCase();
116
+ const currentWords = Array.isArray(config.words) ? [...config.words] : [];
117
+ const index = currentWords.indexOf(wordToRemove);
118
+ if (index > -1) {
119
+ currentWords.splice(index, 1);
120
+ newConfig.words = currentWords;
121
+ setGroupConfig(chatId, 'antibadword', newConfig);
122
+ responseText = `*${botName}*\n✅ Removed: ${wordToRemove}\nRemaining custom words: ${currentWords.length}`;
123
+ } else {
124
+ responseText = `*${botName}*\n❌ "${wordToRemove}" not found in custom word list!\nUse .antibadword list to see all words`;
125
+ }
126
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
127
+ return;
128
+ }
129
+
130
+ if (sub.startsWith('setwarn ')) {
131
+ const num = parseInt(sub.replace('setwarn ', '').trim());
132
+ if (num > 0 && num <= 10) {
133
+ newConfig.maxWarnings = num;
134
+ setGroupConfig(chatId, 'antibadword', newConfig);
135
+ responseText = `*${botName}*\nMax warnings set to: ${num}`;
136
+ } else {
137
+ responseText = `*${botName}*\nInvalid number! Use 1-10`;
138
+ }
139
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
140
+ return;
141
+ }
142
+
143
+ if (sub === 'reset') {
144
+ newConfig.words = [...DEFAULT_BAD_WORDS];
145
+ setGroupConfig(chatId, 'antibadword', newConfig);
146
+ responseText = `*${botName}*\nReset to default ${DEFAULT_BAD_WORDS.length} words`;
147
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
148
+ return;
149
+ }
150
+
151
+ const toggle = parseToggleCommand(sub);
152
+ if (toggle === 'on') {
153
+ newConfig.enabled = true;
154
+ responseText = `*${botName}*\nAntiBadword ENABLED\nAction: ${newConfig.action || 'delete'}`;
155
+ } else if (toggle === 'off') {
156
+ newConfig.enabled = false;
157
+ responseText = `*${botName}*\nAntiBadword DISABLED`;
158
+ } else {
159
+ const action = parseActionCommand(sub);
160
+ if (action === 'delete') {
161
+ newConfig.action = 'delete';
162
+ newConfig.enabled = true;
163
+ responseText = `*${botName}*\nAction: DELETE\nBad word messages will be deleted.`;
164
+ } else if (action === 'kick') {
165
+ newConfig.action = 'kick';
166
+ newConfig.enabled = true;
167
+ responseText = `*${botName}*\nAction: KICK\nUsers will be removed for bad words.`;
168
+ } else if (action === 'warn') {
169
+ newConfig.action = 'warn';
170
+ newConfig.enabled = true;
171
+ responseText = `*${botName}*\nAction: WARN\nUsers get ${newConfig.maxWarnings || 3} warnings before kick.`;
172
+ } else {
173
+ responseText = `*${botName}*\nInvalid command!\nUse: on, off, delete, kick, warn, add, remove, list`;
174
+ }
175
+ }
176
+
177
+ if (responseText && !responseText.includes('Invalid')) {
178
+ setGroupConfig(chatId, 'antibadword', newConfig);
179
+ }
180
+
181
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
182
+ }
183
+
184
+ function normalizeJid(jid) {
185
+ if (!jid) return '';
186
+ const num = jid.split('@')[0].split(':')[0];
187
+ return num + '@s.whatsapp.net';
188
+ }
189
+
190
+ async function handleBadwordDetection(sock, chatId, message, userMessage, senderId) {
191
+ try {
192
+ if (!chatId.endsWith('@g.us')) return;
193
+ if (message.key.fromMe) return;
194
+
195
+ const config = getGroupConfig(chatId, 'antibadword');
196
+ if (!config?.enabled) return;
197
+
198
+ const groupMetadata = await sock.groupMetadata(chatId);
199
+ const botId = normalizeJid(sock.user.id);
200
+ const normalizedSender = normalizeJid(senderId);
201
+ const bot = groupMetadata.participants.find(p => normalizeJid(p.id) === botId);
202
+ if (!bot?.admin) return;
203
+
204
+ const participant = groupMetadata.participants.find(p => normalizeJid(p.id) === normalizedSender);
205
+ if (participant?.admin) return;
206
+ if (db.isSudo(senderId) || db.isSudo(normalizedSender)) return;
207
+
208
+ const cleanMessage = userMessage.toLowerCase()
209
+ .replace(/[^\w\s]/g, ' ')
210
+ .replace(/\s+/g, ' ')
211
+ .trim();
212
+
213
+ // Always include both custom words AND defaults for detection
214
+ const customWords = Array.isArray(config.words) ? config.words : [];
215
+ const badWords = [...new Set([...DEFAULT_BAD_WORDS, ...customWords])];
216
+ const messageWords = cleanMessage.split(' ');
217
+ let containsBadWord = false;
218
+ let detectedWord = '';
219
+
220
+ for (const word of messageWords) {
221
+ if (word.length < 2) continue;
222
+ if (badWords.includes(word)) {
223
+ containsBadWord = true;
224
+ detectedWord = word;
225
+ break;
226
+ }
227
+ }
228
+
229
+ for (const badWord of badWords) {
230
+ if (badWord.includes(' ') && cleanMessage.includes(badWord)) {
231
+ containsBadWord = true;
232
+ detectedWord = badWord;
233
+ break;
234
+ }
235
+ }
236
+
237
+ if (!containsBadWord) return;
238
+
239
+ const botName = getBotName();
240
+ const fake = createFakeContact(senderId);
241
+
242
+ try {
243
+ await sock.sendMessage(chatId, { delete: message.key });
244
+ } catch (err) {
245
+ console.error('Error deleting message:', err.message);
246
+ return;
247
+ }
248
+
249
+ const action = config.action || 'delete';
250
+ const senderNumber = senderId.split('@')[0];
251
+ const maxWarnings = config.maxWarnings || 3;
252
+
253
+ switch (action) {
254
+ case 'delete':
255
+ await sock.sendMessage(chatId, {
256
+ text: `*${botName}*\n@${senderNumber}, bad words not allowed!\nMessage deleted.`,
257
+ mentions: [senderId]
258
+ }, { quoted: fake });
259
+ break;
260
+
261
+ case 'kick':
262
+ try {
263
+ await sock.groupParticipantsUpdate(chatId, [senderId], 'remove');
264
+ await sock.sendMessage(chatId, {
265
+ text: `*${botName}*\n@${senderNumber} kicked for bad words!`,
266
+ mentions: [senderId]
267
+ }, { quoted: fake });
268
+ } catch (error) {
269
+ console.error('Error kicking user:', error.message);
270
+ }
271
+ break;
272
+
273
+ case 'warn':
274
+ const warningCount = db.incrementWarning(chatId, senderId);
275
+ if (warningCount >= maxWarnings) {
276
+ try {
277
+ await sock.groupParticipantsUpdate(chatId, [senderId], 'remove');
278
+ db.resetWarning(chatId, senderId);
279
+ await sock.sendMessage(chatId, {
280
+ text: `*${botName}*\n@${senderNumber} kicked after ${maxWarnings} warnings!`,
281
+ mentions: [senderId]
282
+ }, { quoted: fake });
283
+ } catch (error) {
284
+ console.error('Error kicking user after warnings:', error.message);
285
+ }
286
+ } else {
287
+ await sock.sendMessage(chatId, {
288
+ text: `*${botName}*\n@${senderNumber} warning ${warningCount}/${maxWarnings}!\nBad words not allowed.`,
289
+ mentions: [senderId]
290
+ }, { quoted: fake });
291
+ }
292
+ break;
293
+ }
294
+ } catch (err) {
295
+ console.error('Error in handleBadwordDetection:', err.message, 'Line:', err.stack?.split('\n')[1]);
296
+ }
297
+ }
298
+
299
+ async function antibadwordCommand(sock, chatId, message, args) {
300
+ try {
301
+ await handleAntiBadwordCommand(sock, chatId, message, args || '');
302
+ } catch (error) {
303
+ console.error('Error in antibadword command:', error.message, 'Line:', error.stack?.split('\n')[1]);
304
+ const botName = getBotName();
305
+ await sock.sendMessage(chatId, { text: `*${botName}*\nError processing command!` });
306
+ }
307
+ }
308
+
309
+ module.exports = {
310
+ handleAntiBadwordCommand,
311
+ handleBadwordDetection,
312
+ antibadwordCommand
313
+ };
@@ -0,0 +1,156 @@
1
+ const { getGroupConfig, setGroupConfig, deleteGroupToggle, getOwnerConfig, setOwnerConfig } = require('../../Database/settingsStore');
2
+ const { isBugMessage } = require('../../davelib/index');
3
+ const isAdmin = require('../../davelib/isAdmin');
4
+ const db = require('../../Database/database');
5
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
6
+
7
+ async function antibugCommand(sock, chatId, userMessage, senderId, isSenderAdmin, message) {
8
+ try {
9
+ const fake = createFakeContact(senderId);
10
+ const botName = getBotName();
11
+ const isGroup = chatId.endsWith('@g.us');
12
+
13
+ if (isGroup) {
14
+ if (!isSenderAdmin && !message?.key?.fromMe && !db.isSudo(senderId)) {
15
+ await sock.sendMessage(chatId, { text: `*${botName}*\nAdmin only command!` }, { quoted: fake });
16
+ return;
17
+ }
18
+ } else {
19
+ if (!message?.key?.fromMe && !db.isSudo(senderId)) {
20
+ await sock.sendMessage(chatId, { text: `*${botName}*\nOwner only command!` }, { quoted: fake });
21
+ return;
22
+ }
23
+ }
24
+
25
+ const args = userMessage.slice(8).toLowerCase().trim().split(' ');
26
+ const action = args[0];
27
+
28
+ const config = isGroup
29
+ ? (getGroupConfig(chatId, 'antibug') || { enabled: false })
30
+ : (getOwnerConfig('antibug_pm') || { enabled: false });
31
+ const currentMode = config.enabled ? (config.action || 'delete') : 'off';
32
+
33
+ const { getPrefix } = require('../owner/setprefix');
34
+ const p = getPrefix();
35
+
36
+ if (!action) {
37
+ const scope = isGroup ? 'GROUP' : 'PM';
38
+ const usage = `*${botName} ANTI-BUG (${scope})*\n\nCurrent Mode: ${currentMode.toUpperCase()}\n\n*Commands:*\n${p}antibug off - Disable\n${p}antibug delete - Delete bug messages\n${p}antibug warn - Delete + warn\n${p}antibug kick - Delete + kick${!isGroup ? '\n\nIn PM: blocks bug senders' : ''}`;
39
+
40
+ await sock.sendMessage(chatId, { text: usage }, { quoted: fake });
41
+ return;
42
+ }
43
+
44
+ const validModes = ["off", "delete", "warn", "kick"];
45
+
46
+ if (!validModes.includes(action)) {
47
+ await sock.sendMessage(chatId, {
48
+ text: `*${botName}*\nInvalid mode! Use: off, delete, warn, kick`
49
+ }, { quoted: fake });
50
+ return;
51
+ }
52
+
53
+ if (action === 'off') {
54
+ if (isGroup) {
55
+ deleteGroupToggle(chatId, 'antibug');
56
+ } else {
57
+ setOwnerConfig('antibug_pm', { enabled: false });
58
+ }
59
+ await sock.sendMessage(chatId, {
60
+ text: `*${botName}*\nAnti-Bug DISABLED`
61
+ }, { quoted: fake });
62
+ } else {
63
+ const newConf = { enabled: true, action: action };
64
+ if (isGroup) {
65
+ setGroupConfig(chatId, 'antibug', newConf);
66
+ } else {
67
+ setOwnerConfig('antibug_pm', newConf);
68
+ }
69
+ await sock.sendMessage(chatId, {
70
+ text: `*${botName}*\nAnti-Bug: ${action.toUpperCase()}${!isGroup ? ' (PM)' : ''}`
71
+ }, { quoted: fake });
72
+ }
73
+ } catch (error) {
74
+ console.error('Error in antibug command:', error.message, 'Line:', error.stack?.split('\n')[1]);
75
+ }
76
+ }
77
+
78
+ async function handleBugDetection(sock, chatId, message, senderId) {
79
+ try {
80
+ if (!isBugMessage(message)) return;
81
+
82
+ const isGroup = chatId.endsWith('@g.us');
83
+
84
+ if (isGroup) {
85
+ const config = getGroupConfig(chatId, 'antibug');
86
+ if (!config || !config.enabled) return;
87
+
88
+ const { isSenderAdmin, isBotAdmin } = await isAdmin(sock, chatId, senderId);
89
+ if (!isBotAdmin || isSenderAdmin || db.isSudo(senderId)) return;
90
+
91
+ const botName = getBotName();
92
+ const userTag = `@${senderId.split("@")[0]}`;
93
+ const fake = createFakeContact(senderId);
94
+
95
+ try {
96
+ await sock.sendMessage(chatId, {
97
+ delete: {
98
+ remoteJid: chatId,
99
+ fromMe: false,
100
+ id: message.key.id,
101
+ participant: senderId
102
+ }
103
+ });
104
+ } catch (e) {
105
+ console.error("[ANTI-BUG] Delete failed:", e.message);
106
+ return;
107
+ }
108
+
109
+ if (config.action === 'kick') {
110
+ await sock.sendMessage(chatId, {
111
+ text: `*${botName}*\n\n${userTag} kicked for crash messages.`,
112
+ mentions: [senderId]
113
+ });
114
+ await sock.groupParticipantsUpdate(chatId, [senderId], 'remove');
115
+ } else if (config.action === 'warn') {
116
+ await sock.sendMessage(chatId, {
117
+ text: `*${botName}*\n\n${userTag}, crash messages prohibited!`,
118
+ mentions: [senderId]
119
+ });
120
+ }
121
+ } else {
122
+ const config = getOwnerConfig('antibug_pm') || { enabled: false };
123
+ if (!config.enabled) return;
124
+ if (message.key.fromMe || db.isSudo(senderId)) return;
125
+
126
+ const botName = getBotName();
127
+ const senderNumber = senderId.split('@')[0];
128
+ const fake = createFakeContact(senderId);
129
+ const ownerNumber = sock.user.id.split(':')[0] + '@s.whatsapp.net';
130
+
131
+ await sock.sendMessage(ownerNumber, {
132
+ text: `*${botName} - BUG BLOCKED (PM)*\n\nFrom: @${senderNumber}\nAction: ${config.action || 'delete'}`,
133
+ mentions: [senderId]
134
+ }, { quoted: fake });
135
+
136
+ if (config.action === 'kick' || config.action === 'warn') {
137
+ try {
138
+ await sock.updateBlockStatus(senderId, 'block');
139
+ await sock.sendMessage(ownerNumber, {
140
+ text: `*${botName}*\n@${senderNumber} blocked for sending crash messages in PM.`,
141
+ mentions: [senderId]
142
+ }, { quoted: fake });
143
+ } catch (e) {
144
+ console.error("[ANTI-BUG PM] Block failed:", e.message);
145
+ }
146
+ }
147
+ }
148
+ } catch (error) {
149
+ console.error('Error in handleBugDetection:', error.message, 'Line:', error.stack?.split('\n')[1]);
150
+ }
151
+ }
152
+
153
+ module.exports = {
154
+ antibugCommand,
155
+ handleBugDetection
156
+ };
@@ -0,0 +1,219 @@
1
+ const { getOwnerConfig, setOwnerConfig, parseToggleCommand, parseActionCommand } = require('../../Database/settingsStore');
2
+ const db = require('../../Database/database');
3
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
4
+
5
+ const processedCalls = new Map();
6
+ const CALL_COOLDOWN_MS = 30000;
7
+
8
+ async function isAuthorized(sock, message) {
9
+ try {
10
+ const senderId = message.key.participant || message.key.remoteJid;
11
+ if (message.key.fromMe) return true;
12
+ return db.isSudo(senderId);
13
+ } catch {
14
+ return message.key.fromMe;
15
+ }
16
+ }
17
+
18
+ async function anticallCommand(sock, chatId, message, args) {
19
+ const botName = getBotName();
20
+ const senderId = message.key.participant || message.key.remoteJid;
21
+ const fake = createFakeContact(senderId);
22
+
23
+ if (!await isAuthorized(sock, message)) {
24
+ return sock.sendMessage(chatId, {
25
+ text: `✦ Owner only command`
26
+ }, { quoted: fake });
27
+ }
28
+
29
+ const config = getOwnerConfig('anticall') || { enabled: false, mode: 'block', message: 'Calls not allowed!' };
30
+ const sub = (args || '').trim().toLowerCase();
31
+
32
+ if (!sub) {
33
+ const helpText = `✦ *ANTICALL*
34
+
35
+ Status: ${config.enabled ? 'ON' : 'OFF'}
36
+ Mode: ${config.mode || 'block'}
37
+ Message: ${config.message || 'Calls not allowed!'}
38
+
39
+ Commands:
40
+ › on
41
+ › off
42
+ › block
43
+ › decline
44
+ › both
45
+ › allow
46
+ › .setcallmsg <text>
47
+ › status`;
48
+
49
+ await sock.sendMessage(chatId, { text: helpText }, { quoted: fake });
50
+ return;
51
+ }
52
+
53
+ let newConfig = { ...config };
54
+ let responseText = '';
55
+
56
+ if (sub === 'status') {
57
+ const statusText = `✦ *ANTICALL STATUS*
58
+
59
+ Status: ${config.enabled ? 'ACTIVE' : 'INACTIVE'}
60
+ Mode: ${config.mode || 'block'}
61
+ Message: ${config.message || 'Calls not allowed!'}`;
62
+ await sock.sendMessage(chatId, { text: statusText }, { quoted: fake });
63
+ return;
64
+ }
65
+
66
+ const toggle = parseToggleCommand(sub);
67
+ if (toggle === 'on') {
68
+ newConfig.enabled = true;
69
+ responseText = `✦ Anticall ENABLED\n Mode: ${newConfig.mode || 'block'}`;
70
+ } else if (toggle === 'off') {
71
+ newConfig.enabled = false;
72
+ responseText = `✦ Anticall DISABLED`;
73
+ } else {
74
+ const action = parseActionCommand(sub);
75
+ if (action === 'block') {
76
+ newConfig.mode = 'block';
77
+ newConfig.enabled = true;
78
+ responseText = `✦ Mode: BLOCK\n Callers will be blocked`;
79
+ } else if (action === 'decline') {
80
+ newConfig.mode = 'decline';
81
+ newConfig.enabled = true;
82
+ responseText = `✦ Mode: DECLINE\n Calls will be declined only`;
83
+ } else if (sub === 'both') {
84
+ newConfig.mode = 'both';
85
+ newConfig.enabled = true;
86
+ responseText = `✦ Mode: BOTH\n Declined and blocked`;
87
+ } else if (action === 'allow') {
88
+ newConfig.mode = 'allow';
89
+ newConfig.enabled = false;
90
+ responseText = `✦ Mode: ALLOW\n All calls allowed`;
91
+ } else if (sub.startsWith('msg ') || sub.startsWith('message ')) {
92
+ const msgText = args.replace(/^(msg|message)\s+/i, '').trim();
93
+ if (msgText) {
94
+ newConfig.message = msgText;
95
+ responseText = `✦ Message set: "${msgText}"`;
96
+ } else {
97
+ responseText = `✦ Provide a message`;
98
+ }
99
+ } else {
100
+ responseText = `✦ Invalid command\n Use: on, off, block, decline, both, allow`;
101
+ }
102
+ }
103
+
104
+ if (responseText && !responseText.includes('Invalid') && !responseText.includes('Provide')) {
105
+ setOwnerConfig('anticall', newConfig);
106
+ }
107
+
108
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
109
+ }
110
+
111
+ async function setcallmsgCommand(sock, chatId, message, args) {
112
+ const botName = getBotName();
113
+ const senderId = message.key.participant || message.key.remoteJid;
114
+ const fake = createFakeContact(senderId);
115
+
116
+ if (!await isAuthorized(sock, message)) {
117
+ return sock.sendMessage(chatId, {
118
+ text: `✦ Owner only command`
119
+ }, { quoted: fake });
120
+ }
121
+
122
+ const msgText = (args || '').trim();
123
+
124
+ if (!msgText) {
125
+ const config = getOwnerConfig('anticall') || { message: 'Calls not allowed!' };
126
+ return sock.sendMessage(chatId, {
127
+ text: `✦ *SETCALLMSG*
128
+
129
+ Current: ${config.message}
130
+
131
+ Use: .setcallmsg <message>`
132
+ }, { quoted: fake });
133
+ }
134
+
135
+ const config = getOwnerConfig('anticall') || {};
136
+ setOwnerConfig('anticall', { ...config, message: msgText });
137
+
138
+ await sock.sendMessage(chatId, {
139
+ text: `✦ Message set: "${msgText}"`
140
+ }, { quoted: fake });
141
+ }
142
+
143
+ async function handleIncomingCall(sock, call) {
144
+ try {
145
+ const config = getOwnerConfig('anticall');
146
+ if (!config || !config.enabled || config.mode === 'allow') return;
147
+
148
+ const callKey = call.id || `${call.from}_${Date.now()}`;
149
+ const now = Date.now();
150
+ if (processedCalls.has(callKey)) {
151
+ const lastTime = processedCalls.get(callKey);
152
+ if (now - lastTime < CALL_COOLDOWN_MS) return;
153
+ }
154
+ processedCalls.set(callKey, now);
155
+
156
+ if (processedCalls.size > 50) {
157
+ for (const [key, time] of processedCalls) {
158
+ if (now - time > 60000) processedCalls.delete(key);
159
+ }
160
+ }
161
+
162
+ const callerId = call.from;
163
+ const callerNumber = callerId.split('@')[0];
164
+ const botName = getBotName();
165
+ const fake = createFakeContact(callerId);
166
+
167
+ try { await sock.rejectCall(call.id, call.from); } catch (e) {}
168
+
169
+ const customMsg = config.message || 'Calls not allowed!';
170
+ let modeText = '';
171
+
172
+ switch (config.mode) {
173
+ case 'block':
174
+ modeText = 'You have been blocked';
175
+ break;
176
+ case 'decline':
177
+ modeText = 'Call declined';
178
+ break;
179
+ case 'both':
180
+ modeText = 'Call declined and blocked';
181
+ break;
182
+ default:
183
+ modeText = 'Call declined';
184
+ }
185
+
186
+ const responseMsg = `✦ *${botName}*\n\n${customMsg}\n${modeText}`;
187
+
188
+ await sock.sendMessage(callerId, { text: responseMsg }, { quoted: fake });
189
+
190
+ if (config.mode === 'block' || config.mode === 'both') {
191
+ try {
192
+ await sock.updateBlockStatus(callerId, 'block');
193
+ } catch (blockErr) {
194
+ console.error('Error blocking caller:', blockErr.message);
195
+ }
196
+
197
+ const ownerNumber = sock.user.id.split(':')[0] + '@s.whatsapp.net';
198
+ await sock.sendMessage(ownerNumber, {
199
+ text: `✦ *CALL BLOCKED*\n\nFrom: @${callerNumber}\nAction: ${config.mode.toUpperCase()}`,
200
+ mentions: [callerId]
201
+ }, { quoted: fake });
202
+ }
203
+
204
+ } catch (err) {
205
+ console.error('Error handling call:', err.message);
206
+ }
207
+ }
208
+
209
+ function readState() {
210
+ const config = getOwnerConfig('anticall') || {};
211
+ return { enabled: config.enabled || false };
212
+ }
213
+
214
+ module.exports = {
215
+ anticallCommand,
216
+ setcallmsgCommand,
217
+ handleIncomingCall,
218
+ readState
219
+ };