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,206 @@
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
+ const { getPrefix } = require('../owner/setprefix');
6
+
7
+ async function handleAntiStatusMention(sock, m) {
8
+ try {
9
+ if (!m?.message) return;
10
+ if (m.key.fromMe) return;
11
+
12
+ const chatId = m.key.remoteJid;
13
+ if (!chatId?.endsWith('@g.us')) return;
14
+
15
+ const config = getGroupConfig(chatId, 'antigroupmention');
16
+ if (!config || !config.enabled) return;
17
+
18
+ const mode = config.action || 'delete';
19
+ if (mode === 'off') return;
20
+
21
+ const isGroupStatusMention = m.message?.groupStatusMentionMessage;
22
+
23
+ if (!isGroupStatusMention) {
24
+ const isForwarded = m.message?.extendedTextMessage?.contextInfo?.isForwarded;
25
+ const forwardingScore = m.message?.extendedTextMessage?.contextInfo?.forwardingScore || 0;
26
+
27
+ if (!isForwarded && forwardingScore === 0) return;
28
+
29
+ let text = m.message?.extendedTextMessage?.text || m.message?.conversation || '';
30
+ const groupIdPart = chatId.split('@')[0];
31
+ if (!text.includes(groupIdPart)) return;
32
+ }
33
+
34
+ const sender = m.key.participant || m.key.remoteJid;
35
+ const botName = getBotName();
36
+
37
+ const adminStatus = await isAdmin(sock, chatId, sender);
38
+ const isSenderAdmin = adminStatus.isSenderAdmin;
39
+ const isBotAdmin = adminStatus.isBotAdmin;
40
+
41
+ if (isSenderAdmin || db.isSudo(sender)) {
42
+ return;
43
+ }
44
+
45
+ if (!isBotAdmin) {
46
+ await sock.sendMessage(chatId, {
47
+ text: `┌─ *${botName}* ─┐\n│\n│ Cannot delete - need admin!\n│\n└─────────────┘`,
48
+ });
49
+ return;
50
+ }
51
+
52
+ await sock.sendMessage(chatId, {
53
+ delete: {
54
+ remoteJid: chatId,
55
+ fromMe: false,
56
+ id: m.key.id,
57
+ participant: sender,
58
+ },
59
+ });
60
+
61
+ const userTag = `@${sender.split('@')[0]}`;
62
+
63
+ if (mode === 'delete') {
64
+ await sock.sendMessage(chatId, {
65
+ text: `┌─ *${botName}* ─┐
66
+
67
+ │ ${userTag}
68
+ │ Status mention deleted!
69
+ │ Don't mention this group
70
+
71
+ └─────────────┘`,
72
+ mentions: [sender],
73
+ });
74
+ } else if (mode === 'kick' || mode === 'remove') {
75
+ try {
76
+ await sock.groupParticipantsUpdate(chatId, [sender], 'remove');
77
+ await sock.sendMessage(chatId, {
78
+ text: `┌─ *${botName}* ─┐
79
+
80
+ │ ${userTag}
81
+ │ Kicked for status mention!
82
+
83
+ └─────────────┘`,
84
+ mentions: [sender],
85
+ });
86
+ } catch (err) {
87
+ console.error('Failed to remove user:', err.message, 'Line:', err.stack?.split('\n')[1]);
88
+ }
89
+ }
90
+ } catch (err) {
91
+ console.error('Error in handleAntiStatusMention:', err.message, 'Line:', err.stack?.split('\n')[1]);
92
+ }
93
+ }
94
+
95
+ async function antigroupmentionCommand(sock, chatId, message, senderId) {
96
+ try {
97
+ const fake = createFakeContact(senderId);
98
+ const botName = getBotName();
99
+ const prefix = getPrefix();
100
+
101
+ const userMessage = message.message?.conversation ||
102
+ message.message?.extendedTextMessage?.text || '';
103
+ const args = userMessage.split(' ');
104
+ const subCmd = args[1]?.toLowerCase();
105
+
106
+ if (!chatId.endsWith('@g.us')) {
107
+ await sock.sendMessage(chatId, {
108
+ text: `┌─ *${botName}* ─┐\n│\n│ Group command only!\n│\n└─────────────┘`
109
+ }, { quoted: fake });
110
+ return;
111
+ }
112
+
113
+ const adminStatus = await isAdmin(sock, chatId, senderId);
114
+ const isSenderAdmin = adminStatus.isSenderAdmin;
115
+ const isBotAdmin = adminStatus.isBotAdmin;
116
+
117
+ if (!isBotAdmin) {
118
+ await sock.sendMessage(chatId, {
119
+ text: `┌─ *${botName}* ─┐\n│\n│ Bot needs to be admin!\n│\n└─────────────┘`
120
+ }, { quoted: fake });
121
+ return;
122
+ }
123
+
124
+ if (!subCmd || subCmd === 'help') {
125
+ const config = getGroupConfig(chatId, 'antigroupmention') || { enabled: false };
126
+ await sock.sendMessage(chatId, {
127
+ text: `┌─ *${botName}* ─┐
128
+
129
+ │ Status: ${config.enabled ? 'ON' : 'OFF'}
130
+
131
+ │ Commands:
132
+ │ ${prefix}antigroupmention on
133
+ │ ${prefix}antigroupmention off
134
+ │ ${prefix}antigroupmention delete
135
+ │ ${prefix}antigroupmention kick
136
+ │ ${prefix}antigroupmention status
137
+
138
+ └─────────────┘`
139
+ }, { quoted: fake });
140
+ return;
141
+ }
142
+
143
+ if (subCmd === 'status') {
144
+ const config = getGroupConfig(chatId, 'antigroupmention') || { enabled: false };
145
+ await sock.sendMessage(chatId, {
146
+ text: `┌─ *${botName}* ─┐
147
+
148
+ │ Anti-Group Mention:
149
+ │ ${config.enabled ? 'ACTIVE' : 'INACTIVE'}
150
+ │ ${config.enabled ? 'Mode: ' + (config.action || 'delete').toUpperCase() : ''}
151
+
152
+ └─────────────┘`
153
+ }, { quoted: fake });
154
+ return;
155
+ }
156
+
157
+ if (!isSenderAdmin && !message.key.fromMe && !db.isSudo(senderId)) {
158
+ await sock.sendMessage(chatId, {
159
+ text: `┌─ *${botName}* ─┐\n│\n│ Admin only command!\n│\n└─────────────┘`
160
+ }, { quoted: fake });
161
+ return;
162
+ }
163
+
164
+ const validActions = ['on', 'off', 'delete', 'kick', 'remove'];
165
+ if (!validActions.includes(subCmd)) {
166
+ await sock.sendMessage(chatId, {
167
+ text: `┌─ *${botName}* ─┐
168
+
169
+ │ Invalid option!
170
+ │ Use: on, off, delete, kick
171
+
172
+ └─────────────┘`
173
+ }, { quoted: fake });
174
+ return;
175
+ }
176
+
177
+ if (subCmd === 'off') {
178
+ deleteGroupToggle(chatId, 'antigroupmention');
179
+ await sock.sendMessage(chatId, {
180
+ text: `┌─ *${botName}* ─┐
181
+
182
+ │ Anti-Group Mention DISABLED
183
+
184
+ └─────────────┘`
185
+ }, { quoted: fake });
186
+ } else {
187
+ const action = subCmd === 'on' ? 'delete' : subCmd;
188
+ setGroupConfig(chatId, 'antigroupmention', { enabled: true, action: action });
189
+ await sock.sendMessage(chatId, {
190
+ text: `┌─ *${botName}* ─┐
191
+
192
+ │ Anti-Group Mention ENABLED
193
+ │ Mode: ${action.toUpperCase()}
194
+
195
+ └─────────────┘`
196
+ }, { quoted: fake });
197
+ }
198
+ } catch (error) {
199
+ console.error('Error in antigroupmentionCommand:', error.message, 'Line:', error.stack?.split('\n')[1]);
200
+ }
201
+ }
202
+
203
+ module.exports = {
204
+ handleAntiStatusMention,
205
+ antigroupmentionCommand
206
+ };
@@ -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 antiimageCommand(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(11).toLowerCase().trim().split(' ');
17
+ const action = args[0];
18
+
19
+ if (!action) {
20
+ const config = getGroupConfig(chatId, 'antiimage') || { enabled: false };
21
+ const currentMode = config.enabled ? (config.action || 'delete') : 'off';
22
+
23
+ const usage = `*${botName} ANTI-IMAGE*\n\nCurrent Mode: ${currentMode.toUpperCase()}\n\n*Commands:*\n.antiimage off - Disable\n.antiimage delete - Delete image\n.antiimage warn - Delete + warn\n.antiimage 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, 'antiimage');
40
+ await sock.sendMessage(chatId, {
41
+ text: `*${botName}*\nAnti-Image DISABLED`
42
+ }, { quoted: fake });
43
+ } else {
44
+ setGroupConfig(chatId, 'antiimage', { enabled: true, action: action });
45
+ await sock.sendMessage(chatId, {
46
+ text: `*${botName}*\nAnti-Image: ${action.toUpperCase()}`
47
+ }, { quoted: fake });
48
+ }
49
+ } catch (error) {
50
+ console.error('Error in antiimage command:', error.message, 'Line:', error.stack?.split('\n')[1]);
51
+ }
52
+ }
53
+
54
+ async function handleImageDetection(sock, chatId, message, senderId) {
55
+ try {
56
+ const isImage = message.type === 'imageMessage' ||
57
+ (message.message && message.message.imageMessage);
58
+
59
+ if (!isImage) return;
60
+ if (!chatId.endsWith('@g.us')) return;
61
+
62
+ const config = getGroupConfig(chatId, 'antiimage');
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-IMAGE] 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 image.`,
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}, images are not allowed!`,
94
+ mentions: [senderId]
95
+ });
96
+ }
97
+ } catch (error) {
98
+ console.error('Error in handleImageDetection:', error.message, 'Line:', error.stack?.split('\n')[1]);
99
+ }
100
+ }
101
+
102
+ module.exports = {
103
+ antiimageCommand,
104
+ handleImageDetection
105
+ };
@@ -0,0 +1,125 @@
1
+ const { getGroupConfig, setGroupConfig, parseToggleCommand } = require('../../Database/settingsStore');
2
+ const db = require('../../Database/database');
3
+ const isAdmin = require('../../davelib/isAdmin');
4
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
5
+
6
+ function participantToString(p) {
7
+ if (typeof p === 'string') return p;
8
+ if (p && p.id) return p.id;
9
+ return String(p);
10
+ }
11
+
12
+ async function resolveToPhone(sock, jid) {
13
+ if (!jid) return 'unknown';
14
+ const raw = jid.split('@')[0].split(':')[0];
15
+ if (/^\d{7,15}$/.test(raw)) return raw;
16
+ try {
17
+ if (sock?.signalRepository?.lidMapping?.getPNForLID) {
18
+ const formats = [jid, `${raw}:0@lid`, `${raw}@lid`];
19
+ for (const fmt of formats) {
20
+ try {
21
+ const pn = await sock.signalRepository.lidMapping.getPNForLID(fmt);
22
+ if (pn) {
23
+ const num = String(pn).split('@')[0].replace(/[^0-9]/g, '');
24
+ if (num.length >= 7 && num.length <= 15 && num !== raw) return num;
25
+ }
26
+ } catch {}
27
+ }
28
+ }
29
+ const groups = await sock.groupFetchAllParticipating();
30
+ for (const gid of Object.keys(groups)) {
31
+ for (const p of (groups[gid].participants || [])) {
32
+ const pid = (p.id || '').split('@')[0].split(':')[0];
33
+ const pLid = (p.lid || '').split('@')[0].split(':')[0];
34
+ if ((pLid === raw || pid === raw) && pid && /^\d{7,15}$/.test(pid) && pid !== raw) return pid;
35
+ }
36
+ }
37
+ } catch {}
38
+ return raw;
39
+ }
40
+
41
+ async function antikickCommand(sock, chatId, message, senderId, isSenderAdmin) {
42
+ try {
43
+ const fake = createFakeContact(senderId);
44
+ const botName = getBotName();
45
+
46
+ if (!isSenderAdmin && !message.key.fromMe && !db.isSudo(senderId)) {
47
+ await sock.sendMessage(chatId, { text: `*${botName}*\nAdmin only command!` }, { quoted: fake });
48
+ return;
49
+ }
50
+
51
+ const text = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
52
+ const args = text.trim().split(' ').slice(1);
53
+ const action = args[0]?.toLowerCase();
54
+
55
+ const config = getGroupConfig(chatId, 'antikick') || { enabled: false };
56
+
57
+ if (!action) {
58
+ const helpText = `*${botName} ANTIKICK*\n\n` +
59
+ `Status: ${config.enabled ? 'ON' : 'OFF'}\n\n` +
60
+ `*Commands:*\n` +
61
+ `.antikick on - Enable\n` +
62
+ `.antikick off - Disable\n` +
63
+ `.antikick status - Show status`;
64
+ await sock.sendMessage(chatId, { text: helpText }, { quoted: fake });
65
+ return;
66
+ }
67
+
68
+ let responseText = '';
69
+
70
+ if (action === 'status') {
71
+ responseText = `*${botName}*\nAntikick: ${config.enabled ? 'ACTIVE' : 'INACTIVE'}`;
72
+ } else {
73
+ const toggle = parseToggleCommand(action);
74
+ if (toggle === 'on') {
75
+ setGroupConfig(chatId, 'antikick', { enabled: true });
76
+ responseText = `*${botName}*\nAntikick ENABLED\nRemoved members will be re-added.`;
77
+ } else if (toggle === 'off') {
78
+ setGroupConfig(chatId, 'antikick', { enabled: false });
79
+ responseText = `*${botName}*\nAntikick DISABLED`;
80
+ } else {
81
+ responseText = `*${botName}*\nInvalid command! Use: on, off, status`;
82
+ }
83
+ }
84
+
85
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
86
+ } catch (error) {
87
+ console.error('Error in antikick command:', error.message, 'Line:', error.stack?.split('\n')[1]);
88
+ }
89
+ }
90
+
91
+ async function handleAntikick(sock, chatId, participants) {
92
+ try {
93
+ const config = getGroupConfig(chatId, 'antikick');
94
+ if (!config?.enabled) return;
95
+
96
+ const botName = getBotName();
97
+ const fake = createFakeContact();
98
+
99
+ for (const participant of participants) {
100
+ try {
101
+ const participantJid = participantToString(participant);
102
+ const participantNumber = await resolveToPhone(sock, participantJid);
103
+ await sock.groupParticipantsUpdate(chatId, [participantJid], 'add');
104
+ await sock.sendMessage(chatId, {
105
+ text: `*${botName}*\n@${participantNumber} was re-added by antikick.`,
106
+ mentions: [participantJid]
107
+ }, { quoted: fake });
108
+ } catch (addError) {
109
+ console.error('Antikick re-add failed:', addError.message);
110
+ }
111
+ }
112
+ } catch (error) {
113
+ console.error('Error in antikick handler:', error.message, 'Line:', error.stack?.split('\n')[1]);
114
+ }
115
+ }
116
+
117
+ function getGroupConfigExport(chatId) {
118
+ return getGroupConfig(chatId, 'antikick') || { enabled: false };
119
+ }
120
+
121
+ module.exports = {
122
+ antikickCommand,
123
+ handleAntikick,
124
+ getGroupConfig: getGroupConfigExport
125
+ };
@@ -0,0 +1,237 @@
1
+ const { getGroupConfig, setGroupConfig, parseToggleCommand, parseActionCommand } = require('../../Database/settingsStore');
2
+ const db = require('../../Database/database');
3
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
4
+
5
+ function normalizeJid(jid) {
6
+ if (!jid) return '';
7
+ const num = jid.split('@')[0].split(':')[0];
8
+ return num + '@s.whatsapp.net';
9
+ }
10
+
11
+ async function handleAntiLinkDetection(sock, m) {
12
+ try {
13
+ if (!m?.message) return;
14
+ if (m.key.fromMe) return;
15
+ if (!m.key.remoteJid?.endsWith('@g.us')) return;
16
+
17
+ const chatId = m.key.remoteJid;
18
+ const sender = m.key.participant || m.key.remoteJid;
19
+
20
+ const config = getGroupConfig(chatId, 'antilink');
21
+ if (!config?.enabled) return;
22
+
23
+ let text = "";
24
+ const msg = m.message;
25
+ if (msg.conversation) {
26
+ text = msg.conversation;
27
+ } else if (msg.extendedTextMessage?.text) {
28
+ text = msg.extendedTextMessage.text;
29
+ } else if (msg.imageMessage?.caption) {
30
+ text = msg.imageMessage.caption;
31
+ } else if (msg.videoMessage?.caption) {
32
+ text = msg.videoMessage.caption;
33
+ } else if (msg.documentMessage?.caption) {
34
+ text = msg.documentMessage.caption;
35
+ } else if (msg.buttonsResponseMessage?.selectedDisplayText) {
36
+ text = msg.buttonsResponseMessage.selectedDisplayText;
37
+ } else if (msg.listResponseMessage?.title) {
38
+ text = msg.listResponseMessage.title;
39
+ } else if (msg.templateButtonReplyMessage?.selectedDisplayText) {
40
+ text = msg.templateButtonReplyMessage.selectedDisplayText;
41
+ }
42
+
43
+ const urlRegex = /(https?:\/\/[^\s]+|www\.[^\s]+|bit\.ly\/[^\s]+|t\.me\/[^\s]+|chat\.whatsapp\.com\/[^\s]+|whatsapp\.com\/[^\s]+|youtu\.be\/[^\s]+|youtube\.com\/[^\s]+)/gi;
44
+ if (!urlRegex.test(String(text).toLowerCase())) return;
45
+
46
+ console.log(`[ANTILINK] Link detected from ${sender} in ${chatId}: "${text.substring(0, 80)}"`);
47
+
48
+ let groupMetadata;
49
+ try {
50
+ groupMetadata = await sock.groupMetadata(chatId);
51
+ } catch (metaErr) {
52
+ console.error('[ANTILINK] Failed to fetch group metadata:', metaErr.message);
53
+ return;
54
+ }
55
+
56
+ const botId = normalizeJid(sock.user.id);
57
+ const normalizedSender = normalizeJid(sender);
58
+ const bot = groupMetadata.participants.find(p => normalizeJid(p.id) === botId || p.id === sock.user?.id);
59
+ if (bot && !bot.admin) {
60
+ console.log(`[ANTILINK] Bot is not admin, skipping`);
61
+ return;
62
+ }
63
+
64
+ const participant = groupMetadata.participants.find(p => normalizeJid(p.id) === normalizedSender || p.id === sender);
65
+ if (participant?.admin) {
66
+ console.log(`[ANTILINK] Sender is admin, skipping`);
67
+ return;
68
+ }
69
+ if (db.isSudo(sender) || db.isSudo(normalizedSender)) {
70
+ console.log(`[ANTILINK] Sender is sudo, skipping`);
71
+ return;
72
+ }
73
+
74
+ const botName = getBotName();
75
+ const fake = createFakeContact(sender);
76
+
77
+ await sock.sendMessage(chatId, {
78
+ delete: {
79
+ remoteJid: chatId,
80
+ fromMe: false,
81
+ id: m.key.id,
82
+ participant: sender,
83
+ },
84
+ });
85
+
86
+ const username = sender.split('@')[0];
87
+ const action = config.action || 'delete';
88
+ const maxWarnings = config.maxWarnings || 3;
89
+
90
+ switch (action) {
91
+ case 'delete':
92
+ await sock.sendMessage(chatId, {
93
+ text: `*${botName}*\n@${username}, no links allowed!\nMessage deleted.`,
94
+ mentions: [sender],
95
+ }, { quoted: fake });
96
+ break;
97
+
98
+ case 'warn':
99
+ const warningCount = db.incrementWarning(chatId, sender);
100
+ if (warningCount >= maxWarnings) {
101
+ try {
102
+ await sock.groupParticipantsUpdate(chatId, [sender], 'remove');
103
+ db.resetWarning(chatId, sender);
104
+ await sock.sendMessage(chatId, {
105
+ text: `*${botName}*\n@${username} kicked after ${maxWarnings} warnings!\nLinks not allowed.`,
106
+ mentions: [sender],
107
+ }, { quoted: fake });
108
+ } catch {}
109
+ } else {
110
+ await sock.sendMessage(chatId, {
111
+ text: `*${botName}*\n@${username}, no links allowed!\nWarning ${warningCount}/${maxWarnings}`,
112
+ mentions: [sender],
113
+ }, { quoted: fake });
114
+ }
115
+ break;
116
+
117
+ case 'kick':
118
+ try {
119
+ await sock.groupParticipantsUpdate(chatId, [sender], 'remove');
120
+ await sock.sendMessage(chatId, {
121
+ text: `*${botName}*\n@${username} kicked for posting links.`,
122
+ mentions: [sender],
123
+ }, { quoted: fake });
124
+ } catch (err) {
125
+ console.error('Failed to kick user:', err.message);
126
+ }
127
+ break;
128
+ }
129
+ } catch (err) {
130
+ console.error('Error in handleAntiLinkDetection:', err.message, 'Line:', err.stack?.split('\n')[1]);
131
+ }
132
+ }
133
+
134
+ async function handleAntilinkCommand(sock, chatId, userMessage, senderId, isSenderAdmin) {
135
+ try {
136
+ const text = typeof userMessage === 'string' ? userMessage :
137
+ (userMessage?.message?.conversation ||
138
+ userMessage?.message?.extendedTextMessage?.text || '');
139
+
140
+ const parts = text.trim().split(/\s+/);
141
+ const subCmd = parts[1]?.toLowerCase();
142
+ const botName = getBotName();
143
+ const fake = createFakeContact(senderId);
144
+ const config = getGroupConfig(chatId, 'antilink') || { enabled: false, action: 'delete', maxWarnings: 3 };
145
+
146
+ if (!subCmd || subCmd === 'help' || subCmd === 'status') {
147
+ const helpText = `*${botName} ANTILINK*\n\n` +
148
+ `Status: ${config.enabled ? 'ON' : 'OFF'}\n` +
149
+ `Action: ${config.action || 'delete'}\n` +
150
+ `Max Warnings: ${config.maxWarnings || 3}\n\n` +
151
+ `*Commands:*\n` +
152
+ `.antilink on - Enable\n` +
153
+ `.antilink off - Disable\n` +
154
+ `.antilink delete - Set action to delete only\n` +
155
+ `.antilink warn - Set action to warn (max = kick)\n` +
156
+ `.antilink kick - Set action to delete & kick\n` +
157
+ `.antilink setwarn <num> - Set max warnings\n` +
158
+ `.antilink status - Show status`;
159
+ await sock.sendMessage(chatId, { text: helpText }, { quoted: fake });
160
+ return;
161
+ }
162
+
163
+ if (subCmd === 'setwarn') {
164
+ const num = parseInt(parts[2]);
165
+ if (num > 0 && num <= 10) {
166
+ const newConfig = { ...config, maxWarnings: num };
167
+ setGroupConfig(chatId, 'antilink', newConfig);
168
+ await sock.sendMessage(chatId, {
169
+ text: `*${botName}*\nMax warnings set to: ${num}`
170
+ }, { quoted: fake });
171
+ } else {
172
+ await sock.sendMessage(chatId, {
173
+ text: `*${botName}*\nInvalid number! Use 1-10`
174
+ }, { quoted: fake });
175
+ }
176
+ return;
177
+ }
178
+
179
+ let newConfig = { ...config };
180
+ let responseText = '';
181
+
182
+ if (subCmd === 'on' || subCmd === 'enable') {
183
+ newConfig.enabled = true;
184
+ responseText = `*${botName}*\nAntiLink ENABLED\nAction: ${newConfig.action || 'delete'}`;
185
+ } else if (subCmd === 'off' || subCmd === 'disable') {
186
+ newConfig.enabled = false;
187
+ responseText = `*${botName}*\nAntiLink DISABLED`;
188
+ } else if (subCmd === 'delete' || subCmd === 'del') {
189
+ newConfig.action = 'delete';
190
+ newConfig.enabled = true;
191
+ responseText = `*${botName}*\nAntiLink action set to: DELETE\nLinks will be deleted.`;
192
+ } else if (subCmd === 'warn' || subCmd === 'warning') {
193
+ newConfig.action = 'warn';
194
+ newConfig.enabled = true;
195
+ responseText = `*${botName}*\nAntiLink action set to: WARN\n${newConfig.maxWarnings || 3} warnings = kick.`;
196
+ } else if (subCmd === 'kick' || subCmd === 'boot') {
197
+ newConfig.action = 'kick';
198
+ newConfig.enabled = true;
199
+ responseText = `*${botName}*\nAntiLink action set to: KICK\nLink senders will be removed immediately.`;
200
+ } else {
201
+ responseText = `*${botName}*\nInvalid option: "${subCmd}"\nUse: on, off, delete, warn, kick`;
202
+ }
203
+
204
+ if (responseText && !responseText.includes('Invalid')) {
205
+ setGroupConfig(chatId, 'antilink', newConfig);
206
+ }
207
+
208
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
209
+
210
+ } catch (error) {
211
+ console.error('Error in handleAntilinkCommand:', error.message, 'Line:', error.stack?.split('\n')[1]);
212
+ const botName = getBotName();
213
+ await sock.sendMessage(chatId, {
214
+ text: `*${botName}*\nFailed to configure antilink!`
215
+ });
216
+ }
217
+ }
218
+
219
+ async function getAntilink(groupId) {
220
+ return getGroupConfig(groupId, 'antilink');
221
+ }
222
+
223
+ async function setAntilink(groupId, type, action) {
224
+ const config = {
225
+ enabled: type === 'on' || type === 'delete' || type === 'kick' || type === 'warn',
226
+ action: action || 'delete'
227
+ };
228
+ setGroupConfig(groupId, 'antilink', config);
229
+ return true;
230
+ }
231
+
232
+ module.exports = {
233
+ handleAntiLinkDetection,
234
+ handleAntilinkCommand,
235
+ getAntilink,
236
+ setAntilink
237
+ };