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
package/dave.js ADDED
@@ -0,0 +1,3063 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const chalk = require('chalk').default || require('chalk');
4
+
5
+ // ========== TEMP FOLDER SETUP ==========
6
+ const customTemp = path.join(process.cwd(), 'temp');
7
+ if (!fs.existsSync(customTemp)) fs.mkdirSync(customTemp, { recursive: true });
8
+ process.env.TMPDIR = customTemp;
9
+ process.env.TEMP = customTemp;
10
+ process.env.TMP = customTemp;
11
+
12
+ // Clean temp folder every 1 hour (aggressive for free panels)
13
+ setInterval(() => {
14
+ fs.readdir(customTemp, (err, files) => {
15
+ if (err) return;
16
+ for (const file of files) {
17
+ const filePath = path.join(customTemp, file);
18
+ fs.stat(filePath, (err, stats) => {
19
+ if (!err && Date.now() - stats.mtimeMs > 1 * 60 * 60 * 1000) {
20
+ fs.unlink(filePath, () => {});
21
+ }
22
+ });
23
+ }
24
+ });
25
+ console.log('🧹 Temp folder auto-cleaned');
26
+ }, 1 * 60 * 60 * 1000);
27
+
28
+ // Store original console.log (before any overrides from index.js)
29
+ const originalConsoleLog = console.log;
30
+
31
+ // ========== GROUP NAME & LID RESOLUTION CACHES ==========
32
+ const groupNameCache = new Map();
33
+ const GROUP_CACHE_TTL = 2 * 60 * 1000;
34
+ const MAX_GROUP_CACHE = 25;
35
+ setInterval(() => { if (groupNameCache.size > MAX_GROUP_CACHE) groupNameCache.clear(); }, 3 * 60 * 1000);
36
+ async function getGroupName(sock, chatId) {
37
+ const cached = groupNameCache.get(chatId);
38
+ if (cached && Date.now() - cached.ts < GROUP_CACHE_TTL) return cached.name;
39
+ try {
40
+ const meta = await sock.groupMetadata(chatId);
41
+ const name = meta?.subject || chatId.split('@')[0];
42
+ groupNameCache.set(chatId, { name, ts: Date.now() });
43
+ return name;
44
+ } catch {
45
+ return chatId.split('@')[0];
46
+ }
47
+ }
48
+
49
+ const lidPhoneCache = new Map();
50
+ const LID_CACHE_TTL = 5 * 60 * 1000;
51
+ const MAX_LID_CACHE = 40;
52
+ setInterval(() => { if (lidPhoneCache.size > MAX_LID_CACHE) lidPhoneCache.clear(); }, 5 * 60 * 1000);
53
+ let lidGroupScanDone = false;
54
+ let lidGroupScanTs = 0;
55
+
56
+ function cacheLidPhone(lidNum, phoneNum) {
57
+ if (!lidNum || !phoneNum || lidNum === phoneNum) return;
58
+ if (phoneNum.includes('lid')) return;
59
+ if (lidNum.length <= 15 && /^\d+$/.test(lidNum)) return;
60
+ lidPhoneCache.set(lidNum, { phone: phoneNum, ts: Date.now() });
61
+ }
62
+
63
+ function isLidJid(jid) {
64
+ if (!jid) return false;
65
+ if (jid.includes('@lid')) return true;
66
+ const num = jid.split('@')[0].split(':')[0];
67
+ if (num.length > 15) return true;
68
+ if (!/^\d+$/.test(num)) return true;
69
+ return false;
70
+ }
71
+
72
+ async function resolvePhoneFromLid(sock, lidJid) {
73
+ if (!lidJid) return null;
74
+ const lidNum = lidJid.split('@')[0].split(':')[0];
75
+
76
+ const cached = lidPhoneCache.get(lidNum);
77
+ if (cached && Date.now() - cached.ts < LID_CACHE_TTL) return cached.phone;
78
+
79
+ if (sock?.signalRepository?.lidMapping?.getPNForLID) {
80
+ try {
81
+ const formats = [
82
+ lidJid,
83
+ `${lidNum}:0@lid`,
84
+ `${lidNum}@lid`
85
+ ];
86
+ for (const fmt of formats) {
87
+ try {
88
+ const pn = await sock.signalRepository.lidMapping.getPNForLID(fmt);
89
+ if (pn) {
90
+ const num = String(pn).split('@')[0].replace(/[^0-9]/g, '');
91
+ if (num.length >= 7 && num.length <= 15 && num !== lidNum) {
92
+ cacheLidPhone(lidNum, num);
93
+ return num;
94
+ }
95
+ }
96
+ } catch {}
97
+ }
98
+ } catch {}
99
+ }
100
+
101
+ if (!lidGroupScanDone || Date.now() - lidGroupScanTs > 30 * 60 * 1000) {
102
+ try {
103
+ const groups = await sock.groupFetchAllParticipating();
104
+ for (const gid of Object.keys(groups)) {
105
+ const participants = groups[gid].participants || [];
106
+ for (const p of participants) {
107
+ const pid = (p.id || '').split('@')[0].split(':')[0];
108
+ const pLid = (p.lid || '').split('@')[0].split(':')[0];
109
+
110
+ let phoneNum = null;
111
+ if (pid && !pid.includes('lid') && pid.length >= 7 && pid.length <= 15 && /^\d+$/.test(pid)) {
112
+ phoneNum = pid;
113
+ }
114
+
115
+ let lidVal = null;
116
+ if (pLid && pLid.length >= 5) lidVal = pLid;
117
+ if (!lidVal && (p.id || '').includes('@lid')) lidVal = pid;
118
+ if (!lidVal && pid.length > 15) lidVal = pid;
119
+
120
+ if (phoneNum && lidVal) {
121
+ cacheLidPhone(lidVal, phoneNum);
122
+ }
123
+
124
+ if (lidVal && !phoneNum && sock?.signalRepository?.lidMapping?.getPNForLID) {
125
+ try {
126
+ const fullLid = p.lid || p.id;
127
+ const pn = await sock.signalRepository.lidMapping.getPNForLID(fullLid);
128
+ if (pn) {
129
+ const num = String(pn).split('@')[0].replace(/[^0-9]/g, '');
130
+ if (num.length >= 7 && num.length <= 15) {
131
+ cacheLidPhone(lidVal, num);
132
+ }
133
+ }
134
+ } catch {}
135
+ }
136
+ }
137
+ }
138
+ lidGroupScanDone = true;
139
+ lidGroupScanTs = Date.now();
140
+ } catch (e) {}
141
+ }
142
+
143
+ const resolved = lidPhoneCache.get(lidNum);
144
+ if (resolved) return resolved.phone;
145
+
146
+ if (sock?.onWhatsApp) {
147
+ try {
148
+ const results = await sock.onWhatsApp(lidJid);
149
+ if (results?.[0]?.jid) {
150
+ const num = results[0].jid.split('@')[0].replace(/[^0-9]/g, '');
151
+ if (num.length >= 7 && num.length <= 15 && num !== lidNum) {
152
+ cacheLidPhone(lidNum, num);
153
+ return num;
154
+ }
155
+ }
156
+ } catch {}
157
+ }
158
+
159
+ return lidNum;
160
+ }
161
+
162
+ async function resolveParticipantNumber(sock, participant) {
163
+ if (!participant) return '';
164
+ const num = participant.split('@')[0].split(':')[0];
165
+ if (isLidJid(participant)) {
166
+ const resolved = await resolvePhoneFromLid(sock, participant);
167
+ return resolved || num;
168
+ }
169
+ return num;
170
+ }
171
+
172
+ // ========== GLITCH TEXT FUNCTION ==========
173
+ const glitchText = (text) => {
174
+ return chalk.hex('#00ffff').bold(text) + chalk.hex('#ff00ff')('_');
175
+ };
176
+
177
+ // ========== MODULE IMPORTS ==========
178
+ const { getBotName, createFakeContact } = require('./davelib/fakeContact');
179
+ const settings = require('./daveset');
180
+ require('./config.js');
181
+ const { isBanned } = require('./davelib/isBanned');
182
+ const yts = require('yt-search');
183
+ const { fetchBuffer, smsg, fetchJson, sleep, formatSize, randomKarakter } = require('./davelib/myfunc');
184
+ const fetch = require('node-fetch');
185
+ const ytdl = require('ytdl-core');
186
+ const axios = require('axios');
187
+ const ffmpeg = require('fluent-ffmpeg');
188
+ const { jidDecode } = require('@whiskeysockets/baileys');
189
+ const { isSudo } = require('./davelib/index');
190
+ const isAdmin = require('./davelib/isAdmin');
191
+
192
+ // Message Handler
193
+ const {
194
+ getMessageText,
195
+ isEditedMessage,
196
+ getEditedMessageText,
197
+ extractCommand,
198
+ shouldProcessEditedMessage
199
+ } = require('./davelib/messageHandler');
200
+
201
+ // ========== COMMAND IMPORTS ==========
202
+
203
+ // === CORE & BOT MANAGEMENT ===
204
+ const { getPrefix, handleSetPrefixCommand } = require('./davexcore/owner/setprefix');
205
+ const { getOwnerName, handleSetOwnerCommand } = require('./davexcore/owner/setowner');
206
+ const {
207
+ setbotconfigCommand,
208
+ setbotnameCommand,
209
+ setmenuimageCommand
210
+ } = require('./davexcore/owner/setbotconfig');
211
+ const ownerCommand = require('./davexcore/owner/owner');
212
+ const pingCommand = require('./davexcore/owner/ping');
213
+ const aliveCommand = require('./davexcore/owner/alive');
214
+ const updateCommand = require('./davexcore/owner/update');
215
+ const settingsCommand = require('./davexcore/owner/settings');
216
+ const { sudoCommand } = require('./davexcore/owner/sudo');
217
+ const clearSessionCommand = require('./davexcore/owner/clearsession');
218
+ const { menuManageCommand } = require('./davexcore/owner/menuManage');
219
+ const helpCommand = require('./davexcore/owner/help');
220
+ const bioCommand = require('./davexcore/owner/bio');
221
+ const setfontCommand = require('./davexcore/owner/setfont');
222
+ const { pinchatCommand, unpinchatCommand } = require('./davexcore/owner/pinchat');
223
+ const disappearCommand = require('./davexcore/group/disappear');
224
+
225
+ // === MODERATION COMMANDS ===
226
+ const banCommand = require('./davexcore/group/ban');
227
+ const unbanCommand = require('./davexcore/group/unban');
228
+ const muteCommand = require('./davexcore/group/mute');
229
+ const unmuteCommand = require('./davexcore/group/unmute');
230
+ const kickCommand = require('./davexcore/group/kick');
231
+ const warnCommand = require('./davexcore/group/warn');
232
+ const warningsCommand = require('./davexcore/group/warnings');
233
+ const { promoteCommand, handlePromotionEvent } = require('./davexcore/group/promote');
234
+ const { demoteCommand, handleDemotionEvent } = require('./davexcore/group/demote');
235
+ const { clearCommand } = require('./davexcore/group/clear');
236
+ const kickAllCommand = require('./davexcore/group/kickall');
237
+ const { blockCommand, unblockCommand, blocklistCommand } = require('./davexcore/group/blockUnblock');
238
+ const { removeProfilePicCommand, setProfilePicPrivacyCommand } = require('./davexcore/owner/profilepic');
239
+
240
+ // === GROUP MANAGEMENT ===
241
+ const groupInfoCommand = require('./davexcore/group/groupinfo');
242
+ const staffCommand = require('./davexcore/group/staff');
243
+ const resetlinkCommand = require('./davexcore/group/resetlink');
244
+ const linkgroupCommand = require('./davexcore/group/linkgroup');
245
+ const creategroupCommand = require('./davexcore/group/creategroup');
246
+ const leaveGroupCommand = require('./davexcore/group/leave');
247
+ const {
248
+ setGroupDescription,
249
+ setGroupName,
250
+ setGroupPhoto
251
+ } = require('./davexcore/group/groupmanage');
252
+ const { tagAllCommand } = require('./davexcore/group/tagall');
253
+ const tagCommand = require('./davexcore/group/tag');
254
+ const tagNotAdminCommand = require('./davexcore/group/tagnotadmin');
255
+ const hideTagCommand = require('./davexcore/group/hidetag');
256
+ const { addMemberCommand } = require('./davexcore/group/addmember');
257
+
258
+ // === ANTI-FEATURES ===
259
+ const { handleAntiLinkDetection, handleAntilinkCommand } = require('./davexcore/anti/antilink');
260
+ const { handleAntiStatusMention, antigroupmentionCommand } = require('./davexcore/anti/antigroupmention');
261
+ const { handleChartDetection, antichartCommand } = require('./davexcore/anti/antichart');
262
+ const { handleAntitagCommand, handleTagDetection } = require('./davexcore/anti/antitag');
263
+ const { handleAntiBadwordCommand, handleBadwordDetection, antibadwordCommand } = require('./davexcore/anti/antibadword');
264
+ const { handleMentionDetection, mentionToggleCommand, setMentionCommand } = require('./davexcore/anti/mention');
265
+ const { antimentionCommand, handleMentionDetection: handleNewMentionDetection } = require('./davexcore/anti/antimention');
266
+ const { antipromoteCommand, handleAntipromote } = require('./davexcore/anti/antipromote');
267
+ const { antidemoteCommand, handleAntidemote } = require('./davexcore/anti/antidemote');
268
+ const { antibugCommand, handleBugDetection } = require('./davexcore/anti/antibug');
269
+ const { antivideoCommand, handleVideoDetection } = require('./davexcore/anti/antivideo');
270
+ const { antidocumentCommand, handleDocumentDetection } = require('./davexcore/anti/antidocument');
271
+ const { antifilesCommand, handleFilesDetection } = require('./davexcore/anti/antifiles');
272
+ const { antistickerCommand, handleStickerDetection } = require('./davexcore/anti/antisticker');
273
+ const { antiimageCommand, handleImageDetection } = require('./davexcore/anti/antiimage');
274
+ const { antiaudioCommand, handleAudioDetection } = require('./davexcore/anti/antiaudio');
275
+ const { antikickCommand, handleAntikick, getGroupConfig: getAntikickConfig } = require('./davexcore/anti/antikick');
276
+ const { getGroupConfig } = require('./Database/settingsStore');
277
+ const { getBotMode, setBotMode } = require('./Database/database');
278
+ const { handleAntideleteCommand, handleMessageRevocation, storeMessage } = require('./davexcore/anti/antidelete');
279
+ const { antieditCommand, storeOriginalMessage, handleEditedMessage, handleMessageUpdate } = require('./davexcore/anti/antiedit');
280
+ const { handleAntiviewonce, antiviewonceCommand } = require('./davexcore/anti/antiviewonce');
281
+ const { handleStatusAntideleteCommand, handleStatusDeletion, storeStatusMessage } = require('./davexcore/anti/antideletestatus');
282
+
283
+ // === AUTOMATION FEATURES ===
284
+ const { autotypingCommand, isAutotypingEnabled, handleAutotypingForMessage } = require('./davexcore/automation/autotyping');
285
+ const { autoreadCommand, isAutoreadEnabled, handleAutoread } = require('./davexcore/automation/autoread');
286
+ const { autorecordingCommand, isAutorecordingEnabled, handleAutorecordingForMessage } = require('./davexcore/automation/autorecording');
287
+ const { autoStatusCommand, handleStatusUpdate } = require('./davexcore/automation/autostatus');
288
+ const { welcomeCommand, handleJoinEvent } = require('./davexcore/automation/welcome');
289
+ const { goodbyeCommand, handleLeaveEvent } = require('./davexcore/automation/goodbye');
290
+ const { handleChatbotCommand, handleChatbotResponse } = require('./davexcore/automation/chatbot');
291
+ const { addCommandReaction, handleAreactCommand } = require('./davelib/reactions');
292
+ const { incrementMessageCount, topMembers } = require('./davexcore/group/topmembers');
293
+ const { pmblockerCommand } = require('./davexcore/group/pmblocker');
294
+ const { anticallCommand, setcallmsgCommand, handleIncomingCall, readState: readAnticallState } = require('./davexcore/anti/anticall');
295
+ const { groupanticallCommand, handleGroupCall } = require('./davexcore/anti/groupanticall');
296
+ const { startupWelcomeCommand } = require('./davexcore/owner/startupwelcome');
297
+ const { broadcastCommand } = require('./davexcore/owner/broadcast');
298
+ const { alwaysonlineCommand, alwaysofflineCommand, initPresenceOnConnect } = require('./davexcore/automation/alwaysonline');
299
+ const { pinCommand, unpinCommand, archiveCommand, unarchiveCommand, disappearingCommand } = require('./davexcore/automation/chatmanage');
300
+ const { autoreadReceiptsCommand } = require('./davexcore/automation/autoReadReciepts');
301
+ const lastseenCommand = require('./davexcore/utility/lastseen');
302
+
303
+
304
+ // === MEDIA & ENTERTAINMENT ===
305
+ const stickerCommand = require('./davexcore/media/sticker');
306
+ const simageCommand = require('./davexcore/media/simage');
307
+ const attpCommand = require('./davexcore/media/attp');
308
+ const emojimixCommand = require('./davexcore/media/emojimix');
309
+ const stickerTelegramCommand = require('./davexcore/media/stickertelegram');
310
+ const stickercropCommand = require('./davexcore/media/stickercrop');
311
+ const { qcCommand } = require('./davexcore/media/quotesticker');
312
+ const ttsCommand = require('./davexcore/media/tts');
313
+ const memeCommand = require('./davexcore/media/meme');
314
+ const songCommand = require('./davexcore/downloads/song');
315
+ const videoCommand = require('./davexcore/downloads/video');
316
+ const playCommand = require('./davexcore/downloads/play');
317
+ const { ytplayCommand, ytsongCommand } = require('./davexcore/downloads/ytdl');
318
+ const ytsCommand = require('./davexcore/downloads/yts');
319
+ const { tiktokCommand } = require('./davexcore/downloads/tiktok');
320
+ const tiktokaudioCommand = require('./davexcore/downloads/tiktokaudio');
321
+ const spotifyCommand = require('./davexcore/downloads/spotify');
322
+ const ytdocvideoCommand = require('./davexcore/downloads/ytdocvideo');
323
+ const ytdocplayCommand = require('./davexcore/downloads/ytdocplay');
324
+ const shazamCommand = require('./davexcore/media/shazam');
325
+ const instagramCommand = require('./davexcore/downloads/instagram');
326
+ const { igsCommand } = require('./davexcore/downloads/igs');
327
+ const facebookCommand = require('./davexcore/downloads/facebook');
328
+ const movieCommand = require('./davexcore/utility/movie');
329
+ const { animeCommand } = require('./davexcore/media/anime');
330
+ const { piesCommand, piesAlias } = require('./davexcore/media/pies');
331
+ const imagineCommand = require('./davexcore/ai/imagine');
332
+ const soraCommand = require('./davexcore/ai/sora');
333
+ const mediafireCommand = require('./davexcore/downloads/mediafire');
334
+
335
+ // === AI & TOOLS ===
336
+ const perplexityCommand = require('./davexcore/ai/perplexity');
337
+ const aiCommand = require('./davexcore/ai/ai');
338
+ const visionCommand = require('./davexcore/ai/vision');
339
+ const metaiCommand = require('./davexcore/ai/meta');
340
+ const grokCommand = require('./davexcore/ai/grok');
341
+ const blackboxCommand = require('./davexcore/ai/blackbox');
342
+ const birdCommand = require('./davexcore/ai/bird');
343
+ const speechwriterCommand = require('./davexcore/ai/speechwriter');
344
+ const mistralCommand = require('./davexcore/ai/mistral');
345
+ const locationCommand = require('./davexcore/utility/location');
346
+ const gpt4Command = require('./davexcore/ai/aiGpt4');
347
+ const wormgptCommand = require('./davexcore/ai/wormgpt');
348
+ const copilotCommand = require('./davexcore/ai/copilot');
349
+ const { handleTranslateCommand } = require('./davexcore/utility/translate');
350
+ // At the top with other imports
351
+ const deepseekCommand = require('./davexcore/ai/deepseek');
352
+ const { handleSsCommand } = require('./davexcore/utility/ss');
353
+ const googleCommand = require('./davexcore/utility/google');
354
+ const githubCommand = require('./davexcore/utility/github');
355
+ const gitcloneCommand = require('./davexcore/downloads/gitclone');
356
+ const apkCommand = require('./davexcore/downloads/apk');
357
+ const urlCommand = require('./davexcore/utility/url');
358
+ const { shortenUrlCommand } = require('./davexcore/utility/tinyurl');
359
+ const { analyzeCommand } = require('./davexcore/ai/analyze');
360
+ const encryptCommand = require('./davexcore/utility/encrypt');
361
+ const fetchCommand = require('./davexcore/utility/fetch');
362
+ const removebgCommand = require('./davexcore/media/removebg');
363
+ const { reminiCommand } = require('./davexcore/media/remini');
364
+ const { nightCommand, prettyCommand, uglyCommand } = require('./davexcore/media/imageedit');
365
+ const blurCommand = require('./davexcore/media/img-blur');
366
+ const textmakerCommand = require('./davexcore/media/textmaker');
367
+ const characterCommand = require('./davexcore/ai/character');
368
+ const wastedCommand = require('./davexcore/media/wasted');
369
+ const setProfilePicture = require('./davexcore/media/setpp');
370
+ const getppCommand = require('./davexcore/media/getpp');
371
+ const viewOnceCommand = require('./davexcore/media/viewonce');
372
+ const toAudioCommand = require('./davexcore/media/toAudio');
373
+ const setGroupStatusCommand = require('./davexcore/owner/setGroupStatus');
374
+ const imageCommand = require('./davexcore/media/image');
375
+ const hijackCommand = require('./davexcore/owner/hijack');
376
+
377
+ // === GAMES & FUN ===
378
+ const { startHangman, guessLetter } = require('./davexcore/games/hangman');
379
+ const { startTrivia, answerTrivia } = require('./davexcore/games/trivia');
380
+ const { tictactoeCommand, tictactoeAICommand, handleTicTacToeMove, handleTicTacToeJoin, tictactoeEndCommand } = require('./davexcore/games/tictactoe');
381
+ const { connectFourCommand, handleConnectFourMove } = require('./davexcore/games/connect4');
382
+ const { wcgCommand, wcgAICommand, wcgBeginCommand, wcgEndCommand, wcgScoresCommand, handleWcgJoin, handleWcgWord, hasWcgGame, hasWaitingWcgGame } = require('./davexcore/games/wordchain');
383
+ const { diceCommand, diceAICommand, handleDiceJoin, handleDiceBegin, handleDiceRoll, diceEndCommand, hasDiceGame } = require('./davexcore/games/dice');
384
+ const { acceptCommand, rejectCommand, acceptAllCommand, rejectAllCommand, listRequestsCommand } = require('./davexcore/group/joinrequests');
385
+ const tagAdminsCommand = require('./davexcore/group/tagadmins');
386
+ const onlineCommand = require('./davexcore/group/online');
387
+ const jokeCommand = require('./davexcore/misc/joke');
388
+ const quoteCommand = require('./davexcore/misc/quote');
389
+ const factCommand = require('./davexcore/misc/fact');
390
+ const { complimentCommand } = require('./davexcore/misc/compliment');
391
+ const { insultCommand } = require('./davexcore/misc/insult');
392
+ const { eightBallCommand } = require('./davexcore/games/eightball');
393
+ const { lyricsCommand } = require('./davexcore/utility/lyrics');
394
+ const { dareCommand } = require('./davexcore/misc/dare');
395
+ const { truthCommand } = require('./davexcore/misc/truth');
396
+ const { flirtCommand } = require('./davexcore/misc/flirt');
397
+ const shipCommand = require('./davexcore/games/ship');
398
+ const { simpCommand } = require('./davexcore/misc/simp');
399
+ const { stupidCommand } = require('./davexcore/misc/stupid');
400
+ const pairCommand = require('./davexcore/owner/pair');
401
+
402
+ // === UTILITIES ===
403
+ const deleteCommand = require('./davexcore/utility/delete');
404
+ const weatherCommand = require('./davexcore/utility/weather');
405
+ const newsCommand = require('./davexcore/utility/news');
406
+ const channelidCommand = require('./davexcore/owner/channelid');
407
+ const { chaneljidCommand } = require('./davexcore/owner/chanel');
408
+ const vcfCommand = require('./davexcore/utility/vcf');
409
+ const wallpaperCommand = require('./davexcore/media/wallpaper');
410
+ const takeCommand = require('./davexcore/media/take');
411
+ const clearTmpCommand = require('./davexcore/utility/cleartmp');
412
+ const { tostatusCommand } = require('./davexcore/media/tostatus');
413
+ const saveStatusCommand = require('./davexcore/downloads/saveStatus');
414
+ const vv2Command = require('./davexcore/media/vv2');
415
+ const { vnCommand } = require('./davexcore/media/vn');
416
+
417
+ // === MISC COMMANDS ===
418
+ const { miscCommand } = require('./davexcore/misc/misc');
419
+ const { goodnightCommand } = require('./davexcore/misc/goodnight');
420
+ const { shayariCommand } = require('./davexcore/misc/shayari');
421
+ const { rosedayCommand } = require('./davexcore/misc/roseday');
422
+
423
+ // === SPORTS ===
424
+ const {
425
+ eplStandingsCommand,
426
+ bundesligaStandingsCommand,
427
+ laligaStandingsCommand,
428
+ serieAStandingsCommand,
429
+ ligue1StandingsCommand,
430
+ matchesCommand
431
+ } = require('./davexcore/utility/sports');
432
+
433
+ // === RELIGIOUS ===
434
+ const {
435
+ bibleCommand,
436
+ bibleListCommand,
437
+ quranCommand
438
+ } = require('./davexcore/utility/bible');
439
+
440
+ // === DEV REACT ===
441
+ const handleDevReact = require('./davexcore/automation/devReact');
442
+
443
+ // === NEW COMMANDS ===
444
+ const joinCommand = require('./davexcore/utility/join');
445
+ const davexCommand = require('./davexcore/ai/davex');
446
+ const dalleCommand = require('./davexcore/ai/dalle');
447
+ const bardCommand = require('./davexcore/ai/bard');
448
+ const { llamaCommand, mixtralCommand, qwenCommand, claudeCommand, gpt4oCommand, gemmaCommand } = require('./davexcore/ai/aimodels');
449
+ const aivideoCommand = require('./davexcore/ai/aivideo');
450
+ const { goodmorningCommand, goodafternoonCommand, goodeveningCommand } = require('./davexcore/automation/greetings');
451
+ const { logoCommand, carbonCommand } = require('./davexcore/media/design');
452
+ const { tomp4Command } = require('./davexcore/media/tomp4');
453
+ const { togifCommand } = require('./davexcore/media/togif');
454
+ const toimgCommand = require('./davexcore/media/toimg');
455
+ const { ipLookupCommand, whoIsCommand, reverseipCommand } = require('./davexcore/utility/ethicalhacking');
456
+ const resetMenuImageCommand = require('./davexcore/owner/resetmenuimage');
457
+ const pinterestCommand = require('./davexcore/downloads/pinterest');
458
+ const rpsCommand = require('./davexcore/games/rps');
459
+ const slotCommand = require('./davexcore/games/slot');
460
+
461
+ // ========== GLOBAL SETTINGS ==========
462
+ global.packname = settings?.packname || "DAVE-X";
463
+ global.author = settings?.author || "DAVE-X BOT";
464
+ global.channelLink = "https://whatsapp.com/channel/0029VbApvFQ2Jl84lhONkc3k";
465
+ global.ytchanel = "";
466
+
467
+ const channelInfo = {};
468
+
469
+ // Override console.log with glitch frame for message logging
470
+ console.log = function(...args) {
471
+ // Skip if it's our custom logs (to avoid recursion)
472
+ if (args[0] && typeof args[0] === 'string' && args[0].includes('┌─────────────────')) {
473
+ originalConsoleLog.apply(console, args);
474
+ return;
475
+ }
476
+
477
+ // Check if this is a message/command log
478
+ const message = args.join(' ');
479
+ if (message.includes('[CMD]') || message.includes('[MSG]')) {
480
+ // These are handled separately in the message handler
481
+ originalConsoleLog.apply(console, args);
482
+ } else {
483
+ originalConsoleLog.apply(console, args);
484
+ }
485
+ };
486
+
487
+ // ========== MESSAGE HANDLER ==========
488
+ async function handleMessages(sock, messageUpdate, printLog) {
489
+ try {
490
+ global.sock = sock;
491
+
492
+ const { messages, type } = messageUpdate;
493
+ if (type !== 'notify') return;
494
+
495
+ const message = messages[0];
496
+ if (!message?.message) return;
497
+
498
+ if (!message._editedCommandOnly) {
499
+ // Handle automation features
500
+ await handleAutoread(sock, message);
501
+ await handleDevReact(sock, message);
502
+
503
+ // Store messages for anti-features
504
+ if (message.message) {
505
+ storeMessage(sock, message);
506
+ await storeStatusMessage(sock, message);
507
+ await handleAntiviewonce(sock, message);
508
+ }
509
+
510
+ // Store for antiedit tracking (edits handled via messages.update in index.js)
511
+ storeOriginalMessage(message);
512
+
513
+ // Handle status deletions
514
+ await handleStatusDeletion(sock, message);
515
+
516
+ if (message.message?.protocolMessage?.type === 14) {
517
+ const editUpdate = {
518
+ key: message.message.protocolMessage.key || message.key,
519
+ update: { message: message.message }
520
+ };
521
+ await handleEditedMessage(sock, editUpdate);
522
+ const _editedText = getEditedMessageText(message);
523
+ const _prefix = getPrefix();
524
+ const _isCommand = _editedText && (_prefix === '' || _editedText.startsWith(_prefix));
525
+ if (!_isCommand) return;
526
+ }
527
+
528
+ if (message.message?.protocolMessage?.type === 0) {
529
+ await handleMessageRevocation(sock, message);
530
+ return;
531
+ }
532
+ }
533
+
534
+ const chatId = message.key.remoteJid;
535
+ const senderId = message.key.participant || message.key.remoteJid;
536
+ let senderNumber = (senderId || '').split(':')[0].split('@')[0];
537
+
538
+ if (isLidJid(senderId)) {
539
+ try {
540
+ const resolved = await resolvePhoneFromLid(sock, senderId);
541
+ if (resolved && resolved !== senderNumber && /^\d{7,15}$/.test(resolved)) {
542
+ senderNumber = resolved;
543
+ }
544
+ } catch {}
545
+ }
546
+
547
+ const pushName = message.pushName || senderNumber;
548
+
549
+ const prefix = getPrefix();
550
+ const isPrefixless = prefix === '';
551
+ const isGroup = chatId.endsWith('@g.us');
552
+ const senderIsSudo = await isSudo(senderId);
553
+
554
+ const msgType = Object.keys(message.message || {}).find(k =>
555
+ k !== 'messageContextInfo' && k !== 'senderKeyDistributionMessage'
556
+ ) || 'unknown';
557
+
558
+ let userMessage = getMessageText(message);
559
+
560
+ // Check for edited messages
561
+ if (shouldProcessEditedMessage(message, prefix)) {
562
+ const editedText = getEditedMessageText(message);
563
+ if (editedText) {
564
+ userMessage = editedText;
565
+ console.log(chalk.cyan(`[EDIT] Processed edited message: ${userMessage}`));
566
+ }
567
+ }
568
+
569
+ let groupName = '';
570
+ if (isGroup) {
571
+ groupName = await getGroupName(sock, chatId);
572
+ }
573
+
574
+ // ========== GLITCH FRAME LOGGING FOR EVERY MESSAGE ==========
575
+ if (message.message) {
576
+ const mtype = Object.keys(message.message)[0].replace('Message', '').replace('ExtendedText', 'Text');
577
+ const messageContent = userMessage || mtype || 'Unknown';
578
+
579
+ console.log(chalk.bgHex('#0a0a0a').hex('#00ff00')('┌───────────────── MESSAGE ─────────────────┐'));
580
+ console.log(chalk.bgHex('#0a0a0a').hex('#ff00ff')(` ⚡ ${glitchText('INCOMING TRANSMISSION')}`));
581
+ console.log(chalk.bgHex('#0a0a0a').hex('#00ffff')('├─────────────────────────────────────────────┤'));
582
+
583
+ const entries = [
584
+ ['🕐', 'TIMESTAMP', new Date().toLocaleString()],
585
+ ['📡', 'CONTENT', messageContent.substring(0, 50) + (messageContent.length > 50 ? '...' : '')],
586
+ ['👤', 'USER', pushName],
587
+ ['🔢', 'NUMBER', `+${senderNumber}`], // Shows real number with + prefix
588
+ ...(isGroup ? [
589
+ ['👥', 'GROUP', groupName],
590
+ ['🔗', 'GROUP_ID', chatId.split('@')[0]]
591
+ ] : [
592
+ ['💬', 'CHAT', 'PRIVATE']
593
+ ]),
594
+ ['📱', 'TYPE', mtype]
595
+ ];
596
+
597
+ entries.forEach(([icon, label, value]) => {
598
+ console.log(
599
+ chalk.bgHex('#0a0a0a').hex('#ffff00')(` ${icon} `) +
600
+ chalk.bgHex('#0a0a0a').hex('#00ff00')(`${label}:`) +
601
+ chalk.bgHex('#0a0a0a').hex('#ffffff')(` ${value}`)
602
+ );
603
+ });
604
+
605
+ console.log(chalk.bgHex('#0a0a0a').hex('#00ff00')('└─────────────────────────────────────────────┘\n'));
606
+ }
607
+
608
+ const fake = createFakeContact(message);
609
+
610
+ // Check bot mode access
611
+ try {
612
+ const botMode = getBotMode();
613
+ if (botMode === 'group' && !isGroup) return;
614
+ if (botMode === 'pm' && isGroup) return;
615
+ if (botMode === 'private' && !message.key.fromMe && !senderIsSudo) return;
616
+ } catch (error) {
617
+ // Non-fatal — default to allowing all messages
618
+ }
619
+
620
+ // Check if user is banned
621
+ if (isBanned(senderId) && !userMessage.startsWith(`${prefix}unban`)) {
622
+ if (Math.random() < 0.1) {
623
+ await sock.sendMessage(chatId, {
624
+ text: 'You are banned from using the bot. Contact an admin to get unbanned.',
625
+ ...channelInfo
626
+ });
627
+ }
628
+ return;
629
+ }
630
+
631
+ // Handle game moves (Tic Tac Toe & Connect Four)
632
+ if (/^[1-9]$/.test(userMessage)) {
633
+ const tttResult = await handleTicTacToeMove(sock, chatId, senderId, userMessage);
634
+ if (!tttResult && parseInt(userMessage) <= 7) {
635
+ await handleConnectFourMove(sock, chatId, senderId, userMessage);
636
+ }
637
+ }
638
+
639
+ // Handle Word Chain game words (single words during active game)
640
+ if (hasWcgGame && hasWcgGame(chatId) && /^[a-zA-Z]+$/.test(userMessage.trim())) {
641
+ await handleWcgWord(sock, chatId, senderId, userMessage.trim(), fake);
642
+ }
643
+
644
+ // Increment message count for top members
645
+ if (!message.key.fromMe && !message._editedCommandOnly) incrementMessageCount(chatId, senderId);
646
+
647
+ // ====== ANTI FEATURES DETECTION ======
648
+ if (isGroup) {
649
+ // Run anti-link detection
650
+ await handleAntiLinkDetection(sock, message);
651
+
652
+ // Run anti status mention detection
653
+ await handleAntiStatusMention(sock, message);
654
+
655
+ // Check message type for anti-features
656
+ const isSticker = message.message?.stickerMessage;
657
+ const isImage = message.message?.imageMessage;
658
+ const isVideo = message.message?.videoMessage;
659
+ const isAudio = message.message?.audioMessage || message.message?.pttMessage;
660
+ const isDocument = message.message?.documentMessage;
661
+ const hasText = userMessage && userMessage.trim() !== '';
662
+
663
+ // Anti-sticker detection
664
+ if (isSticker) {
665
+ await handleStickerDetection(sock, chatId, message, senderId);
666
+ }
667
+
668
+ // Anti-image detection
669
+ if (isImage) {
670
+ await handleImageDetection(sock, chatId, message, senderId);
671
+ }
672
+
673
+ // Anti-video detection
674
+ if (isVideo) {
675
+ await handleVideoDetection(sock, chatId, message, senderId);
676
+ }
677
+
678
+ // Anti-audio detection
679
+ if (isAudio) {
680
+ await handleAudioDetection(sock, chatId, message, senderId);
681
+ }
682
+
683
+ // Anti-document detection
684
+ if (isDocument) {
685
+ await handleDocumentDetection(sock, chatId, message, senderId);
686
+ }
687
+
688
+ // Anti-files detection (for any file)
689
+ if (isSticker || isImage || isVideo || isAudio || isDocument) {
690
+ await handleFilesDetection(sock, chatId, message, senderId);
691
+ }
692
+
693
+ // ANTICHART DETECTION - runs on ALL message types (once)
694
+ await handleChartDetection(sock, chatId, message, senderId);
695
+
696
+ // Bug detection runs on ALL message types (not just text)
697
+ await handleBugDetection(sock, chatId, message, senderId);
698
+
699
+ // Run text-based detections
700
+ if (hasText) {
701
+ await handleBadwordDetection(sock, chatId, message, userMessage, senderId);
702
+ await handleNewMentionDetection(sock, chatId, message, senderId);
703
+ }
704
+ }
705
+ // ====== END ANTI FEATURES DETECTION ======
706
+
707
+ // PM Blocker check
708
+ if (!isGroup && !message.key.fromMe && !senderIsSudo) {
709
+ try {
710
+ const pmState = readPmBlockerState();
711
+ if (pmState.enabled) {
712
+ await sock.sendMessage(chatId, { text: pmState.message || 'Private messages are blocked. Please contact the owner in groups only.' });
713
+ try { await sock.updateBlockStatus(chatId, 'block'); } catch (e) { }
714
+ return;
715
+ }
716
+ } catch (e) { }
717
+ }
718
+
719
+ // Auto typing and recording features
720
+ if (isAutotypingEnabled()) {
721
+ await handleAutotypingForMessage(sock, chatId);
722
+ }
723
+
724
+ if (isAutorecordingEnabled()) {
725
+ await handleAutorecordingForMessage(sock, chatId);
726
+ }
727
+
728
+ if (userMessage) {
729
+ const lowerMsg = userMessage.trim().toLowerCase();
730
+ if (lowerMsg === 'resetprefix' || lowerMsg === 'getprefix' || lowerMsg === 'prefix') {
731
+ const currentPrefix = getPrefix() || '.';
732
+ const botName = getBotName();
733
+ const isOwner = message.key.fromMe || senderId === `${settings.ownerNumber}@s.whatsapp.net` || senderIsSudo;
734
+ if (lowerMsg === 'resetprefix' && isOwner) {
735
+ const { setPrefix } = require('./davexcore/owner/setprefix');
736
+ setPrefix('.');
737
+ await sock.sendMessage(chatId, { text: `*${botName}*\nPrefix has been reset to: .` }, { quoted: fake });
738
+ } else {
739
+ await sock.sendMessage(chatId, { text: `*${botName}*\nCurrent prefix: ${currentPrefix === '' ? 'None (prefixless)' : currentPrefix}\n\nType "resetprefix" to reset to default (.)` }, { quoted: fake });
740
+ }
741
+ return;
742
+ }
743
+ }
744
+
745
+ // Extract command
746
+ let command, args, fullArgs;
747
+ if (userMessage) {
748
+ const extracted = extractCommand(userMessage, prefix);
749
+ command = extracted.command;
750
+ args = extracted.args;
751
+ fullArgs = extracted.fullArgs;
752
+
753
+ if (command) {
754
+ const chatLabel = isGroup ? chatId.split('@')[0] : 'DM';
755
+ const typeLabel = msgType.replace('Message', '').replace('extendedText', 'text');
756
+ const cmdLine = `${prefix}${command}${fullArgs ? ' ' + fullArgs.substring(0, 50) + (fullArgs.length > 50 ? '...' : '') : ''}`;
757
+
758
+ // Command log with glitch frame
759
+ console.log(chalk.bgHex('#0a0a0a').hex('#00ff00')('┌───────────────── COMMAND ─────────────────┐'));
760
+ console.log(chalk.bgHex('#0a0a0a').hex('#ff00ff')(` ⚡ ${glitchText('COMMAND EXECUTED')}`));
761
+ console.log(chalk.bgHex('#0a0a0a').hex('#00ffff')('├─────────────────────────────────────────────┤'));
762
+
763
+ const cmdEntries = [
764
+ ['🕐', 'TIME', new Date().toLocaleString()],
765
+ ['⚡', 'COMMAND', `${prefix}${command}`],
766
+ ['📝', 'ARGS', fullArgs || 'None'],
767
+ ['👤', 'USER', pushName],
768
+ ['🔢', 'NUMBER', `+${senderNumber}`],
769
+ ['📍', 'CHAT', chatLabel],
770
+ ['📱', 'TYPE', typeLabel]
771
+ ];
772
+
773
+ cmdEntries.forEach(([icon, label, value]) => {
774
+ console.log(
775
+ chalk.bgHex('#0a0a0a').hex('#ffff00')(` ${icon} `) +
776
+ chalk.bgHex('#0a0a0a').hex('#00ff00')(`${label}:`) +
777
+ chalk.bgHex('#0a0a0a').hex('#ffffff')(` ${value}`)
778
+ );
779
+ });
780
+
781
+ console.log(chalk.bgHex('#0a0a0a').hex('#00ff00')('└─────────────────────────────────────────────┘\n'));
782
+ }
783
+ }
784
+
785
+ // If no command but has text, handle chatbot/tag detection
786
+ if (!command && userMessage) {
787
+ if (isGroup) {
788
+ await handleAntiLinkDetection(sock, message);
789
+ await handleChatbotResponse(sock, chatId, message, userMessage, senderId);
790
+ await handleTagDetection(sock, message);
791
+ await handleMentionDetection(sock, chatId, message);
792
+ }
793
+ return;
794
+ }
795
+
796
+ if (!command) return;
797
+
798
+ // Define command categories
799
+ const adminCommands = [
800
+ 'mute', 'unmute', 'ban', 'unban', 'promote', 'demote', 'kick',
801
+ 'linkgroup', 'linkgc', 'tagall', 'tagnotadmin', 'hidetag', 'antilink',
802
+ 'antitag', 'setgdesc', 'setgname', 'setgpp', 'antikick',
803
+ 'antipromote', 'antidemote', 'antibug', 'antigroupmention', 'groupmention',
804
+ 'antimention', 'antiaudio', 'antivideo', 'antidocument',
805
+ 'antifiles', 'antisticker', 'antiimage', 'antibadword',
806
+ 'antichart', 'antiforward', 'welcome', 'goodbye',
807
+ 'add', 'groupinfo', 'infogroup', 'infogrupo', 'admin', 'listadmin',
808
+ 'staff', 'reset', 'revoke', 'resetlink', 'tagadmins', 'admins',
809
+ 'accept', 'approve', 'reject', 'decline', 'acceptall', 'rejectall',
810
+ 'listrequests', 'requests', 'joinrequests', 'online',
811
+ 'warn', 'warnings', 'kickall', 'tag', 'clear',
812
+ 'chatbot', 'ship'
813
+ ];
814
+
815
+ const ownerCommands = [
816
+ 'mode', 'autostatus', 'antidelete', 'cleartmp', 'setpp',
817
+ 'tostatus', 'clearsession', 'areact', 'autoreact', 'autotyping',
818
+ 'autoread', 'pmblocker', 'setbotconfig', 'setbotname',
819
+ 'setmenuimage', 'setfont', 'font', 'hijack', 'pair', 'autorecording', 'chatbot',
820
+ 'autocall', 'broadcast', 'creategroup', 'setowner', 'setprefix',
821
+ 'vv2', 'antiedit', 'antiviewonce', 'antideletestatus', 'sad', 'ads', 'startupwelcome',
822
+ 'alwaysonline', 'alwaysoffline', 'pin', 'unpin', 'archive',
823
+ 'unarchive', 'disappearing', 'readreceipts', 'autoreadreceipts',
824
+ 'setbio', 'bio', 'removebio', 'resetbio', 'clearbio',
825
+ 'pinchat', 'pinconvo', 'unpinchat', 'unpinconvo',
826
+ 'disappear', 'ephemeral', 'menuset', 'menuconfig', 'menustyle'
827
+ ];
828
+
829
+ const isAdminCommand = adminCommands.includes(command);
830
+ const isOwnerCommand = ownerCommands.includes(command);
831
+
832
+ if (!isGroup && isAdminCommand) {
833
+ await sock.sendMessage(chatId, {
834
+ text: 'This command can only be used in groups, not in private chats!'
835
+ }, { quoted: fake });
836
+ return;
837
+ }
838
+
839
+ let isSenderAdmin = false;
840
+ let isBotAdmin = false;
841
+
842
+ if (isGroup && isAdminCommand) {
843
+ const adminStatus = await isAdmin(sock, chatId, senderId, message);
844
+ isSenderAdmin = adminStatus.isSenderAdmin;
845
+ isBotAdmin = adminStatus.isBotAdmin;
846
+
847
+ if (!isBotAdmin && command !== 'welcome' && command !== 'goodbye') {
848
+ await sock.sendMessage(chatId, { text: 'Please make the bot an admin to use admin commands.' }, { quoted: fake });
849
+ return;
850
+ }
851
+
852
+ if (
853
+ ['mute', 'unmute', 'ban', 'unban', 'promote', 'demote', 'kick', 'hijack',
854
+ 'antilink', 'antitag', 'antikick', 'antipromote', 'antidemote', 'antibug',
855
+ 'antigroupmention', 'groupmention', 'antimention', 'antiaudio', 'antivideo', 'antidocument',
856
+ 'antifiles', 'antisticker', 'antiimage', 'antibadword', 'antichart', 'antiforward', 'add',
857
+ 'kickall', 'resetlink', 'reset', 'revoke', 'setgdesc', 'setgname', 'setgpp',
858
+ 'accept', 'approve', 'reject', 'decline', 'acceptall', 'rejectall',
859
+ 'listrequests', 'requests', 'joinrequests', 'warn'].includes(command)
860
+ ) {
861
+ if (!isSenderAdmin && !message.key.fromMe) {
862
+ await sock.sendMessage(chatId, {
863
+ text: 'Sorry, only group admins can use this command.',
864
+ ...channelInfo
865
+ }, { quoted: fake });
866
+ return;
867
+ }
868
+ }
869
+ }
870
+
871
+ if (isOwnerCommand) {
872
+ if (!message.key.fromMe && !senderIsSudo) {
873
+ await sock.sendMessage(chatId, { text: 'This command is only available for the owner or sudo!' }, { quoted: fake });
874
+ return;
875
+ }
876
+ }
877
+
878
+ let commandExecuted = false;
879
+
880
+ // ========== COMMAND SWITCH CASE ==========
881
+ switch (command) {
882
+ // === BOT MANAGEMENT ===
883
+ case 'setprefix':
884
+ await handleSetPrefixCommand(sock, chatId, message);
885
+ commandExecuted = true;
886
+ break;
887
+
888
+ case 'setowner':
889
+ await handleSetOwnerCommand(sock, chatId, senderId, message, userMessage, prefix);
890
+ commandExecuted = true;
891
+ break;
892
+
893
+ case 'owner':
894
+ await ownerCommand(sock, chatId);
895
+ commandExecuted = true;
896
+ break;
897
+
898
+ case 'ping':
899
+ case 'p':
900
+ await pingCommand(sock, chatId, message);
901
+ commandExecuted = true;
902
+ break;
903
+
904
+ case 'uptime':
905
+ case 'alive':
906
+ case 'up':
907
+ case 'runtime':
908
+ await aliveCommand(sock, chatId, message);
909
+ commandExecuted = true;
910
+ break;
911
+
912
+ case 'help':
913
+ case 'menu':
914
+ case 'h':
915
+ case 'allmenu':
916
+ await helpCommand(sock, chatId, message);
917
+ commandExecuted = true;
918
+ break;
919
+
920
+ case 'menuconfig':
921
+ case 'menustyle':
922
+ case 'menuset':
923
+ case 'setmenu':
924
+ await menuManageCommand(sock, chatId, message, args);
925
+ commandExecuted = true;
926
+ break;
927
+
928
+ case 'settings':
929
+ case 'getsettings':
930
+ await settingsCommand(sock, chatId, message);
931
+ commandExecuted = true;
932
+ break;
933
+
934
+ case 'sudo':
935
+ case 'addsudo':
936
+ case 'delsudo':
937
+ case 'removesudo':
938
+ case 'listsudo':
939
+ if (command === 'addsudo') {
940
+ const rawText = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
941
+ const rest = rawText.trim().split(/\s+/).slice(1).join(' ');
942
+ message.message = message.message || {};
943
+ if (message.message.conversation !== undefined) {
944
+ message.message.conversation = `${prefix}sudo add ${rest}`;
945
+ } else if (message.message.extendedTextMessage) {
946
+ message.message.extendedTextMessage.text = `${prefix}sudo add ${rest}`;
947
+ }
948
+ } else if (command === 'delsudo' || command === 'removesudo') {
949
+ const rawText = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
950
+ const rest = rawText.trim().split(/\s+/).slice(1).join(' ');
951
+ message.message = message.message || {};
952
+ if (message.message.conversation !== undefined) {
953
+ message.message.conversation = `${prefix}sudo del ${rest}`;
954
+ } else if (message.message.extendedTextMessage) {
955
+ message.message.extendedTextMessage.text = `${prefix}sudo del ${rest}`;
956
+ }
957
+ } else if (command === 'listsudo') {
958
+ message.message = message.message || {};
959
+ if (message.message.conversation !== undefined) {
960
+ message.message.conversation = `${prefix}sudo list`;
961
+ } else if (message.message.extendedTextMessage) {
962
+ message.message.extendedTextMessage.text = `${prefix}sudo list`;
963
+ }
964
+ }
965
+ await sudoCommand(sock, chatId, message);
966
+ commandExecuted = true;
967
+ break;
968
+
969
+ case 'clearsession':
970
+ case 'clearsesi':
971
+ await clearSessionCommand(sock, chatId, message);
972
+ commandExecuted = true;
973
+ break;
974
+
975
+ case 'mode':
976
+ {
977
+ if (!message.key.fromMe && !senderIsSudo) {
978
+ await sock.sendMessage(chatId, {
979
+ text: `✦ Only the owner can change bot mode`
980
+ }, { quoted: fake });
981
+ return;
982
+ }
983
+
984
+ const action = args[0]?.toLowerCase();
985
+ const validModes = ['private', 'public', 'group', 'pm'];
986
+
987
+ const modeDescriptions = {
988
+ private: `Now only you can use the bot`,
989
+ public: `Everyone can now use the bot`,
990
+ group: `Bot will now only work in groups`,
991
+ pm: `Bot will now only work in private chats`
992
+ };
993
+
994
+ if (!action) {
995
+ const currentMode = getBotMode();
996
+ await sock.sendMessage(chatId, {
997
+ text: `✦ Current mode: ${currentMode}
998
+
999
+ To change mode:
1000
+ ${prefix}mode private
1001
+ ${prefix}mode public
1002
+ ${prefix}mode group
1003
+ ${prefix}mode pm
1004
+
1005
+ Example: ${prefix}mode group`
1006
+ }, { quoted: fake });
1007
+ return;
1008
+ }
1009
+
1010
+ if (!validModes.includes(action)) {
1011
+ await sock.sendMessage(chatId, {
1012
+ text: `✦ Use one of these: private, public, group, pm
1013
+
1014
+ Example: ${prefix}mode group`
1015
+ }, { quoted: fake });
1016
+ return;
1017
+ }
1018
+
1019
+ try {
1020
+ setBotMode(action);
1021
+ await sock.sendMessage(chatId, {
1022
+ text: `✦ Mode set to ${action}\n${modeDescriptions[action]}`
1023
+ }, { quoted: fake });
1024
+ } catch (error) {
1025
+ console.error('Error updating access mode:', error);
1026
+ await sock.sendMessage(chatId, {
1027
+ text: `✦ Something went wrong updating the mode`
1028
+ }, { quoted: fake });
1029
+ }
1030
+ }
1031
+ commandExecuted = true;
1032
+ break;
1033
+ case 'update':
1034
+ case 'start':
1035
+ case 'restart':
1036
+ {
1037
+ const zipArg = args[0] && args[0].startsWith('http') ? args[0] : '';
1038
+ await updateCommand(sock, chatId, message, senderIsSudo, zipArg);
1039
+ }
1040
+ commandExecuted = true;
1041
+ break;
1042
+
1043
+ // === MODERATION COMMANDS ===
1044
+ case 'ban':
1045
+ await banCommand(sock, chatId, message);
1046
+ commandExecuted = true;
1047
+ break;
1048
+
1049
+ case 'unban':
1050
+ await unbanCommand(sock, chatId, message);
1051
+ commandExecuted = true;
1052
+ break;
1053
+
1054
+ case 'mute':
1055
+ {
1056
+ const muteArg = args[0];
1057
+ const muteDuration = muteArg !== undefined ? parseInt(muteArg, 10) : undefined;
1058
+ if (muteArg !== undefined && (isNaN(muteDuration) || muteDuration <= 0)) {
1059
+ await sock.sendMessage(chatId, { text: 'Please provide a valid number of minutes or use .mute with no number to mute immediately.' }, { quoted: fake });
1060
+ } else {
1061
+ await muteCommand(sock, chatId, senderId, message, muteDuration);
1062
+ }
1063
+ }
1064
+ commandExecuted = true;
1065
+ break;
1066
+
1067
+ case 'unmute':
1068
+ await unmuteCommand(sock, chatId, senderId);
1069
+ commandExecuted = true;
1070
+ break;
1071
+
1072
+ case 'kick':
1073
+ const mentionedJidListKick = message.message.extendedTextMessage?.contextInfo?.mentionedJid || [];
1074
+ await kickCommand(sock, chatId, senderId, mentionedJidListKick, message);
1075
+ commandExecuted = true;
1076
+ break;
1077
+
1078
+ case 'warn':
1079
+ const mentionedJidListWarn = message.message.extendedTextMessage?.contextInfo?.mentionedJid || [];
1080
+ await warnCommand(sock, chatId, senderId, mentionedJidListWarn, message);
1081
+ commandExecuted = true;
1082
+ break;
1083
+
1084
+ case 'warnings':
1085
+ const mentionedJidListWarnings = message.message.extendedTextMessage?.contextInfo?.mentionedJid || [];
1086
+ await warningsCommand(sock, chatId, mentionedJidListWarnings);
1087
+ commandExecuted = true;
1088
+ break;
1089
+
1090
+ case 'promote':
1091
+ const mentionedJidListPromote = message.message.extendedTextMessage?.contextInfo?.mentionedJid || [];
1092
+ await promoteCommand(sock, chatId, mentionedJidListPromote, message);
1093
+ commandExecuted = true;
1094
+ break;
1095
+
1096
+ case 'demote':
1097
+ const mentionedJidListDemote = message.message.extendedTextMessage?.contextInfo?.mentionedJid || [];
1098
+ await demoteCommand(sock, chatId, mentionedJidListDemote, message);
1099
+ commandExecuted = true;
1100
+ break;
1101
+
1102
+ case 'clear':
1103
+ if (isGroup) await clearCommand(sock, chatId);
1104
+ commandExecuted = true;
1105
+ break;
1106
+
1107
+ case 'removeall':
1108
+ case 'killall':
1109
+ await kickAllCommand(sock, chatId, message);
1110
+ commandExecuted = true;
1111
+ break;
1112
+
1113
+ case 'block':
1114
+ await blockCommand(sock, chatId, message);
1115
+ commandExecuted = true;
1116
+ break;
1117
+ case 'lastseen':
1118
+ await lastseenCommand(sock, chatId, message);
1119
+ commandExecuted = true;
1120
+ break;
1121
+ case 'unblock':
1122
+ await unblockCommand(sock, chatId, message);
1123
+ commandExecuted = true;
1124
+ break;
1125
+
1126
+ case 'blocklist':
1127
+ case 'listblock':
1128
+ await blocklistCommand(sock, chatId, message);
1129
+ commandExecuted = true;
1130
+ break;
1131
+
1132
+ case 'removepp':
1133
+ case 'removeprofilepic':
1134
+ case 'removepfp':
1135
+ await removeProfilePicCommand(sock, chatId, message);
1136
+ commandExecuted = true;
1137
+ break;
1138
+
1139
+ case 'ppnone':
1140
+ case 'profilepicnone':
1141
+ case 'pfpnone':
1142
+ await setProfilePicPrivacyCommand(sock, chatId, message, 'none');
1143
+ commandExecuted = true;
1144
+ break;
1145
+
1146
+ case 'ppall':
1147
+ case 'profilepicall':
1148
+ case 'pfpall':
1149
+ await setProfilePicPrivacyCommand(sock, chatId, message, 'all');
1150
+ commandExecuted = true;
1151
+ break;
1152
+
1153
+ case 'ppcontacts':
1154
+ case 'profilepiccontacts':
1155
+ await setProfilePicPrivacyCommand(sock, chatId, message, 'contacts');
1156
+ commandExecuted = true;
1157
+ break;
1158
+
1159
+ case 'pp':
1160
+ case 'profilepic': {
1161
+ const ppArg = (fullArgs || '').trim().toLowerCase();
1162
+ if (ppArg === 'all') {
1163
+ await setProfilePicPrivacyCommand(sock, chatId, message, 'all');
1164
+ } else if (ppArg === 'none') {
1165
+ await setProfilePicPrivacyCommand(sock, chatId, message, 'none');
1166
+ } else if (ppArg === 'contacts') {
1167
+ await setProfilePicPrivacyCommand(sock, chatId, message, 'contacts');
1168
+ } else {
1169
+ const _bn = getBotName();
1170
+ const _fk = createFakeContact(message);
1171
+ await sock.sendMessage(chatId, {
1172
+ text: `✦ *${_bn}* | Profile Pic Privacy\n\n.pp all — everyone can see\n.pp none — nobody can see\n.pp contacts — contacts only\n.removepp — remove profile picture`
1173
+ }, { quoted: _fk });
1174
+ }
1175
+ commandExecuted = true;
1176
+ break;
1177
+ }
1178
+
1179
+ // === GROUP MANAGEMENT ===
1180
+ case 'groupinfo':
1181
+ case 'infogroup':
1182
+ case 'infogrupo':
1183
+ await groupInfoCommand(sock, chatId, message);
1184
+ commandExecuted = true;
1185
+ break;
1186
+
1187
+ case 'admin':
1188
+ case 'listadmin':
1189
+ case 'staff':
1190
+ await staffCommand(sock, chatId, message);
1191
+ commandExecuted = true;
1192
+ break;
1193
+
1194
+ case 'reset':
1195
+ case 'revoke':
1196
+ case 'resetlink':
1197
+ await resetlinkCommand(sock, chatId, senderId);
1198
+ commandExecuted = true;
1199
+ break;
1200
+
1201
+ case 'linkgroup':
1202
+ case 'linkgc':
1203
+ await linkgroupCommand(sock, chatId, message);
1204
+ commandExecuted = true;
1205
+ break;
1206
+
1207
+ case 'creategroup':
1208
+ case 'creategc':
1209
+ await creategroupCommand(sock, chatId, message);
1210
+ commandExecuted = true;
1211
+ break;
1212
+
1213
+ case 'join':
1214
+ await joinCommand(sock, chatId, message);
1215
+ commandExecuted = true;
1216
+ break;
1217
+
1218
+ case 'left':
1219
+ case 'leave':
1220
+ await leaveGroupCommand(sock, chatId, message);
1221
+ commandExecuted = true;
1222
+ break;
1223
+
1224
+ case 'setgdesc':
1225
+ await setGroupDescription(sock, chatId, senderId, fullArgs, message);
1226
+ commandExecuted = true;
1227
+ break;
1228
+
1229
+ case 'setgname':
1230
+ case 'setgroupname':
1231
+ case 'groupname':
1232
+ await setGroupName(sock, chatId, senderId, fullArgs, message);
1233
+ commandExecuted = true;
1234
+ break;
1235
+
1236
+ case 'setgpp':
1237
+ await setGroupPhoto(sock, chatId, senderId, message);
1238
+ commandExecuted = true;
1239
+ break;
1240
+
1241
+ case 'tagall':
1242
+ if (isSenderAdmin || message.key.fromMe) {
1243
+ await tagAllCommand(sock, chatId, senderId, message);
1244
+ } else {
1245
+ await sock.sendMessage(chatId, { text: '_Only admins can use this command_' }, { quoted: fake });
1246
+ }
1247
+ commandExecuted = true;
1248
+ break;
1249
+
1250
+ case 'tagnotadmin':
1251
+ await tagNotAdminCommand(sock, chatId, senderId, message);
1252
+ commandExecuted = true;
1253
+ break;
1254
+ case 'hidetag':
1255
+ {
1256
+ const messageText = fullArgs;
1257
+ const replyMessage = message.message?.extendedTextMessage?.contextInfo?.quotedMessage || null;
1258
+ await hideTagCommand(sock, chatId, senderId, messageText, replyMessage, message);
1259
+ }
1260
+ commandExecuted = true;
1261
+ break;
1262
+
1263
+ case 'tag':
1264
+ const messageText = fullArgs;
1265
+ const replyMessage = message.message?.extendedTextMessage?.contextInfo?.quotedMessage || null;
1266
+ await tagCommand(sock, chatId, senderId, messageText, replyMessage, message);
1267
+ commandExecuted = true;
1268
+ break;
1269
+
1270
+ case 'tagadmins':
1271
+ case 'admins':
1272
+ await tagAdminsCommand(sock, chatId, senderId, message, fullArgs);
1273
+ commandExecuted = true;
1274
+ break;
1275
+
1276
+ case 'online':
1277
+ await onlineCommand(sock, chatId, senderId, message);
1278
+ commandExecuted = true;
1279
+ break;
1280
+
1281
+ case 'accept':
1282
+ case 'approve':
1283
+ await acceptCommand(sock, chatId, senderId, fullArgs, message, fake);
1284
+ commandExecuted = true;
1285
+ break;
1286
+
1287
+ case 'reject':
1288
+ case 'decline':
1289
+ await rejectCommand(sock, chatId, senderId, fullArgs, message, fake);
1290
+ commandExecuted = true;
1291
+ break;
1292
+
1293
+ case 'acceptall':
1294
+ await acceptAllCommand(sock, chatId, senderId, message, fake);
1295
+ commandExecuted = true;
1296
+ break;
1297
+
1298
+ case 'rejectall':
1299
+ await rejectAllCommand(sock, chatId, senderId, message, fake);
1300
+ commandExecuted = true;
1301
+ break;
1302
+
1303
+ case 'listrequests':
1304
+ case 'requests':
1305
+ case 'joinrequests':
1306
+ await listRequestsCommand(sock, chatId, senderId, message, fake);
1307
+ commandExecuted = true;
1308
+ break;
1309
+
1310
+ case 'add':
1311
+ await addMemberCommand(sock, chatId, message, fullArgs, prefix, senderId, isSenderAdmin, isBotAdmin, isGroup);
1312
+ commandExecuted = true;
1313
+ break;
1314
+
1315
+ // === ANTI-FEATURES ===
1316
+ case 'antilink':
1317
+ const antilinkAdminStatus = await isAdmin(sock, chatId, senderId);
1318
+ const antilinkIsSenderAdmin = antilinkAdminStatus.isSenderAdmin;
1319
+ const antilinkIsBotAdmin = antilinkAdminStatus.isBotAdmin;
1320
+
1321
+ if (!antilinkIsBotAdmin) {
1322
+ await sock.sendMessage(chatId, {
1323
+ text: '❌ Bot must be admin to use anti-link!'
1324
+ }, { quoted: fake });
1325
+ return;
1326
+ }
1327
+
1328
+ const antilinkSubCmd = args[0]?.toLowerCase();
1329
+ if (!['status', 'help'].includes(antilinkSubCmd) && !antilinkIsSenderAdmin && !message.key.fromMe) {
1330
+ await sock.sendMessage(chatId, {
1331
+ text: '❌ Only group admins can configure anti-link!'
1332
+ }, { quoted: fake });
1333
+ return;
1334
+ }
1335
+
1336
+ await handleAntilinkCommand(sock, chatId, userMessage, senderId, antilinkIsSenderAdmin);
1337
+ commandExecuted = true;
1338
+ break;
1339
+
1340
+ case 'antigroupmention':
1341
+ case 'groupmention':
1342
+ const agmAdminStatus = await isAdmin(sock, chatId, senderId);
1343
+ const agmIsSenderAdmin = agmAdminStatus.isSenderAdmin;
1344
+ const agmIsBotAdmin = agmAdminStatus.isBotAdmin;
1345
+
1346
+ if (!agmIsBotAdmin) {
1347
+ await sock.sendMessage(chatId, {
1348
+ text: '❌ Bot must be admin to use anti-group mention!'
1349
+ }, { quoted: fake });
1350
+ return;
1351
+ }
1352
+
1353
+ if (!agmIsSenderAdmin && !message.key.fromMe) {
1354
+ await sock.sendMessage(chatId, {
1355
+ text: '❌ Only group admins can configure anti-group mention!'
1356
+ }, { quoted: fake });
1357
+ return;
1358
+ }
1359
+
1360
+ await antigroupmentionCommand(sock, chatId, message, senderId);
1361
+ commandExecuted = true;
1362
+ break;
1363
+
1364
+ case 'antichart':
1365
+ case 'antiforward':
1366
+ const antichartAdminStatus = await isAdmin(sock, chatId, senderId);
1367
+ const antichartIsSenderAdmin = antichartAdminStatus.isSenderAdmin;
1368
+ const antichartIsBotAdmin = antichartAdminStatus.isBotAdmin;
1369
+
1370
+ if (!antichartIsBotAdmin) {
1371
+ await sock.sendMessage(chatId, {
1372
+ text: '❌ Bot must be admin to use anti-chart!'
1373
+ }, { quoted: fake });
1374
+ return;
1375
+ }
1376
+
1377
+ if (!antichartIsSenderAdmin && !message.key.fromMe) {
1378
+ await sock.sendMessage(chatId, {
1379
+ text: '❌ Only group admins can configure anti-chart!'
1380
+ }, { quoted: fake });
1381
+ return;
1382
+ }
1383
+
1384
+ await antichartCommand(sock, chatId, message, senderId, antichartIsSenderAdmin, fullArgs);
1385
+ commandExecuted = true;
1386
+ break;
1387
+
1388
+ case 'antitag':
1389
+ if (!isBotAdmin) {
1390
+ await sock.sendMessage(chatId, {
1391
+ text: 'Please make the bot an admin first.',
1392
+ ...channelInfo
1393
+ }, { quoted: fake });
1394
+ return;
1395
+ }
1396
+ await handleAntitagCommand(sock, chatId, userMessage, senderId, isSenderAdmin, message);
1397
+ commandExecuted = true;
1398
+ break;
1399
+
1400
+ case 'antiedit':
1401
+ if (!message.key.fromMe && !senderIsSudo) {
1402
+ await sock.sendMessage(chatId, {
1403
+ text: `Owner only command!`
1404
+ }, { quoted: fake });
1405
+ return;
1406
+ }
1407
+ await antieditCommand(sock, chatId, message, fullArgs);
1408
+ commandExecuted = true;
1409
+ break;
1410
+
1411
+ case 'antideletestatus':
1412
+ case 'antistatus delete':
1413
+ case 'ads':
1414
+ if (!message.key.fromMe && !senderIsSudo) {
1415
+ await sock.sendMessage(chatId, {
1416
+ text: '❌ This command is only available for the owner or sudo!'
1417
+ }, { quoted: fake });
1418
+ return;
1419
+ }
1420
+ await handleStatusAntideleteCommand(sock, chatId, message, fullArgs);
1421
+ commandExecuted = true;
1422
+ break;
1423
+
1424
+ case 'antidelete':
1425
+ await handleAntideleteCommand(sock, chatId, message, fullArgs);
1426
+ commandExecuted = true;
1427
+ break;
1428
+
1429
+ case 'antiviewonce':
1430
+ await antiviewonceCommand(sock, chatId, message, fullArgs);
1431
+ commandExecuted = true;
1432
+ break;
1433
+
1434
+ case 'mention':
1435
+ {
1436
+ const isOwner = message.key.fromMe || senderIsSudo;
1437
+ await mentionToggleCommand(sock, chatId, message, fullArgs, isOwner);
1438
+ }
1439
+ commandExecuted = true;
1440
+ break;
1441
+
1442
+ case 'setmention':
1443
+ {
1444
+ const isOwner = message.key.fromMe || senderIsSudo;
1445
+ await setMentionCommand(sock, chatId, message, isOwner);
1446
+ }
1447
+ commandExecuted = true;
1448
+ break;
1449
+
1450
+ case 'antibadword':
1451
+ await antibadwordCommand(sock, chatId, message, fullArgs);
1452
+ commandExecuted = true;
1453
+ break;
1454
+
1455
+ case 'antimention':
1456
+ await antimentionCommand(sock, chatId, message, senderId);
1457
+ commandExecuted = true;
1458
+ break;
1459
+
1460
+ case 'antipromote':
1461
+ await antipromoteCommand(sock, chatId, message, senderId);
1462
+ commandExecuted = true;
1463
+ break;
1464
+
1465
+ case 'antidemote':
1466
+ await antidemoteCommand(sock, chatId, message, senderId);
1467
+ commandExecuted = true;
1468
+ break;
1469
+
1470
+ case 'antibug':
1471
+ await antibugCommand(sock, chatId, userMessage, senderId, isSenderAdmin, message);
1472
+ commandExecuted = true;
1473
+ break;
1474
+
1475
+ case 'antikick':
1476
+ await antikickCommand(sock, chatId, message, senderId, isSenderAdmin);
1477
+ commandExecuted = true;
1478
+ break;
1479
+
1480
+ case 'antiaudio':
1481
+ await antiaudioCommand(sock, chatId, userMessage, senderId, isSenderAdmin, message);
1482
+ commandExecuted = true;
1483
+ break;
1484
+
1485
+ case 'antivideo':
1486
+ await antivideoCommand(sock, chatId, userMessage, senderId, isSenderAdmin, message);
1487
+ commandExecuted = true;
1488
+ break;
1489
+
1490
+ case 'antidocument':
1491
+ await antidocumentCommand(sock, chatId, userMessage, senderId, isSenderAdmin, message);
1492
+ commandExecuted = true;
1493
+ break;
1494
+
1495
+ case 'antifiles':
1496
+ await antifilesCommand(sock, chatId, userMessage, senderId, isSenderAdmin, message);
1497
+ commandExecuted = true;
1498
+ break;
1499
+
1500
+ case 'antisticker':
1501
+ await antistickerCommand(sock, chatId, userMessage, senderId, isSenderAdmin, message);
1502
+ commandExecuted = true;
1503
+ break;
1504
+
1505
+ case 'antiimage':
1506
+ await antiimageCommand(sock, chatId, userMessage, senderId, isSenderAdmin, message);
1507
+ commandExecuted = true;
1508
+ break;
1509
+
1510
+ // === AUTOMATION FEATURES ===
1511
+ case 'autotyping':
1512
+ await autotypingCommand(sock, chatId, message);
1513
+ commandExecuted = true;
1514
+ break;
1515
+
1516
+ case 'autoread':
1517
+ await autoreadCommand(sock, chatId, message);
1518
+ commandExecuted = true;
1519
+ break;
1520
+
1521
+ case 'autorecording':
1522
+ await autorecordingCommand(sock, chatId, message);
1523
+ commandExecuted = true;
1524
+ break;
1525
+
1526
+ case 'alwaysonline':
1527
+ await alwaysonlineCommand(sock, chatId, message);
1528
+ commandExecuted = true;
1529
+ break;
1530
+ case 'offline':
1531
+ case 'alwaysoffline':
1532
+ await alwaysofflineCommand(sock, chatId, message);
1533
+ commandExecuted = true;
1534
+ break;
1535
+
1536
+ case 'pin':
1537
+ await pinCommand(sock, chatId, message);
1538
+ commandExecuted = true;
1539
+ break;
1540
+
1541
+ case 'unpin':
1542
+ await unpinCommand(sock, chatId, message);
1543
+ commandExecuted = true;
1544
+ break;
1545
+
1546
+ case 'archive':
1547
+ await archiveCommand(sock, chatId, message);
1548
+ commandExecuted = true;
1549
+ break;
1550
+
1551
+ case 'unarchive':
1552
+ await unarchiveCommand(sock, chatId, message);
1553
+ commandExecuted = true;
1554
+ break;
1555
+
1556
+ case 'disappearing':
1557
+ await disappearCommand(sock, chatId, message, args);
1558
+ commandExecuted = true;
1559
+ break;
1560
+
1561
+ case 'readreceipts':
1562
+ case 'autoreadreceipts':
1563
+ await autoreadReceiptsCommand(sock, chatId, message);
1564
+ commandExecuted = true;
1565
+ break;
1566
+
1567
+ case 'autostatus':
1568
+ case 'autoviewstatus':
1569
+ case 'autostatusview':
1570
+ await autoStatusCommand(sock, chatId, message, args);
1571
+ commandExecuted = true;
1572
+ break;
1573
+
1574
+ case 'welcome':
1575
+ if (isGroup) {
1576
+ if (!isSenderAdmin) {
1577
+ const adminStatus = await isAdmin(sock, chatId, senderId);
1578
+ isSenderAdmin = adminStatus.isSenderAdmin;
1579
+ }
1580
+
1581
+ if (isSenderAdmin || message.key.fromMe) {
1582
+ await welcomeCommand(sock, chatId, message);
1583
+ } else {
1584
+ await sock.sendMessage(chatId, { text: 'Sorry, only group admins can use this command.' }, { quoted: fake });
1585
+ }
1586
+ } else {
1587
+ await sock.sendMessage(chatId, { text: 'This command can only be used in groups.' }, { quoted: fake });
1588
+ }
1589
+ commandExecuted = true;
1590
+ break;
1591
+
1592
+ case 'goodbye':
1593
+ if (isGroup) {
1594
+ if (!isSenderAdmin) {
1595
+ const adminStatus = await isAdmin(sock, chatId, senderId);
1596
+ isSenderAdmin = adminStatus.isSenderAdmin;
1597
+ }
1598
+
1599
+ if (isSenderAdmin || message.key.fromMe) {
1600
+ await goodbyeCommand(sock, chatId, message);
1601
+ } else {
1602
+ await sock.sendMessage(chatId, { text: 'Sorry, only group admins can use this command.' }, { quoted: fake });
1603
+ }
1604
+ } else {
1605
+ await sock.sendMessage(chatId, { text: 'This command can only be used in groups.' }, { quoted: fake });
1606
+ }
1607
+ commandExecuted = true;
1608
+ break;
1609
+
1610
+ case 'chatbot':
1611
+ const chatbotAdminStatus = await isAdmin(sock, chatId, senderId);
1612
+ if (!chatbotAdminStatus.isSenderAdmin && !message.key.fromMe) {
1613
+ await sock.sendMessage(chatId, { text: '*Only admins or bot owner can use this command*' }, { quoted: fake });
1614
+ return;
1615
+ }
1616
+ await handleChatbotCommand(sock, chatId, message, fullArgs);
1617
+ commandExecuted = true;
1618
+ break;
1619
+
1620
+ case 'topmembers':
1621
+ topMembers(sock, chatId, isGroup, message);
1622
+ commandExecuted = true;
1623
+ break;
1624
+
1625
+ case 'pmblocker':
1626
+ if (!message.key.fromMe && !senderIsSudo) {
1627
+ await sock.sendMessage(chatId, { text: 'Only owner or sudo can use pmblocker.' }, { quoted: fake });
1628
+ commandExecuted = true;
1629
+ break;
1630
+ }
1631
+ await pmblockerCommand(sock, chatId, message, fullArgs);
1632
+ commandExecuted = true;
1633
+ break;
1634
+
1635
+ case 'anticall':
1636
+ if (!message.key.fromMe && !senderIsSudo) {
1637
+ await sock.sendMessage(chatId, { text: 'Only owner/sudo can use anticall.' }, { quoted: fake });
1638
+ break;
1639
+ }
1640
+ await anticallCommand(sock, chatId, message, fullArgs);
1641
+ commandExecuted = true;
1642
+ break;
1643
+
1644
+ case 'setcallmsg':
1645
+ if (!message.key.fromMe && !senderIsSudo) {
1646
+ await sock.sendMessage(chatId, { text: 'Only owner/sudo can use setcallmsg.' }, { quoted: fake });
1647
+ break;
1648
+ }
1649
+ await setcallmsgCommand(sock, chatId, message, fullArgs);
1650
+ commandExecuted = true;
1651
+ break;
1652
+
1653
+ case 'groupanticall':
1654
+ case 'gcanticall':
1655
+ case 'ganticall':
1656
+ await groupanticallCommand(sock, chatId, message, fullArgs);
1657
+ commandExecuted = true;
1658
+ break;
1659
+
1660
+ case 'startupwelcome':
1661
+ case 'startupmsg':
1662
+ await startupWelcomeCommand(sock, chatId, message);
1663
+ commandExecuted = true;
1664
+ break;
1665
+
1666
+ case 'broadcast':
1667
+ case 'bc':
1668
+ await broadcastCommand(sock, chatId, message);
1669
+ commandExecuted = true;
1670
+ break;
1671
+
1672
+ case 'areact':
1673
+ case 'autoreact':
1674
+ case 'autoreaction':
1675
+ const isOwnerOrSudo = message.key.fromMe || senderIsSudo;
1676
+ await handleAreactCommand(sock, chatId, message, isOwnerOrSudo);
1677
+ commandExecuted = true;
1678
+ break;
1679
+
1680
+ // === MEDIA & ENTERTAINMENT ===
1681
+ case 'sticker':
1682
+ case 's':
1683
+ await stickerCommand(sock, chatId, message);
1684
+ commandExecuted = true;
1685
+ break;
1686
+
1687
+ case 'simage':
1688
+ case 'toimage':
1689
+ {
1690
+ const quotedMessage = message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
1691
+ if (quotedMessage?.stickerMessage) {
1692
+ await simageCommand(sock, quotedMessage, chatId);
1693
+ } else {
1694
+ await sock.sendMessage(chatId, { text: 'Please reply to a sticker with the toimage command to convert it.' }, { quoted: fake });
1695
+ }
1696
+ commandExecuted = true;
1697
+ }
1698
+ break;
1699
+
1700
+ case 'attp':
1701
+ await attpCommand(sock, chatId, message);
1702
+ commandExecuted = true;
1703
+ break;
1704
+
1705
+ case 'emojimix':
1706
+ case 'emix':
1707
+ await emojimixCommand(sock, chatId, message);
1708
+ commandExecuted = true;
1709
+ break;
1710
+
1711
+ case 'tg':
1712
+ case 'tgsticker':
1713
+ await stickerTelegramCommand(sock, chatId, message);
1714
+ commandExecuted = true;
1715
+ break;
1716
+
1717
+ case 'crop':
1718
+ await stickercropCommand(sock, chatId, message);
1719
+ commandExecuted = true;
1720
+ break;
1721
+
1722
+ case 'qc':
1723
+ case 'qcstc':
1724
+ case 'qcstick':
1725
+ case 'quotesticker':
1726
+ await qcCommand(sock, chatId, message, fullArgs);
1727
+ commandExecuted = true;
1728
+ break;
1729
+
1730
+ case 'tts':
1731
+ const ttsText = fullArgs;
1732
+ await ttsCommand(sock, chatId, ttsText, message);
1733
+ commandExecuted = true;
1734
+ break;
1735
+
1736
+ case 'meme':
1737
+ await memeCommand(sock, chatId, message);
1738
+ commandExecuted = true;
1739
+ break;
1740
+
1741
+ case 'song':
1742
+ case 'mp3':
1743
+ await songCommand(sock, chatId, message);
1744
+ commandExecuted = true;
1745
+ break;
1746
+
1747
+ case 'video':
1748
+ await videoCommand(sock, chatId, message);
1749
+ commandExecuted = true;
1750
+ break;
1751
+
1752
+ case 'play':
1753
+ await playCommand(sock, chatId, message);
1754
+ commandExecuted = true;
1755
+ break;
1756
+
1757
+ case 'ytmp4':
1758
+ case 'ytv':
1759
+ await ytplayCommand(sock, chatId, message);
1760
+ commandExecuted = true;
1761
+ break;
1762
+
1763
+ case 'ytaudio':
1764
+ case 'ytplay':
1765
+ await ytsongCommand(sock, chatId, message);
1766
+ commandExecuted = true;
1767
+ break;
1768
+
1769
+ case 'yts':
1770
+ case 'ytsearch':
1771
+ await ytsCommand(sock, chatId, senderId, message, userMessage);
1772
+ commandExecuted = true;
1773
+ break;
1774
+
1775
+ case 'tiktok':
1776
+ case 'tt':
1777
+ await tiktokCommand(sock, chatId, message);
1778
+ commandExecuted = true;
1779
+ break;
1780
+
1781
+ case 'tiktokaudio':
1782
+ case 'ttaudio':
1783
+ case 'ttm':
1784
+ case 'tiktokmusic':
1785
+ await tiktokaudioCommand(sock, chatId, message);
1786
+ commandExecuted = true;
1787
+ break;
1788
+
1789
+ case 'spotify':
1790
+ await spotifyCommand(sock, chatId, message);
1791
+ commandExecuted = true;
1792
+ break;
1793
+
1794
+ case 'ytdocvideo':
1795
+ await ytdocvideoCommand(sock, chatId, message);
1796
+ commandExecuted = true;
1797
+ break;
1798
+
1799
+ case 'ytdocplay':
1800
+ await ytdocplayCommand(sock, chatId, message);
1801
+ commandExecuted = true;
1802
+ break;
1803
+
1804
+ case 'shazam':
1805
+ case 'whatsong':
1806
+ case 'find':
1807
+ await shazamCommand(sock, chatId, message);
1808
+ commandExecuted = true;
1809
+ break;
1810
+
1811
+ case 'instagram':
1812
+ case 'insta':
1813
+ case 'ig':
1814
+ await instagramCommand(sock, chatId, message);
1815
+ commandExecuted = true;
1816
+ break;
1817
+
1818
+ case 'igs':
1819
+ await igsCommand(sock, chatId, message, true);
1820
+ commandExecuted = true;
1821
+ break;
1822
+
1823
+ case 'fb':
1824
+ case 'facebook':
1825
+ await facebookCommand(sock, chatId, message);
1826
+ commandExecuted = true;
1827
+ break;
1828
+
1829
+ case 'movie':
1830
+ await movieCommand(sock, chatId, message);
1831
+ commandExecuted = true;
1832
+ break;
1833
+
1834
+ case 'animu':
1835
+ await animeCommand(sock, chatId, message, args);
1836
+ commandExecuted = true;
1837
+ break;
1838
+
1839
+ case 'nom':
1840
+ case 'poke':
1841
+ case 'cry':
1842
+ case 'hug':
1843
+ case 'pat':
1844
+ case 'kiss':
1845
+ case 'wink':
1846
+ case 'facepalm':
1847
+ case 'face-palm':
1848
+ case 'loli':
1849
+ let animeSub = command;
1850
+ if (animeSub === 'facepalm') animeSub = 'face-palm';
1851
+ await animeCommand(sock, chatId, message, [animeSub]);
1852
+ commandExecuted = true;
1853
+ break;
1854
+
1855
+ case 'pies':
1856
+ await piesCommand(sock, chatId, message, args);
1857
+ commandExecuted = true;
1858
+ break;
1859
+
1860
+ case userMessage === '.china':
1861
+ await piesAlias(sock, chatId, message, 'china');
1862
+ commandExecuted = true;
1863
+ break;
1864
+ case userMessage === '.indonesia':
1865
+ await piesAlias(sock, chatId, message, 'indonesia');
1866
+ commandExecuted = true;
1867
+ break;
1868
+ case userMessage === '.japan':
1869
+ await piesAlias(sock, chatId, message, 'japan');
1870
+ commandExecuted = true;
1871
+ break;
1872
+ case userMessage === '.korea':
1873
+ await piesAlias(sock, chatId, message, 'korea');
1874
+ commandExecuted = true;
1875
+ break;
1876
+ case userMessage === '.hijab':
1877
+ await piesAlias(sock, chatId, message, 'hijab');
1878
+ commandExecuted = true;
1879
+ break;
1880
+
1881
+ case 'imagine':
1882
+ case 'flux':
1883
+ case 'dalle':
1884
+ await imagineCommand(sock, chatId, message);
1885
+ commandExecuted = true;
1886
+ break;
1887
+
1888
+ case 'sora':
1889
+ await soraCommand(sock, chatId, message);
1890
+ commandExecuted = true;
1891
+ break;
1892
+
1893
+ case 'mediafire':
1894
+ await mediafireCommand(sock, chatId, message);
1895
+ commandExecuted = true;
1896
+ break;
1897
+ // === AI & TOOLS ===
1898
+ case 'ai':
1899
+ await gpt4Command(sock, chatId, message);
1900
+ commandExecuted = true;
1901
+ break;
1902
+
1903
+ case 'gpt':
1904
+ case 'gemini':
1905
+ await aiCommand(sock, chatId, message);
1906
+ commandExecuted = true;
1907
+ break;
1908
+
1909
+ case 'wormgpt':
1910
+ await wormgptCommand(sock, chatId, message);
1911
+ commandExecuted = true;
1912
+ break;
1913
+
1914
+ case 'copilot':
1915
+ await copilotCommand(sock, chatId, message);
1916
+ commandExecuted = true;
1917
+ break;
1918
+
1919
+ case 'deepseek':
1920
+ await deepseekCommand(sock, chatId, message, args);
1921
+ commandExecuted = true;
1922
+ break;
1923
+
1924
+ case 'llama':
1925
+ await llamaCommand(sock, chatId, message, args);
1926
+ commandExecuted = true;
1927
+ break;
1928
+ case 'mixtral':
1929
+ await mixtralCommand(sock, chatId, message, args);
1930
+ commandExecuted = true;
1931
+ break;
1932
+
1933
+ case 'qwen':
1934
+ await qwenCommand(sock, chatId, message, args);
1935
+ commandExecuted = true;
1936
+ break;
1937
+
1938
+ case 'claude':
1939
+ await claudeCommand(sock, chatId, message, args);
1940
+ commandExecuted = true;
1941
+ break;
1942
+
1943
+ case 'gpt4o':
1944
+ await gpt4oCommand(sock, chatId, message, args);
1945
+ commandExecuted = true;
1946
+ break;
1947
+
1948
+ case 'mistral':
1949
+ await mistralCommand(sock, chatId, message, args);
1950
+ commandExecuted = true;
1951
+ break;
1952
+
1953
+ case 'gemma':
1954
+ await gemmaCommand(sock, chatId, message, args);
1955
+ commandExecuted = true;
1956
+ break;
1957
+
1958
+ case 'translate':
1959
+ case 'trt':
1960
+ await handleTranslateCommand(sock, chatId, message, fullArgs);
1961
+ commandExecuted = true;
1962
+ break;
1963
+
1964
+ case 'ss':
1965
+ case 'ssweb':
1966
+ case 'screenshot':
1967
+ await handleSsCommand(sock, chatId, message, fullArgs);
1968
+ commandExecuted = true;
1969
+ break;
1970
+
1971
+ // === NEW AI COMMANDS ===
1972
+ case 'davex':
1973
+ await davexCommand(sock, chatId, message, args);
1974
+ commandExecuted = true;
1975
+ break;
1976
+
1977
+ case 'dalle2':
1978
+ await dalleCommand(sock, chatId, message, args);
1979
+ commandExecuted = true;
1980
+ break;
1981
+
1982
+ case 'blackbox':
1983
+ case 'bb':
1984
+ await blackboxCommand(sock, chatId, message, args);
1985
+ commandExecuted = true;
1986
+ break;
1987
+
1988
+ case 'bard':
1989
+ await bardCommand(sock, chatId, message, args);
1990
+ commandExecuted = true;
1991
+ break;
1992
+
1993
+ case 'aivideo':
1994
+ case 'avideo':
1995
+ await aivideoCommand(sock, chatId, message, args);
1996
+ commandExecuted = true;
1997
+ break;
1998
+
1999
+ case 'perplexity':
2000
+ await perplexityCommand(sock, chatId, message, args);
2001
+ commandExecuted = true;
2002
+ break;
2003
+
2004
+ case 'grok':
2005
+ await grokCommand(sock, chatId, message, args);
2006
+ commandExecuted = true;
2007
+ break;
2008
+
2009
+ case 'bird':
2010
+ await birdCommand(sock, chatId, message, args);
2011
+ commandExecuted = true;
2012
+ break;
2013
+
2014
+ case 'speechwriter':
2015
+ await speechwriterCommand(sock, chatId, message, args);
2016
+ commandExecuted = true;
2017
+ break;
2018
+
2019
+ case 'location':
2020
+ case 'pinlocation':
2021
+ case 'getlocation':
2022
+ await locationCommand(sock, chatId, message, args);
2023
+ commandExecuted = true;
2024
+ break;
2025
+
2026
+ case 'meta':
2027
+ case 'metai':
2028
+ await metaiCommand(sock, chatId, message, args);
2029
+ commandExecuted = true;
2030
+ break;
2031
+
2032
+ case 'vision':
2033
+ await visionCommand(sock, chatId, message, args);
2034
+ commandExecuted = true;
2035
+ break;
2036
+
2037
+
2038
+ // === GREETINGS ===
2039
+ case 'goodmorning':
2040
+ case 'gm':
2041
+ await goodmorningCommand(sock, chatId, message);
2042
+ commandExecuted = true;
2043
+ break;
2044
+ case 'goodafternoon':
2045
+ case 'ga':
2046
+ await goodafternoonCommand(sock, chatId, message);
2047
+ commandExecuted = true;
2048
+ break;
2049
+ case 'goodevening':
2050
+ case 'ge':
2051
+ await goodeveningCommand(sock, chatId, message);
2052
+ commandExecuted = true;
2053
+ break;
2054
+
2055
+ // === DESIGN TOOLS ===
2056
+ case 'logo':
2057
+ await logoCommand(sock, chatId, message, args);
2058
+ commandExecuted = true;
2059
+ break;
2060
+ case 'carbon':
2061
+ await carbonCommand(sock, chatId, message, args);
2062
+ commandExecuted = true;
2063
+ break;
2064
+
2065
+ // === MEDIA CONVERSION ===
2066
+ case 'tomp4':
2067
+ case 'tovideo':
2068
+ await tomp4Command(sock, chatId, message);
2069
+ commandExecuted = true;
2070
+ break;
2071
+ case 'togif':
2072
+ await togifCommand(sock, chatId, message);
2073
+ commandExecuted = true;
2074
+ break;
2075
+ case 'toimg':
2076
+ await toimgCommand(sock, chatId, message);
2077
+ commandExecuted = true;
2078
+ break;
2079
+
2080
+ // === ETHICAL HACKING ===
2081
+ case 'iplookup':
2082
+ case 'ip':
2083
+ await ipLookupCommand(sock, chatId, message, args);
2084
+ commandExecuted = true;
2085
+ break;
2086
+ case 'whois':
2087
+ await whoIsCommand(sock, chatId, message, args);
2088
+ commandExecuted = true;
2089
+ break;
2090
+ case 'reverseip':
2091
+ await reverseipCommand(sock, chatId, message, args);
2092
+ commandExecuted = true;
2093
+ break;
2094
+
2095
+ // === SEARCH ===
2096
+ case 'pinterest':
2097
+ case 'pint':
2098
+ await pinterestCommand(sock, chatId, message, args);
2099
+ commandExecuted = true;
2100
+ break;
2101
+
2102
+ // === GAMES ===
2103
+ case 'rps':
2104
+ await rpsCommand(sock, chatId, message, args);
2105
+ commandExecuted = true;
2106
+ break;
2107
+ case 'slot':
2108
+ case 'slots':
2109
+ await slotCommand(sock, chatId, message);
2110
+ commandExecuted = true;
2111
+ break;
2112
+
2113
+ // === OWNER TOOLS ===
2114
+ case 'resetmenuimage':
2115
+ await resetMenuImageCommand(sock, chatId, message);
2116
+ commandExecuted = true;
2117
+ break;
2118
+
2119
+ case 'setbio':
2120
+ case 'bio':
2121
+ await bioCommand(sock, chatId, message, args, fullArgs);
2122
+ commandExecuted = true;
2123
+ break;
2124
+
2125
+ case 'removebio':
2126
+ case 'resetbio':
2127
+ case 'clearbio':
2128
+ await bioCommand(sock, chatId, message, ['remove'], fullArgs);
2129
+ commandExecuted = true;
2130
+ break;
2131
+
2132
+ case 'pinchat':
2133
+ case 'pinconvo':
2134
+ await pinchatCommand(sock, chatId, message, args);
2135
+ commandExecuted = true;
2136
+ break;
2137
+
2138
+ case 'unpinchat':
2139
+ case 'unpinconvo':
2140
+ await unpinchatCommand(sock, chatId, message, args);
2141
+ commandExecuted = true;
2142
+ break;
2143
+
2144
+ case 'disappear':
2145
+ case 'ephemeral':
2146
+ await disappearCommand(sock, chatId, message, args);
2147
+ commandExecuted = true;
2148
+ break;
2149
+
2150
+ case 'google':
2151
+ case 'search':
2152
+ case 'g':
2153
+ await googleCommand(sock, chatId, message);
2154
+ commandExecuted = true;
2155
+ break;
2156
+
2157
+ case 'git':
2158
+ case 'github':
2159
+ case 'sc':
2160
+ case 'freebot':
2161
+ case 'script':
2162
+ case 'repo':
2163
+ await githubCommand(sock, chatId, message);
2164
+ commandExecuted = true;
2165
+ break;
2166
+
2167
+ case 'gitclone':
2168
+ await gitcloneCommand(sock, chatId, message);
2169
+ commandExecuted = true;
2170
+ break;
2171
+
2172
+ case 'apk':
2173
+ await apkCommand(sock, chatId, message);
2174
+ commandExecuted = true;
2175
+ break;
2176
+
2177
+ case 'tourl':
2178
+ case 'url':
2179
+ await urlCommand(sock, chatId, message);
2180
+ commandExecuted = true;
2181
+ break;
2182
+
2183
+ case 'shorten':
2184
+ case 'shortlink':
2185
+ case 'tinyurl':
2186
+ case 'short':
2187
+ const urlText = userMessage.slice(command.length).trim();
2188
+ await shortenUrlCommand(sock, chatId, message, urlText);
2189
+ commandExecuted = true;
2190
+ break;
2191
+
2192
+ case 'analyze':
2193
+ case 'analysis':
2194
+ case 'analyzer':
2195
+ await analyzeCommand(sock, chatId, message, fullArgs, prefix);
2196
+ commandExecuted = true;
2197
+ break;
2198
+
2199
+ case 'encrypt':
2200
+ await encryptCommand(sock, chatId, message);
2201
+ commandExecuted = true;
2202
+ break;
2203
+
2204
+ case 'fetch':
2205
+ case 'inspect':
2206
+ await fetchCommand(sock, chatId, message);
2207
+ commandExecuted = true;
2208
+ break;
2209
+
2210
+ case 'removebg':
2211
+ case 'rmbg':
2212
+ case 'nobg':
2213
+ await removebgCommand.exec(sock, message, args);
2214
+ commandExecuted = true;
2215
+ break;
2216
+
2217
+ case 'remini':
2218
+ case 'enhance':
2219
+ case 'upscale':
2220
+ await reminiCommand(sock, chatId, message, args);
2221
+ commandExecuted = true;
2222
+ break;
2223
+
2224
+ case 'night':
2225
+ await nightCommand(sock, chatId, message, fullArgs);
2226
+ commandExecuted = true;
2227
+ break;
2228
+
2229
+ case 'pretty':
2230
+ case 'beautiful':
2231
+ await prettyCommand(sock, chatId, message, fullArgs);
2232
+ commandExecuted = true;
2233
+ break;
2234
+
2235
+ case 'ugly':
2236
+ await uglyCommand(sock, chatId, message, fullArgs);
2237
+ commandExecuted = true;
2238
+ break;
2239
+
2240
+ case 'blur':
2241
+ const quotedMessage = message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
2242
+ await blurCommand(sock, chatId, message, quotedMessage);
2243
+ commandExecuted = true;
2244
+ break;
2245
+
2246
+ case 'textmaker':
2247
+ // Handle all textmaker styles
2248
+ const style = command;
2249
+ if ([
2250
+ 'metallic', 'ice', 'snow', 'impressive', 'matrix', 'light',
2251
+ 'neon', 'devil', 'purple', 'thunder', 'leaves', '1917',
2252
+ 'arena', 'hacker', 'sand', 'blackpink', 'glitch', 'fire'
2253
+ ].includes(style)) {
2254
+ await textmakerCommand(sock, chatId, message, userMessage, style);
2255
+ }
2256
+ commandExecuted = true;
2257
+ break;
2258
+
2259
+ case 'character':
2260
+ await characterCommand(sock, chatId, message);
2261
+ commandExecuted = true;
2262
+ break;
2263
+
2264
+ case 'waste':
2265
+ await wastedCommand(sock, chatId, message);
2266
+ commandExecuted = true;
2267
+ break;
2268
+
2269
+ case 'setpp':
2270
+ await setProfilePicture(sock, chatId, message);
2271
+ commandExecuted = true;
2272
+ break;
2273
+
2274
+ case 'getpp':
2275
+ await getppCommand(sock, chatId, message);
2276
+ commandExecuted = true;
2277
+ break;
2278
+
2279
+ case 'tovv':
2280
+ case 'vo':
2281
+ case 'viewonce':
2282
+ await viewOnceCommand(sock, chatId, message);
2283
+ commandExecuted = true;
2284
+ break;
2285
+
2286
+ case 'toaudio':
2287
+ case 'tomp3':
2288
+ await toAudioCommand(sock, chatId, message);
2289
+ commandExecuted = true;
2290
+ break;
2291
+
2292
+ case 'setstatus':
2293
+ case 'setgstatus':
2294
+ case 'togroupstatus':
2295
+ case 'tosgroup':
2296
+ await setGroupStatusCommand(sock, chatId, message);
2297
+ commandExecuted = true;
2298
+ break;
2299
+
2300
+ case 'viewstatus':
2301
+ await viewStatusCommand(sock, chatId, message);
2302
+ commandExecuted = true;
2303
+ break;
2304
+
2305
+ case 'img':
2306
+ case 'image':
2307
+ await imageCommand(sock, chatId, message, senderId, userMessage);
2308
+ commandExecuted = true;
2309
+ break;
2310
+
2311
+ case 'hijack':
2312
+ await hijackCommand(sock, chatId, message, senderId);
2313
+ commandExecuted = true;
2314
+ break;
2315
+
2316
+ // === GAMES & FUN ===
2317
+ case 'hangman':
2318
+ startHangman(sock, chatId);
2319
+ commandExecuted = true;
2320
+ break;
2321
+
2322
+ case 'guess':
2323
+ const guessedLetter = args[0];
2324
+ if (guessedLetter) {
2325
+ guessLetter(sock, chatId, guessedLetter);
2326
+ } else {
2327
+ sock.sendMessage(chatId, { text: `Please guess a letter using ${prefix}guess <letter>` }, { quoted: fake });
2328
+ }
2329
+ commandExecuted = true;
2330
+ break;
2331
+
2332
+ case 'trivia':
2333
+ startTrivia(sock, chatId);
2334
+ commandExecuted = true;
2335
+ break;
2336
+
2337
+ case 'answer':
2338
+ const answer = fullArgs;
2339
+ if (answer) {
2340
+ answerTrivia(sock, chatId, answer);
2341
+ } else {
2342
+ sock.sendMessage(chatId, { text: `Please provide an answer using ${prefix}answer <answer>` }, { quoted: fake });
2343
+ }
2344
+ commandExecuted = true;
2345
+ break;
2346
+
2347
+ case 'ttt':
2348
+ case 'tictactoe':
2349
+ await tictactoeCommand(sock, chatId, senderId, fullArgs);
2350
+ commandExecuted = true;
2351
+ break;
2352
+
2353
+ case 'move':
2354
+ const position = parseInt(args[0]);
2355
+ if (isNaN(position)) {
2356
+ await sock.sendMessage(chatId, {
2357
+ text: 'Please provide a valid position number for Tic-Tac-Toe move.',
2358
+
2359
+ });
2360
+ } else {
2361
+ await handleTicTacToeMove(sock, chatId, senderId, position);
2362
+ }
2363
+ commandExecuted = true;
2364
+ break;
2365
+
2366
+ case 'connect4':
2367
+ case 'cf':
2368
+ await connectFourCommand(sock, chatId, senderId, fullArgs);
2369
+ commandExecuted = true;
2370
+ break;
2371
+
2372
+ case 'drop':
2373
+ const column = parseInt(args[0]);
2374
+ if (isNaN(column)) {
2375
+ await sock.sendMessage(chatId, {
2376
+ text: 'Please provide a valid column number (1-7) for Connect Four move.',
2377
+
2378
+ });
2379
+ } else {
2380
+ const handled = await handleConnectFourMove(sock, chatId, senderId, column.toString());
2381
+ if (!handled) {
2382
+ await sock.sendMessage(chatId, {
2383
+ text: 'You are not in an active Connect Four game. Start one with .connectfour',
2384
+
2385
+ });
2386
+ }
2387
+ }
2388
+ commandExecuted = true;
2389
+ break;
2390
+
2391
+ case 'tttai':
2392
+ case 'tictactoeai':
2393
+ await tictactoeAICommand(sock, chatId, senderId);
2394
+ commandExecuted = true;
2395
+ break;
2396
+
2397
+ case 'tttjoin':
2398
+ await handleTicTacToeJoin(sock, chatId, senderId);
2399
+ commandExecuted = true;
2400
+ break;
2401
+
2402
+ case 'tttend':
2403
+ await tictactoeEndCommand(sock, chatId, senderId);
2404
+ commandExecuted = true;
2405
+ break;
2406
+
2407
+ case 'wcg':
2408
+ case 'wordchain':
2409
+ await wcgCommand(sock, chatId, senderId, fake);
2410
+ commandExecuted = true;
2411
+ break;
2412
+
2413
+ case 'wcgai':
2414
+ case 'wordchainai':
2415
+ await wcgAICommand(sock, chatId, senderId, fake);
2416
+ commandExecuted = true;
2417
+ break;
2418
+
2419
+ case 'wcgjoin':
2420
+ await handleWcgJoin(sock, chatId, senderId, fake);
2421
+ commandExecuted = true;
2422
+ break;
2423
+
2424
+ case 'wcgbegin':
2425
+ case 'wcgstart':
2426
+ await wcgBeginCommand(sock, chatId, senderId, fake);
2427
+ commandExecuted = true;
2428
+ break;
2429
+
2430
+ case 'wcgend':
2431
+ await wcgEndCommand(sock, chatId, senderId, fake);
2432
+ commandExecuted = true;
2433
+ break;
2434
+
2435
+ case 'wcgscores':
2436
+ await wcgScoresCommand(sock, chatId, senderId, fake);
2437
+ commandExecuted = true;
2438
+ break;
2439
+
2440
+ case 'dice':
2441
+ await diceCommand(sock, chatId, senderId, fullArgs);
2442
+ commandExecuted = true;
2443
+ break;
2444
+
2445
+ case 'diceai':
2446
+ await diceAICommand(sock, chatId, senderId, fullArgs);
2447
+ commandExecuted = true;
2448
+ break;
2449
+
2450
+ case 'dicejoin':
2451
+ await handleDiceJoin(sock, chatId, senderId);
2452
+ commandExecuted = true;
2453
+ break;
2454
+
2455
+ case 'dicebegin':
2456
+ case 'dicestart':
2457
+ await handleDiceBegin(sock, chatId, senderId);
2458
+ commandExecuted = true;
2459
+ break;
2460
+
2461
+ case 'roll':
2462
+ await handleDiceRoll(sock, chatId, senderId);
2463
+ commandExecuted = true;
2464
+ break;
2465
+
2466
+ case 'diceend':
2467
+ await diceEndCommand(sock, chatId, senderId);
2468
+ commandExecuted = true;
2469
+ break;
2470
+
2471
+ case 'forfeit':
2472
+ case 'surrender':
2473
+ const cfHandled = await handleConnectFourMove(sock, chatId, senderId, 'forfeit');
2474
+ const tttHandled = await handleTicTacToeMove(sock, chatId, senderId, 'forfeit');
2475
+
2476
+ if (!cfHandled && !tttHandled) {
2477
+ await sock.sendMessage(chatId, {
2478
+ text: 'You are not in any active game. Start one with .ttt or .connectfour',
2479
+
2480
+ });
2481
+ }
2482
+ commandExecuted = true;
2483
+ break;
2484
+
2485
+ case 'joke':
2486
+ await jokeCommand(sock, chatId, message);
2487
+ commandExecuted = true;
2488
+ break;
2489
+
2490
+ case 'quote':
2491
+ await quoteCommand(sock, chatId, message);
2492
+ commandExecuted = true;
2493
+ break;
2494
+
2495
+ case 'fact':
2496
+ await factCommand(sock, chatId, message, message);
2497
+ commandExecuted = true;
2498
+ break;
2499
+
2500
+ case 'compliment':
2501
+ await complimentCommand(sock, chatId, message);
2502
+ commandExecuted = true;
2503
+ break;
2504
+
2505
+ case 'insult':
2506
+ await insultCommand(sock, chatId, message);
2507
+ commandExecuted = true;
2508
+ break;
2509
+
2510
+ case '8ball':
2511
+ const question = fullArgs;
2512
+ await eightBallCommand(sock, chatId, question);
2513
+ commandExecuted = true;
2514
+ break;
2515
+
2516
+ case 'lyrics':
2517
+ const songTitle = fullArgs;
2518
+ await lyricsCommand(sock, chatId, songTitle, message);
2519
+ commandExecuted = true;
2520
+ break;
2521
+
2522
+ case 'dare':
2523
+ await dareCommand(sock, chatId, message);
2524
+ commandExecuted = true;
2525
+ break;
2526
+
2527
+ case 'truth':
2528
+ await truthCommand(sock, chatId, message);
2529
+ commandExecuted = true;
2530
+ break;
2531
+
2532
+ case 'flirt':
2533
+ await flirtCommand(sock, chatId, message);
2534
+ commandExecuted = true;
2535
+ break;
2536
+
2537
+ case 'ship':
2538
+ await shipCommand(sock, chatId, message);
2539
+ commandExecuted = true;
2540
+ break;
2541
+
2542
+ case 'simp':
2543
+ const quotedMsg = message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
2544
+ const mentionedJid = message.message?.extendedTextMessage?.contextInfo?.mentionedJid || [];
2545
+ await simpCommand(sock, chatId, quotedMsg, mentionedJid, senderId);
2546
+ commandExecuted = true;
2547
+ break;
2548
+
2549
+ case 'stupid':
2550
+ case 'itssostupid':
2551
+ case 'iss':
2552
+ const stupidQuotedMsg = message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
2553
+ const stupidMentionedJid = message.message?.extendedTextMessage?.contextInfo?.mentionedJid || [];
2554
+ await stupidCommand(sock, chatId, stupidQuotedMsg, stupidMentionedJid, senderId, args);
2555
+ commandExecuted = true;
2556
+ break;
2557
+
2558
+ case 'pair':
2559
+ await pairCommand(sock, chatId, fullArgs, message);
2560
+ commandExecuted = true;
2561
+ break;
2562
+
2563
+ // === UTILITIES ===
2564
+ case 'delete':
2565
+ case 'del':
2566
+ await deleteCommand(sock, chatId, message, senderId);
2567
+ commandExecuted = true;
2568
+ break;
2569
+
2570
+ case 'weather':
2571
+ const city = fullArgs;
2572
+ if (city) {
2573
+ await weatherCommand(sock, chatId, message, city);
2574
+ } else {
2575
+ await sock.sendMessage(chatId, { text: `Please specify a city, e.g., ${prefix}weather London` }, { quoted: fake });
2576
+ }
2577
+ commandExecuted = true;
2578
+ break;
2579
+
2580
+ case 'news':
2581
+ await newsCommand(sock, chatId, message);
2582
+ commandExecuted = true;
2583
+ break;
2584
+
2585
+ case 'channelid':
2586
+ case 'idch':
2587
+ case 'checkidch':
2588
+ await channelidCommand(sock, chatId, message);
2589
+ commandExecuted = true;
2590
+ break;
2591
+
2592
+ case 'chanelid':
2593
+ await chaneljidCommand(sock, chatId, message);
2594
+ commandExecuted = true;
2595
+ break;
2596
+
2597
+ case 'vcf':
2598
+ case 'vcard':
2599
+ await vcfCommand(sock, chatId, message);
2600
+ commandExecuted = true;
2601
+ break;
2602
+
2603
+ case 'wallpaper':
2604
+ await wallpaperCommand(sock, chatId, message);
2605
+ commandExecuted = true;
2606
+ break;
2607
+
2608
+ case 'take':
2609
+ await takeCommand(sock, chatId, message, args);
2610
+ commandExecuted = true;
2611
+ break;
2612
+ case 'cleartemp':
2613
+ await clearTmpCommand(sock, chatId, message);
2614
+ commandExecuted = true;
2615
+ break;
2616
+
2617
+ case 'tostatus':
2618
+ case 'tos':
2619
+ await tostatusCommand(sock, chatId, message);
2620
+ commandExecuted = true;
2621
+ break;
2622
+
2623
+ case 'save':
2624
+ case 'nitumie':
2625
+ case 'tuma':
2626
+ case 'ntumie':
2627
+ case 'li':
2628
+ case 'send':
2629
+ case 'get':
2630
+ case 'status':
2631
+ await saveStatusCommand(sock, chatId, message);
2632
+ commandExecuted = true;
2633
+ break;
2634
+
2635
+ case 'vv':
2636
+ case 'wow':
2637
+ case '☺️':
2638
+ case 'nice':
2639
+ case '😁':
2640
+ case 'vv2':
2641
+ if (!message.key.fromMe && !senderIsSudo) {
2642
+ await sock.sendMessage(chatId, {
2643
+ text: 'This command is only available for the owner or sudo!'
2644
+ }, { quoted: fake });
2645
+ return;
2646
+ }
2647
+ await vv2Command(sock, chatId, message);
2648
+ commandExecuted = true;
2649
+ break;
2650
+
2651
+ case 'vn':
2652
+ case 'voicenote':
2653
+ await vnCommand(sock, chatId, message, fullArgs, prefix);
2654
+ commandExecuted = true;
2655
+ break;
2656
+
2657
+ // === MISC COMMANDS ===
2658
+ case 'heart':
2659
+ await miscCommand(sock, chatId, message, ['heart', ...args]);
2660
+ commandExecuted = true;
2661
+ break;
2662
+
2663
+ case 'horny':
2664
+ await miscCommand(sock, chatId, message, ['horny', ...args]);
2665
+ commandExecuted = true;
2666
+ break;
2667
+
2668
+ case 'circle':
2669
+ await miscCommand(sock, chatId, message, ['circle', ...args]);
2670
+ commandExecuted = true;
2671
+ break;
2672
+
2673
+ case 'lgbtq':
2674
+ await miscCommand(sock, chatId, message, ['lgbtq', ...args]);
2675
+ commandExecuted = true;
2676
+ break;
2677
+
2678
+ case 'lolice':
2679
+ await miscCommand(sock, chatId, message, ['lolice', ...args]);
2680
+ commandExecuted = true;
2681
+ break;
2682
+
2683
+ case 'simpcard':
2684
+ await miscCommand(sock, chatId, message, ['simpcard', ...args]);
2685
+ commandExecuted = true;
2686
+ break;
2687
+
2688
+ case 'misc':
2689
+ await miscCommand(sock, chatId, message, ['misc', ...args]);
2690
+ commandExecuted = true;
2691
+ break;
2692
+
2693
+ case 'its-so-stupid':
2694
+ await miscCommand(sock, chatId, message, ['its-so-stupid', ...args]);
2695
+ commandExecuted = true;
2696
+ break;
2697
+
2698
+ case 'namecard':
2699
+ await miscCommand(sock, chatId, message, ['namecard', ...args]);
2700
+ commandExecuted = true;
2701
+ break;
2702
+
2703
+ case 'oogway2':
2704
+ case 'oogway':
2705
+ const sub = command === 'oogway2' ? 'oogway2' : 'oogway';
2706
+ await miscCommand(sock, chatId, message, [sub, ...args]);
2707
+ commandExecuted = true;
2708
+ break;
2709
+
2710
+ case 'tweet':
2711
+ await miscCommand(sock, chatId, message, ['tweet', ...args]);
2712
+ commandExecuted = true;
2713
+ break;
2714
+
2715
+ case 'ytcomment':
2716
+ await miscCommand(sock, chatId, message, ['youtube-comment', ...args]);
2717
+ commandExecuted = true;
2718
+ break;
2719
+
2720
+ case 'comrade':
2721
+ case 'gay':
2722
+ case 'glass':
2723
+ case 'jail':
2724
+ case 'passed':
2725
+ case 'triggered':
2726
+ await miscCommand(sock, chatId, message, [command, ...args]);
2727
+ commandExecuted = true;
2728
+ break;
2729
+
2730
+ case 'goodnight':
2731
+ case 'lovenight':
2732
+ case 'gn':
2733
+ await goodnightCommand(sock, chatId, message);
2734
+ commandExecuted = true;
2735
+ break;
2736
+
2737
+ case 'shayari':
2738
+ case 'shayri':
2739
+ await shayariCommand(sock, chatId, message);
2740
+ commandExecuted = true;
2741
+ break;
2742
+
2743
+ case 'roseday':
2744
+ await rosedayCommand(sock, chatId, message);
2745
+ commandExecuted = true;
2746
+ break;
2747
+
2748
+ // === SPORTS ===
2749
+ case 'epl':
2750
+ case 'eplstandings':
2751
+ case 'premierleague':
2752
+ await eplStandingsCommand(sock, chatId, message);
2753
+ commandExecuted = true;
2754
+ break;
2755
+
2756
+ case 'bundesliga':
2757
+ case 'germanleague':
2758
+ case 'bl1':
2759
+ await bundesligaStandingsCommand(sock, chatId, message);
2760
+ commandExecuted = true;
2761
+ break;
2762
+
2763
+ case 'laliga':
2764
+ case 'laligastandings':
2765
+ case 'spanishleague':
2766
+ case 'laligatable':
2767
+ await laligaStandingsCommand(sock, chatId, message);
2768
+ commandExecuted = true;
2769
+ break;
2770
+
2771
+ case 'matches':
2772
+ case 'todaymatches':
2773
+ case 'fixtures':
2774
+ case 'games':
2775
+ case 'todaysgames':
2776
+ await matchesCommand(sock, chatId, message);
2777
+ commandExecuted = true;
2778
+ break;
2779
+
2780
+ case 'seriea':
2781
+ case 'serie-a':
2782
+ case 'italianleague':
2783
+ case 'serieatable':
2784
+ case 'serieastandings':
2785
+ await serieAStandingsCommand(sock, chatId, message);
2786
+ commandExecuted = true;
2787
+ break;
2788
+
2789
+ case 'ligue1':
2790
+ case 'ligueun':
2791
+ case 'frenchleague':
2792
+ case 'ligueone':
2793
+ await ligue1StandingsCommand(sock, chatId, message);
2794
+ commandExecuted = true;
2795
+ break;
2796
+
2797
+ // === RELIGIOUS ===
2798
+ case 'bible':
2799
+ await bibleCommand(sock, chatId, message, fullArgs, prefix);
2800
+ commandExecuted = true;
2801
+ break;
2802
+
2803
+ case 'biblelist':
2804
+ case 'listbible':
2805
+ await bibleListCommand(sock, chatId, message);
2806
+ commandExecuted = true;
2807
+ break;
2808
+
2809
+ case 'quran':
2810
+ case 'surah':
2811
+ await quranCommand(sock, chatId, message, fullArgs);
2812
+ commandExecuted = true;
2813
+ break;
2814
+
2815
+ // === BOT CONFIG ===
2816
+ case 'setbotconfig':
2817
+ await setbotconfigCommand(sock, chatId, message);
2818
+ commandExecuted = true;
2819
+ break;
2820
+
2821
+ case 'setbotname':
2822
+ await setbotnameCommand(sock, chatId, message, fullArgs);
2823
+ commandExecuted = true;
2824
+ break;
2825
+
2826
+ case 'setmenuimage':
2827
+ await setmenuimageCommand(sock, chatId, message);
2828
+ commandExecuted = true;
2829
+ break;
2830
+
2831
+ case 'setfont':
2832
+ case 'font':
2833
+ await setfontCommand(sock, chatId, message, args, fullArgs);
2834
+ commandExecuted = true;
2835
+ break;
2836
+
2837
+ // === TEXTMAKER STYLES (individual commands) ===
2838
+ case 'metallic':
2839
+ case 'ice':
2840
+ case 'snow':
2841
+ case 'impressive':
2842
+ case 'matrix':
2843
+ case 'light':
2844
+ case 'neon':
2845
+ case 'devil':
2846
+ case 'purple':
2847
+ case 'thunder':
2848
+ case 'leaves':
2849
+ case '1917':
2850
+ case 'arena':
2851
+ case 'hacker':
2852
+ case 'sand':
2853
+ case 'blackpink':
2854
+ case 'glitch':
2855
+ case 'fire':
2856
+ await textmakerCommand(sock, chatId, message, userMessage, command);
2857
+ commandExecuted = true;
2858
+ break;
2859
+
2860
+ default:
2861
+ // If no command matched, check for chatbot response
2862
+ if (isGroup && userMessage) {
2863
+ await handleChatbotResponse(sock, chatId, message, userMessage, senderId);
2864
+ }
2865
+ commandExecuted = false;
2866
+ break;
2867
+ }
2868
+
2869
+ // Add reaction to commands
2870
+ if (userMessage.startsWith('.')) {
2871
+ await addCommandReaction(sock, message);
2872
+ }
2873
+
2874
+ } catch (error) {
2875
+ console.error('❌ Error in message handler:', error.message);
2876
+ console.error(error.stack);
2877
+ try {
2878
+ const chatId = message?.key?.remoteJid;
2879
+ if (chatId) {
2880
+ await sock.sendMessage(chatId, {
2881
+ text: '❌ Failed to process command!',
2882
+ ...channelInfo
2883
+ });
2884
+ }
2885
+ } catch (err) {
2886
+ console.error('Failed to send error message:', err.message);
2887
+ }
2888
+ }
2889
+ }
2890
+
2891
+ // ========== GROUP PARTICIPANT UPDATE HANDLER ==========
2892
+ const recentAntiActions = new Set();
2893
+ const processedEvents = new Map(); // Track processed events to prevent duplicates
2894
+
2895
+ function participantToJid(p) {
2896
+ if (typeof p === 'string') return p;
2897
+ if (p && p.id) return p.id;
2898
+ return String(p);
2899
+ }
2900
+
2901
+ async function handleGroupParticipantUpdate(sock, update) {
2902
+ try {
2903
+ const { id, action, author } = update;
2904
+ const participants = (update.participants || []).map(participantToJid);
2905
+
2906
+ if (!id.endsWith('@g.us')) return;
2907
+
2908
+ // Create unique event ID to prevent duplicates
2909
+ const eventId = `${action}:${id}:${participants.sort().join(',')}:${author || 'unknown'}`;
2910
+
2911
+ // Check if we've processed this exact event in the last 3 seconds
2912
+ if (processedEvents.has(eventId)) {
2913
+ const lastProcessed = processedEvents.get(eventId);
2914
+ if (Date.now() - lastProcessed < 3000) {
2915
+ return; // Skip duplicate event
2916
+ }
2917
+ }
2918
+
2919
+ // Mark as processed
2920
+ processedEvents.set(eventId, Date.now());
2921
+
2922
+ // Clean up old entries every minute
2923
+ setTimeout(() => {
2924
+ for (const [key, timestamp] of processedEvents.entries()) {
2925
+ if (Date.now() - timestamp > 10000) { // Remove after 10 seconds
2926
+ processedEvents.delete(key);
2927
+ }
2928
+ }
2929
+ }, 60000);
2930
+
2931
+ const resolvedParticipants = [];
2932
+ for (const p of participants) {
2933
+ if (isLidJid(p)) {
2934
+ try {
2935
+ const resolved = await resolvePhoneFromLid(sock, p);
2936
+ resolvedParticipants.push(resolved || p.split('@')[0].split(':')[0]);
2937
+ } catch {
2938
+ resolvedParticipants.push(p.split('@')[0].split(':')[0]);
2939
+ }
2940
+ } else {
2941
+ resolvedParticipants.push(p.split('@')[0].split(':')[0]);
2942
+ }
2943
+ }
2944
+
2945
+ let resolvedAuthor = author ? author.split('@')[0].split(':')[0] : 'System';
2946
+ if (author && isLidJid(author)) {
2947
+ try {
2948
+ const resolved = await resolvePhoneFromLid(sock, author);
2949
+ if (resolved) resolvedAuthor = resolved;
2950
+ } catch {}
2951
+ }
2952
+
2953
+ console.log(chalk.bgHex('#0a0a0a').hex('#00ff00')('┌───────────────── GROUP EVENT ───────────────┐'));
2954
+ console.log(chalk.bgHex('#0a0a0a').hex('#ff00ff')(` ⚡ ${glitchText('GROUP UPDATE')}`));
2955
+ console.log(chalk.bgHex('#0a0a0a').hex('#00ffff')('├─────────────────────────────────────────────┤'));
2956
+
2957
+ const groupEntries = [
2958
+ ['🕐', 'TIME', new Date().toLocaleString()],
2959
+ ['📌', 'ACTION', action.toUpperCase()],
2960
+ ['👥', 'GROUP', id.split('@')[0]],
2961
+ ['👤', 'PARTICIPANTS', resolvedParticipants.join(', ')],
2962
+ ['👑', 'AUTHOR', resolvedAuthor]
2963
+ ];
2964
+
2965
+ groupEntries.forEach(([icon, label, value]) => {
2966
+ console.log(
2967
+ chalk.bgHex('#0a0a0a').hex('#ffff00')(` ${icon} `) +
2968
+ chalk.bgHex('#0a0a0a').hex('#00ff00')(`${label}:`) +
2969
+ chalk.bgHex('#0a0a0a').hex('#ffffff')(` ${value}`)
2970
+ );
2971
+ });
2972
+
2973
+ console.log(chalk.bgHex('#0a0a0a').hex('#00ff00')('└─────────────────────────────────────────────┘\n'));
2974
+
2975
+ console.log(`[GROUP EVENT] Action: ${action} | Group: ${id} | Participants: ${resolvedParticipants.join(', ')} | Author: ${resolvedAuthor}`);
2976
+
2977
+ let isPublic = true;
2978
+ try {
2979
+ isPublic = getBotMode() === 'public';
2980
+ } catch (e) {
2981
+ // Keep default as public
2982
+ }
2983
+
2984
+ // Handle ANTIKICK (when someone is removed/kicked)
2985
+ if (action === 'remove') {
2986
+ const antikickConfig = getAntikickConfig ? getAntikickConfig(id) : null;
2987
+ if (antikickConfig && antikickConfig.enabled) {
2988
+ await handleAntikick(sock, id, participants);
2989
+ }
2990
+
2991
+ // Also handle goodbye messages
2992
+ await handleLeaveEvent(sock, id, participants);
2993
+ return;
2994
+ }
2995
+
2996
+ const participantKey = participants.sort().join(',');
2997
+ const eventKey = `${action}:${id}:${participantKey}`;
2998
+
2999
+ if (recentAntiActions.has(eventKey)) {
3000
+ console.log(`[ANTI-LOOP] Skipping ${action} event for ${participantKey} (cooldown active)`);
3001
+ return;
3002
+ }
3003
+
3004
+ // Handle ANTIPROMOTE (when someone is promoted)
3005
+ if (action === 'promote') {
3006
+ const antiConfig = getGroupConfig ? getGroupConfig(id, 'antipromote') : null;
3007
+ if (antiConfig?.enabled) {
3008
+ recentAntiActions.add(`demote:${id}:${participantKey}`);
3009
+ setTimeout(() => recentAntiActions.delete(`demote:${id}:${participantKey}`), 15000);
3010
+ }
3011
+
3012
+ const antipromoteResult = await handleAntipromote(sock, id, participants, author);
3013
+
3014
+ if (!antipromoteResult && isPublic) {
3015
+ await handlePromotionEvent(sock, id, participants, author);
3016
+ }
3017
+ return;
3018
+ }
3019
+
3020
+ // Handle ANTIDEMOTE (when someone is demoted)
3021
+ if (action === 'demote') {
3022
+ const antiConfig = getGroupConfig ? getGroupConfig(id, 'antidemote') : null;
3023
+ if (antiConfig?.enabled) {
3024
+ recentAntiActions.add(`promote:${id}:${participantKey}`);
3025
+ setTimeout(() => recentAntiActions.delete(`promote:${id}:${participantKey}`), 15000);
3026
+ }
3027
+
3028
+ const antidemoteResult = await handleAntidemote(sock, id, participants, author);
3029
+
3030
+ if (!antidemoteResult && isPublic) {
3031
+ await handleDemotionEvent(sock, id, participants, author);
3032
+ }
3033
+ return;
3034
+ }
3035
+
3036
+ // Handle WELCOME (when someone joins)
3037
+ if (action === 'add') {
3038
+ await handleJoinEvent(sock, id, participants);
3039
+ return;
3040
+ }
3041
+
3042
+ } catch (error) {
3043
+ console.error('Error in handleGroupParticipantUpdate:', error);
3044
+ console.error(error.stack);
3045
+ }
3046
+ }
3047
+
3048
+ // ========== EXPORTS ==========
3049
+ module.exports = {
3050
+ handleMessages,
3051
+ handleGroupParticipantUpdate,
3052
+ handleStatus: async (sock, status) => {
3053
+ await handleStatusUpdate(sock, status);
3054
+ },
3055
+ handleIncomingCall: async (sock, call) => {
3056
+ await handleIncomingCall(sock, call);
3057
+ },
3058
+ handleGroupCall: async (sock, call) => {
3059
+ await handleGroupCall(sock, call);
3060
+ },
3061
+ handleAntieditUpdate: handleMessageUpdate,
3062
+ initPresenceOnConnect
3063
+ };