jsdecryptor 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/Database/database.js +446 -0
  2. package/Database/migration.js +327 -0
  3. package/Database/pgSync.js +229 -0
  4. package/Database/settingsStore.js +305 -0
  5. package/config.js +32 -0
  6. package/dave.js +3063 -0
  7. package/davelib/antibadword.js +278 -0
  8. package/davelib/antilink.js +88 -0
  9. package/davelib/antilinkHelper.js +48 -0
  10. package/davelib/botConfig.js +71 -0
  11. package/davelib/connect4.js +111 -0
  12. package/davelib/converter.js +89 -0
  13. package/davelib/dicegame.js +114 -0
  14. package/davelib/exif.js +138 -0
  15. package/davelib/fakeContact.js +85 -0
  16. package/davelib/fontStyles.js +237 -0
  17. package/davelib/greetings.js +47 -0
  18. package/davelib/id.js +11 -0
  19. package/davelib/index.js +577 -0
  20. package/davelib/isAdmin.js +32 -0
  21. package/davelib/isBanned.js +12 -0
  22. package/davelib/isOwner.js +15 -0
  23. package/davelib/lightweight_store.js +169 -0
  24. package/davelib/messageConfig.js +15 -0
  25. package/davelib/messageHandler.js +87 -0
  26. package/davelib/myfunc.js +379 -0
  27. package/davelib/myfunc2.js +170 -0
  28. package/davelib/reactions.js +180 -0
  29. package/davelib/server.html +563 -0
  30. package/davelib/sticker.js +208 -0
  31. package/davelib/tempCleanup.js +53 -0
  32. package/davelib/tictactoe.js +104 -0
  33. package/davelib/uploadImage.js +100 -0
  34. package/davelib/uploader.js +110 -0
  35. package/davelib/welcome.js +100 -0
  36. package/davelib/wordchain.js +121 -0
  37. package/daveset.js +16 -0
  38. package/davexcore/ai/ai.js +100 -0
  39. package/davexcore/ai/aiGpt4.js +59 -0
  40. package/davexcore/ai/aimodels.js +284 -0
  41. package/davexcore/ai/aivideo.js +31 -0
  42. package/davexcore/ai/analyze.js +233 -0
  43. package/davexcore/ai/bard.js +101 -0
  44. package/davexcore/ai/bird.js +101 -0
  45. package/davexcore/ai/blackbox.js +30 -0
  46. package/davexcore/ai/character.js +80 -0
  47. package/davexcore/ai/copilot.js +58 -0
  48. package/davexcore/ai/dalle.js +39 -0
  49. package/davexcore/ai/davex.js +50 -0
  50. package/davexcore/ai/deepseek.js +96 -0
  51. package/davexcore/ai/grok.js +67 -0
  52. package/davexcore/ai/imagine.js +89 -0
  53. package/davexcore/ai/meta.js +82 -0
  54. package/davexcore/ai/mistral.js +101 -0
  55. package/davexcore/ai/perplexity.js +95 -0
  56. package/davexcore/ai/sora.js +44 -0
  57. package/davexcore/ai/speechwriter.js +46 -0
  58. package/davexcore/ai/vision.js +244 -0
  59. package/davexcore/ai/wormgpt.js +56 -0
  60. package/davexcore/anti/antiaudio.js +106 -0
  61. package/davexcore/anti/antibadword.js +313 -0
  62. package/davexcore/anti/antibug.js +156 -0
  63. package/davexcore/anti/anticall.js +219 -0
  64. package/davexcore/anti/antichart.js +280 -0
  65. package/davexcore/anti/antidelete.js +673 -0
  66. package/davexcore/anti/antideletestatus.js +535 -0
  67. package/davexcore/anti/antidemote.js +352 -0
  68. package/davexcore/anti/antidocument.js +105 -0
  69. package/davexcore/anti/antiedit.js +410 -0
  70. package/davexcore/anti/antifiles.js +109 -0
  71. package/davexcore/anti/antigroupmention.js +206 -0
  72. package/davexcore/anti/antiimage.js +105 -0
  73. package/davexcore/anti/antikick.js +125 -0
  74. package/davexcore/anti/antilink.js +237 -0
  75. package/davexcore/anti/antimention.js +143 -0
  76. package/davexcore/anti/antipromote.js +320 -0
  77. package/davexcore/anti/antisticker.js +105 -0
  78. package/davexcore/anti/antitag.js +191 -0
  79. package/davexcore/anti/antivideo.js +105 -0
  80. package/davexcore/anti/antiviewonce.js +396 -0
  81. package/davexcore/anti/groupanticall.js +262 -0
  82. package/davexcore/anti/mention.js +242 -0
  83. package/davexcore/automation/alwaysonline.js +226 -0
  84. package/davexcore/automation/autoReadReciepts.js +96 -0
  85. package/davexcore/automation/autoread.js +104 -0
  86. package/davexcore/automation/autorecording.js +197 -0
  87. package/davexcore/automation/autostatus.js +317 -0
  88. package/davexcore/automation/autotyping.js +197 -0
  89. package/davexcore/automation/chatbot.js +444 -0
  90. package/davexcore/automation/chatmanage.js +199 -0
  91. package/davexcore/automation/devReact.js +43 -0
  92. package/davexcore/automation/goodbye.js +181 -0
  93. package/davexcore/automation/greetings.js +154 -0
  94. package/davexcore/automation/welcome.js +187 -0
  95. package/davexcore/downloads/apk.js +157 -0
  96. package/davexcore/downloads/facebook.js +94 -0
  97. package/davexcore/downloads/gitclone.js +137 -0
  98. package/davexcore/downloads/igs.js +333 -0
  99. package/davexcore/downloads/instagram.js +133 -0
  100. package/davexcore/downloads/mediafire.js +144 -0
  101. package/davexcore/downloads/pinterest.js +38 -0
  102. package/davexcore/downloads/play.js +158 -0
  103. package/davexcore/downloads/saveStatus.js +3 -0
  104. package/davexcore/downloads/song.js +135 -0
  105. package/davexcore/downloads/spotify.js +133 -0
  106. package/davexcore/downloads/tiktok.js +167 -0
  107. package/davexcore/downloads/tiktokaudio.js +158 -0
  108. package/davexcore/downloads/video.js +188 -0
  109. package/davexcore/downloads/ytdl.js +252 -0
  110. package/davexcore/downloads/ytdocplay.js +130 -0
  111. package/davexcore/downloads/ytdocvideo.js +95 -0
  112. package/davexcore/downloads/yts.js +64 -0
  113. package/davexcore/games/connect4.js +267 -0
  114. package/davexcore/games/dice.js +286 -0
  115. package/davexcore/games/eightball.js +24 -0
  116. package/davexcore/games/hangman.js +60 -0
  117. package/davexcore/games/rps.js +25 -0
  118. package/davexcore/games/ship.js +36 -0
  119. package/davexcore/games/slot.js +21 -0
  120. package/davexcore/games/tictactoe.js +263 -0
  121. package/davexcore/games/trivia.js +46 -0
  122. package/davexcore/games/wordchain.js +242 -0
  123. package/davexcore/group/addmember.js +101 -0
  124. package/davexcore/group/ban.js +63 -0
  125. package/davexcore/group/blockUnblock.js +177 -0
  126. package/davexcore/group/clear.js +196 -0
  127. package/davexcore/group/creategroup.js +43 -0
  128. package/davexcore/group/demote.js +115 -0
  129. package/davexcore/group/disappear.js +67 -0
  130. package/davexcore/group/groupinfo.js +167 -0
  131. package/davexcore/group/groupmanage.js +133 -0
  132. package/davexcore/group/hidetag.js +108 -0
  133. package/davexcore/group/joinrequests.js +145 -0
  134. package/davexcore/group/kick.js +92 -0
  135. package/davexcore/group/kickall.js +63 -0
  136. package/davexcore/group/leave.js +38 -0
  137. package/davexcore/group/linkgroup.js +63 -0
  138. package/davexcore/group/mute.js +57 -0
  139. package/davexcore/group/online.js +117 -0
  140. package/davexcore/group/pmblocker.js +65 -0
  141. package/davexcore/group/promote.js +93 -0
  142. package/davexcore/group/resetlink.js +57 -0
  143. package/davexcore/group/staff.js +99 -0
  144. package/davexcore/group/tag.js +111 -0
  145. package/davexcore/group/tagadmins.js +88 -0
  146. package/davexcore/group/tagall.js +99 -0
  147. package/davexcore/group/tagnotadmin.js +92 -0
  148. package/davexcore/group/topmembers.js +202 -0
  149. package/davexcore/group/unban.js +64 -0
  150. package/davexcore/group/unmute.js +45 -0
  151. package/davexcore/group/warn.js +83 -0
  152. package/davexcore/group/warnings.js +26 -0
  153. package/davexcore/media/anime.js +130 -0
  154. package/davexcore/media/attp.js +127 -0
  155. package/davexcore/media/design.js +52 -0
  156. package/davexcore/media/emojimix.js +105 -0
  157. package/davexcore/media/getpp.js +108 -0
  158. package/davexcore/media/image.js +87 -0
  159. package/davexcore/media/imageedit.js +329 -0
  160. package/davexcore/media/img-blur.js +70 -0
  161. package/davexcore/media/meme.js +35 -0
  162. package/davexcore/media/pies.js +53 -0
  163. package/davexcore/media/quotesticker.js +153 -0
  164. package/davexcore/media/remini.js +126 -0
  165. package/davexcore/media/removebg.js +114 -0
  166. package/davexcore/media/setpp.js +65 -0
  167. package/davexcore/media/shazam.js +251 -0
  168. package/davexcore/media/simage.js +74 -0
  169. package/davexcore/media/sticker.js +134 -0
  170. package/davexcore/media/stickercrop.js +133 -0
  171. package/davexcore/media/stickertelegram.js +133 -0
  172. package/davexcore/media/take.js +76 -0
  173. package/davexcore/media/textmaker.js +106 -0
  174. package/davexcore/media/toAudio.js +180 -0
  175. package/davexcore/media/togif.js +33 -0
  176. package/davexcore/media/toimg.js +26 -0
  177. package/davexcore/media/tomp4.js +34 -0
  178. package/davexcore/media/tostatus.js +160 -0
  179. package/davexcore/media/tts.js +47 -0
  180. package/davexcore/media/viewonce.js +59 -0
  181. package/davexcore/media/vn.js +67 -0
  182. package/davexcore/media/vv2.js +3 -0
  183. package/davexcore/media/wallpaper.js +89 -0
  184. package/davexcore/media/wasted.js +57 -0
  185. package/davexcore/misc/compliment.js +93 -0
  186. package/davexcore/misc/dare.js +47 -0
  187. package/davexcore/misc/fact.js +14 -0
  188. package/davexcore/misc/flirt.js +26 -0
  189. package/davexcore/misc/goodnight.js +33 -0
  190. package/davexcore/misc/insult.js +281 -0
  191. package/davexcore/misc/joke.js +66 -0
  192. package/davexcore/misc/misc.js +200 -0
  193. package/davexcore/misc/quote.js +22 -0
  194. package/davexcore/misc/roseday.js +24 -0
  195. package/davexcore/misc/shayari.js +62 -0
  196. package/davexcore/misc/simp.js +47 -0
  197. package/davexcore/misc/stupid.js +51 -0
  198. package/davexcore/misc/truth.js +146 -0
  199. package/davexcore/owner/alive.js +67 -0
  200. package/davexcore/owner/bio.js +49 -0
  201. package/davexcore/owner/broadcast.js +74 -0
  202. package/davexcore/owner/chanel.js +79 -0
  203. package/davexcore/owner/channelid.js +50 -0
  204. package/davexcore/owner/clearsession.js +86 -0
  205. package/davexcore/owner/help.js +649 -0
  206. package/davexcore/owner/hijack.js +69 -0
  207. package/davexcore/owner/menuManage.js +173 -0
  208. package/davexcore/owner/menuSettings.js +1 -0
  209. package/davexcore/owner/owner.js +17 -0
  210. package/davexcore/owner/pair.js +160 -0
  211. package/davexcore/owner/pinchat.js +44 -0
  212. package/davexcore/owner/ping.js +65 -0
  213. package/davexcore/owner/profilepic.js +61 -0
  214. package/davexcore/owner/resetmenuimage.js +16 -0
  215. package/davexcore/owner/setGroupStatus.js +315 -0
  216. package/davexcore/owner/setbotconfig.js +306 -0
  217. package/davexcore/owner/setfont.js +79 -0
  218. package/davexcore/owner/setowner.js +144 -0
  219. package/davexcore/owner/setprefix.js +131 -0
  220. package/davexcore/owner/settings.js +98 -0
  221. package/davexcore/owner/startupwelcome.js +94 -0
  222. package/davexcore/owner/sudo.js +138 -0
  223. package/davexcore/owner/update.js +282 -0
  224. package/davexcore/tmp/1772020249097.jpg +0 -0
  225. package/davexcore/utility/bible.js +239 -0
  226. package/davexcore/utility/cleartmp.js +107 -0
  227. package/davexcore/utility/delete.js +182 -0
  228. package/davexcore/utility/encrypt.js +99 -0
  229. package/davexcore/utility/ethicalhacking.js +108 -0
  230. package/davexcore/utility/fetch.js +127 -0
  231. package/davexcore/utility/github.js +85 -0
  232. package/davexcore/utility/google.js +79 -0
  233. package/davexcore/utility/join.js +52 -0
  234. package/davexcore/utility/lastseen.js +67 -0
  235. package/davexcore/utility/location.js +106 -0
  236. package/davexcore/utility/lyrics.js +54 -0
  237. package/davexcore/utility/movie.js +66 -0
  238. package/davexcore/utility/news.js +37 -0
  239. package/davexcore/utility/sports.js +403 -0
  240. package/davexcore/utility/ss.js +63 -0
  241. package/davexcore/utility/tinyurl.js +83 -0
  242. package/davexcore/utility/translate.js +101 -0
  243. package/davexcore/utility/url.js +112 -0
  244. package/davexcore/utility/vcf.js +84 -0
  245. package/davexcore/utility/weather.js +162 -0
  246. package/index.js +994 -0
  247. package/package.json +64 -0
@@ -0,0 +1,444 @@
1
+ const path = require('path');
2
+ const fetch = require('node-fetch');
3
+ const { loadUserGroupData, saveUserGroupData } = require('../../davelib/index');
4
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
5
+
6
+ const chatMemory = {
7
+ messages: new Map(),
8
+ userInfo: new Map()
9
+ };
10
+
11
+ function getRandomDelay() {
12
+ return Math.floor(Math.random() * 3000) + 2000;
13
+ }
14
+
15
+ async function showTyping(sock, chatId) {
16
+ try {
17
+ await sock.presenceSubscribe(chatId);
18
+ await sock.sendPresenceUpdate('composing', chatId);
19
+ await new Promise(resolve => setTimeout(resolve, getRandomDelay()));
20
+ } catch (error) {}
21
+ }
22
+
23
+ async function handleChatbotCommand(sock, chatId, message, match) {
24
+ if (!match) {
25
+ await showTyping(sock, chatId);
26
+ return sock.sendMessage(chatId, {
27
+ text: `┌─ *CHATBOT* ─┐
28
+
29
+ │ Commands:
30
+ │ .chatbot on
31
+ │ .chatbot off
32
+
33
+ │ Enable/disable chatbot in group
34
+
35
+ └─────────────┘`,
36
+ quoted: message
37
+ });
38
+ }
39
+
40
+ const data = loadUserGroupData();
41
+
42
+ const botNumber = sock.user.id.split(':')[0] + '@s.whatsapp.net';
43
+
44
+ const senderId = message.key.participant || message.participant || message.pushName || message.key.remoteJid;
45
+ const isOwner = senderId === botNumber || message.key.fromMe;
46
+
47
+ if (isOwner) {
48
+ if (match === 'on') {
49
+ await showTyping(sock, chatId);
50
+ if (data.chatbot[chatId]) {
51
+ return sock.sendMessage(chatId, {
52
+ text: `┌─ *CHATBOT* ─┐
53
+
54
+ │ Already enabled
55
+
56
+ └─────────────┘`,
57
+ quoted: message
58
+ });
59
+ }
60
+ data.chatbot[chatId] = true;
61
+ saveUserGroupData(data);
62
+ return sock.sendMessage(chatId, {
63
+ text: `┌─ *CHATBOT* ─┐
64
+
65
+ │ Chatbot ENABLED
66
+
67
+ └─────────────┘`,
68
+ quoted: message
69
+ });
70
+ }
71
+
72
+ if (match === 'off') {
73
+ await showTyping(sock, chatId);
74
+ if (!data.chatbot[chatId]) {
75
+ return sock.sendMessage(chatId, {
76
+ text: `┌─ *CHATBOT* ─┐
77
+
78
+ │ Already disabled
79
+
80
+ └─────────────┘`,
81
+ quoted: message
82
+ });
83
+ }
84
+ data.chatbot[chatId] = false;
85
+ saveUserGroupData(data);
86
+ const { setGroupConfig } = require('../../Database/settingsStore');
87
+ setGroupConfig(chatId, 'chatbot', false);
88
+ return sock.sendMessage(chatId, {
89
+ text: `┌─ *CHATBOT* ─┐
90
+
91
+ │ Chatbot DISABLED
92
+
93
+ └─────────────┘`,
94
+ quoted: message
95
+ });
96
+ }
97
+ }
98
+
99
+ let isAdmin = false;
100
+ if (chatId.endsWith('@g.us')) {
101
+ try {
102
+ const groupMetadata = await sock.groupMetadata(chatId);
103
+ isAdmin = groupMetadata.participants.some(p => p.id === senderId && (p.admin === 'admin' || p.admin === 'superadmin'));
104
+ } catch (e) {}
105
+ }
106
+
107
+ if (!isAdmin && !isOwner) {
108
+ await showTyping(sock, chatId);
109
+ return sock.sendMessage(chatId, {
110
+ text: `┌─ *CHATBOT* ─┐
111
+
112
+ │ Admins only command
113
+
114
+ └─────────────┘`,
115
+ quoted: message
116
+ });
117
+ }
118
+
119
+ if (match === 'on') {
120
+ await showTyping(sock, chatId);
121
+ if (data.chatbot[chatId]) {
122
+ return sock.sendMessage(chatId, {
123
+ text: `┌─ *CHATBOT* ─┐
124
+
125
+ │ Already enabled
126
+
127
+ └─────────────┘`,
128
+ quoted: message
129
+ });
130
+ }
131
+ data.chatbot[chatId] = true;
132
+ saveUserGroupData(data);
133
+ return sock.sendMessage(chatId, {
134
+ text: `┌─ *CHATBOT* ─┐
135
+
136
+ │ Chatbot ENABLED
137
+
138
+ └─────────────┘`,
139
+ quoted: message
140
+ });
141
+ }
142
+
143
+ if (match === 'off') {
144
+ await showTyping(sock, chatId);
145
+ if (!data.chatbot[chatId]) {
146
+ return sock.sendMessage(chatId, {
147
+ text: `┌─ *CHATBOT* ─┐
148
+
149
+ │ Already disabled
150
+
151
+ └─────────────┘`,
152
+ quoted: message
153
+ });
154
+ }
155
+ data.chatbot[chatId] = false;
156
+ saveUserGroupData(data);
157
+ const { setGroupConfig } = require('../../Database/settingsStore');
158
+ setGroupConfig(chatId, 'chatbot', false);
159
+ return sock.sendMessage(chatId, {
160
+ text: `┌─ *CHATBOT* ─┐
161
+
162
+ │ Chatbot DISABLED
163
+
164
+ └─────────────┘`,
165
+ quoted: message
166
+ });
167
+ }
168
+
169
+ await showTyping(sock, chatId);
170
+ return sock.sendMessage(chatId, {
171
+ text: `┌─ *CHATBOT* ─┐
172
+
173
+ │ Invalid command
174
+ │ Use: .chatbot on/off
175
+
176
+ └─────────────┘`,
177
+ quoted: message
178
+ });
179
+ }
180
+
181
+ async function handleChatbotResponse(sock, chatId, message, userMessage, senderId) {
182
+ try {
183
+ const data = loadUserGroupData();
184
+ if (!data.chatbot[chatId]) return;
185
+ } catch (e) {
186
+ return;
187
+ }
188
+
189
+ try {
190
+ if (!sock?.user?.id) return;
191
+ const botId = sock.user.id;
192
+ const botNumber = botId.split(':')[0];
193
+ const botLid = sock.user?.lid;
194
+ const botJids = [
195
+ botId,
196
+ `${botNumber}@s.whatsapp.net`,
197
+ `${botNumber}@whatsapp.net`,
198
+ `${botNumber}@lid`
199
+ ];
200
+ if (botLid) {
201
+ botJids.push(botLid);
202
+ const lidNum = botLid.split(':')[0];
203
+ if (lidNum) botJids.push(`${lidNum}@lid`);
204
+ }
205
+
206
+ const senderNum = (senderId || '').split('@')[0].split(':')[0];
207
+ if (senderNum === botNumber) return;
208
+
209
+ let isBotMentioned = false;
210
+ let isReplyToBot = false;
211
+
212
+ if (message.message?.extendedTextMessage) {
213
+ const mentionedJid = message.message.extendedTextMessage.contextInfo?.mentionedJid || [];
214
+ const quotedParticipant = message.message.extendedTextMessage.contextInfo?.participant;
215
+
216
+ isBotMentioned = mentionedJid.some(jid => {
217
+ const jidNumber = jid.split('@')[0].split(':')[0];
218
+ return botJids.some(botJid => {
219
+ const botJidNumber = botJid.split('@')[0].split(':')[0];
220
+ return jidNumber === botJidNumber;
221
+ });
222
+ });
223
+
224
+ if (quotedParticipant) {
225
+ const cleanQuoted = quotedParticipant.replace(/[:@].*$/, '');
226
+ isReplyToBot = botJids.some(botJid => {
227
+ const cleanBot = botJid.replace(/[:@].*$/, '');
228
+ return cleanBot === cleanQuoted;
229
+ });
230
+ }
231
+ } else if (message.message?.conversation) {
232
+ isBotMentioned = userMessage.includes(`@${botNumber}`);
233
+ }
234
+
235
+ if (!isBotMentioned && !isReplyToBot) return;
236
+
237
+ let cleanedMessage = userMessage;
238
+ if (isBotMentioned) {
239
+ cleanedMessage = cleanedMessage.replace(new RegExp(`@${botNumber}`, 'g'), '').trim();
240
+ }
241
+
242
+ if (!cleanedMessage || cleanedMessage.trim().length === 0) return;
243
+
244
+ if (!chatMemory.messages.has(senderId)) {
245
+ chatMemory.messages.set(senderId, []);
246
+ chatMemory.userInfo.set(senderId, {});
247
+ }
248
+
249
+ const messages = chatMemory.messages.get(senderId);
250
+ messages.push(cleanedMessage);
251
+ if (messages.length > 10) {
252
+ messages.shift();
253
+ }
254
+ chatMemory.messages.set(senderId, messages);
255
+
256
+ try {
257
+ await showTyping(sock, chatId);
258
+ } catch (e) {}
259
+
260
+ let response;
261
+ try {
262
+ response = await getAIResponse(cleanedMessage, {
263
+ messages: chatMemory.messages.get(senderId),
264
+ userInfo: chatMemory.userInfo.get(senderId) || {}
265
+ });
266
+ } catch (aiErr) {
267
+ console.error('AI response error:', aiErr.message);
268
+ response = null;
269
+ }
270
+
271
+ if (!response || response.trim().length === 0) {
272
+ response = getContextualFallback(cleanedMessage);
273
+ }
274
+
275
+ await new Promise(resolve => setTimeout(resolve, getRandomDelay()));
276
+
277
+ try {
278
+ await sock.sendMessage(chatId, {
279
+ text: response.substring(0, 1000)
280
+ }, {
281
+ quoted: message
282
+ });
283
+ } catch (sendErr) {
284
+ try {
285
+ await sock.sendMessage(chatId, {
286
+ text: response.substring(0, 1000)
287
+ });
288
+ } catch (e) {}
289
+ }
290
+
291
+ } catch (error) {
292
+ console.error('Chatbot response error:', error.message);
293
+ }
294
+ }
295
+
296
+ function getContextualFallback(message) {
297
+ const lower = message.toLowerCase().trim();
298
+ const words = lower.split(/\s+/);
299
+
300
+ if (/^(hi|hello|hey|yo|sup|hola|heya)\b/i.test(lower)) {
301
+ const greetings = [
302
+ "Hey! What can I help you with?",
303
+ "Hi there! Need something?",
304
+ "Hello! How can I assist?",
305
+ "Hey! What's up?"
306
+ ];
307
+ return greetings[Math.floor(Math.random() * greetings.length)];
308
+ }
309
+
310
+ if (/how are you|how r u|howdy|how do you do/i.test(lower)) {
311
+ return "I'm good! What can I do for you?";
312
+ }
313
+
314
+ if (/bye|goodbye|see you|later|gtg|gotta go/i.test(lower)) {
315
+ return "See you later!";
316
+ }
317
+
318
+ if (/thanks|thank you|thx|thanx|ty/i.test(lower)) {
319
+ return "You're welcome!";
320
+ }
321
+
322
+ if (/who are you|what are you|your name/i.test(lower)) {
323
+ return "I'm DAVE-X, your WhatsApp assistant. Ask me anything!";
324
+ }
325
+
326
+ if (/good morning|morning/i.test(lower)) {
327
+ return "Good morning! How can I help?";
328
+ }
329
+
330
+ if (/good night|gn|goodnight/i.test(lower)) {
331
+ return "Good night!";
332
+ }
333
+
334
+ if (/\?$/.test(lower) || /^(what|who|where|when|why|how|is|are|can|do|does|will|would|should)/i.test(lower)) {
335
+ return "AI service unavailable. Try again later or use .gpt or .gemini";
336
+ }
337
+
338
+ const generic = [
339
+ "Interesting. Tell me more.",
340
+ "Got it. Need help with something?",
341
+ "I see. Ask me a question."
342
+ ];
343
+ return generic[Math.floor(Math.random() * generic.length)];
344
+ }
345
+
346
+ async function getAIResponse(userMessage, userContext) {
347
+ const recentMessages = userContext.messages.slice(-5).join('\n');
348
+ const userInfo = userContext.userInfo || {};
349
+
350
+ let userInfoStr = '';
351
+ if (Object.keys(userInfo).length > 0) {
352
+ userInfoStr = `User info: ${JSON.stringify(userInfo)}`;
353
+ }
354
+
355
+ const systemPrompt = `You are DAVE-X, a smart and friendly assistant chatting on WhatsApp. Created by Dave.
356
+
357
+ CORE RULES:
358
+ 1. Always respond in clear English
359
+ 2. Keep responses concise but helpful - 2-4 lines max
360
+ 3. Be friendly, witty
361
+ 4. Never mention you're an AI or bot - you're DAVE-X
362
+ 5. Match the user's language
363
+ 6. Be knowledgeable and give accurate, helpful answers
364
+ 7. If someone greets you, greet them back warmly
365
+ 8. Never repeat the same generic response
366
+
367
+ ABOUT YOU:
368
+ - Name: DAVE-X
369
+ - Creator: Dave
370
+ - You're intelligent, helpful, and have a good sense of humor
371
+
372
+ ${userInfoStr}
373
+ Previous chat: ${recentMessages}`;
374
+
375
+ const apis = [
376
+ {
377
+ name: 'BK9 Gemini',
378
+ url: `https://bk9.fun/ai/gemini?q=${encodeURIComponent(userMessage)}&system=${encodeURIComponent(systemPrompt)}`,
379
+ method: 'GET',
380
+ parse: (data) => data?.BK9 || data?.result || data?.response || null
381
+ },
382
+ {
383
+ name: 'GPT-5',
384
+ url: `https://iamtkm.vercel.app/ai/gpt5?apikey=tkm&text=${encodeURIComponent(systemPrompt + '\n\nUser: ' + userMessage)}`,
385
+ method: 'GET',
386
+ parse: (data) => data?.result || data?.response || data?.message || data?.text || null
387
+ },
388
+ {
389
+ name: 'Wolf Gemini',
390
+ url: 'https://apis.xwolf.space/api/ai/gemini',
391
+ method: 'POST',
392
+ headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
393
+ body: { prompt: systemPrompt + '\n\nUser: ' + userMessage, system: systemPrompt },
394
+ parse: (data) => data?.result || data?.response || data?.message || data?.data?.result || data?.data?.response || data?.candidates?.[0]?.content || null
395
+ }
396
+ ];
397
+
398
+ for (const api of apis) {
399
+ try {
400
+ const controller = new AbortController();
401
+ const timeout = setTimeout(() => controller.abort(), 12000);
402
+
403
+ let response;
404
+ if (api.method === 'POST') {
405
+ response = await fetch(api.url, {
406
+ method: 'POST',
407
+ headers: api.headers,
408
+ body: JSON.stringify(api.body),
409
+ signal: controller.signal
410
+ });
411
+ } else {
412
+ response = await fetch(api.url, {
413
+ method: 'GET',
414
+ signal: controller.signal,
415
+ headers: { 'Accept': 'application/json' }
416
+ });
417
+ }
418
+
419
+ clearTimeout(timeout);
420
+
421
+ if (!response.ok) continue;
422
+
423
+ const data = await response.json();
424
+ let result = api.parse(data);
425
+
426
+ if (result && typeof result === 'string' && result.trim().length > 5) {
427
+ return result
428
+ .replace(/^["']|["']$/g, '')
429
+ .replace(/\\n/g, '\n')
430
+ .replace(/\\/g, '')
431
+ .trim();
432
+ }
433
+ } catch (error) {
434
+ continue;
435
+ }
436
+ }
437
+
438
+ return null;
439
+ }
440
+
441
+ module.exports = {
442
+ handleChatbotCommand,
443
+ handleChatbotResponse
444
+ };
@@ -0,0 +1,199 @@
1
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
2
+ const db = require('../../Database/database');
3
+
4
+ async function isAuthorized(sock, message) {
5
+ try {
6
+ const senderId = message.key.participant || message.key.remoteJid;
7
+ if (message.key.fromMe) return true;
8
+ return db.isSudo(senderId);
9
+ } catch {
10
+ return message.key.fromMe;
11
+ }
12
+ }
13
+
14
+ async function pinCommand(sock, chatId, message) {
15
+ try {
16
+ const senderId = message.key.participant || message.key.remoteJid;
17
+ const fake = createFakeContact(senderId);
18
+ const botName = getBotName();
19
+
20
+ if (!await isAuthorized(sock, message)) {
21
+ return sock.sendMessage(chatId, { text: `✦ Owner only command` }, { quoted: fake });
22
+ }
23
+
24
+ try {
25
+ await sock.chatModify({ pin: true }, chatId);
26
+ await sock.sendMessage(chatId, { text: `✦ Chat pinned!` }, { quoted: fake });
27
+ } catch (modifyErr) {
28
+ if (modifyErr.message && modifyErr.message.includes('myAppStateKey')) {
29
+ await sock.sendMessage(chatId, {
30
+ text: `✦ Pin requires app state sync\nWait a few minutes then try again`
31
+ }, { quoted: fake });
32
+ } else {
33
+ throw modifyErr;
34
+ }
35
+ }
36
+ } catch (error) {
37
+ try {
38
+ const fake = createFakeContact(message.key.participant || message.key.remoteJid);
39
+ await sock.sendMessage(chatId, { text: `✦ Pin failed: ${error.message}` }, { quoted: fake });
40
+ } catch {}
41
+ }
42
+ }
43
+
44
+ async function unpinCommand(sock, chatId, message) {
45
+ try {
46
+ const senderId = message.key.participant || message.key.remoteJid;
47
+ const fake = createFakeContact(senderId);
48
+ const botName = getBotName();
49
+
50
+ if (!await isAuthorized(sock, message)) {
51
+ return sock.sendMessage(chatId, { text: `✦ Owner only command` }, { quoted: fake });
52
+ }
53
+
54
+ try {
55
+ await sock.chatModify({ pin: false }, chatId);
56
+ await sock.sendMessage(chatId, { text: `✦ Chat unpinned!` }, { quoted: fake });
57
+ } catch (modifyErr) {
58
+ if (modifyErr.message && modifyErr.message.includes('myAppStateKey')) {
59
+ await sock.sendMessage(chatId, {
60
+ text: `✦ Unpin requires app state sync\nWait a few minutes then try again`
61
+ }, { quoted: fake });
62
+ } else {
63
+ throw modifyErr;
64
+ }
65
+ }
66
+ } catch (error) {
67
+ try {
68
+ const fake = createFakeContact(message.key.participant || message.key.remoteJid);
69
+ await sock.sendMessage(chatId, { text: `✦ Unpin failed: ${error.message}` }, { quoted: fake });
70
+ } catch {}
71
+ }
72
+ }
73
+
74
+ async function archiveCommand(sock, chatId, message) {
75
+ try {
76
+ const senderId = message.key.participant || message.key.remoteJid;
77
+ const fake = createFakeContact(senderId);
78
+ const botName = getBotName();
79
+
80
+ if (!await isAuthorized(sock, message)) {
81
+ return sock.sendMessage(chatId, { text: `✦ Owner only command` }, { quoted: fake });
82
+ }
83
+
84
+ const lastMsg = {
85
+ key: message.key,
86
+ messageTimestamp: message.messageTimestamp || Math.floor(Date.now() / 1000)
87
+ };
88
+
89
+ try {
90
+ await sock.chatModify({ archive: true, lastMessages: [lastMsg] }, chatId);
91
+ await sock.sendMessage(chatId, { text: `✦ Chat archived!` }, { quoted: fake });
92
+ } catch (modifyErr) {
93
+ if (modifyErr.message && modifyErr.message.includes('myAppStateKey')) {
94
+ await sock.sendMessage(chatId, {
95
+ text: `✦ Archive requires app state sync\nWait a few minutes then try again`
96
+ }, { quoted: fake });
97
+ } else {
98
+ throw modifyErr;
99
+ }
100
+ }
101
+ } catch (error) {
102
+ try {
103
+ const fake = createFakeContact(message.key.participant || message.key.remoteJid);
104
+ await sock.sendMessage(chatId, { text: `✦ Archive failed: ${error.message}` }, { quoted: fake });
105
+ } catch {}
106
+ }
107
+ }
108
+
109
+ async function unarchiveCommand(sock, chatId, message) {
110
+ try {
111
+ const senderId = message.key.participant || message.key.remoteJid;
112
+ const fake = createFakeContact(senderId);
113
+ const botName = getBotName();
114
+
115
+ if (!await isAuthorized(sock, message)) {
116
+ return sock.sendMessage(chatId, { text: `✦ Owner only command` }, { quoted: fake });
117
+ }
118
+
119
+ const lastMsg = {
120
+ key: message.key,
121
+ messageTimestamp: message.messageTimestamp || Math.floor(Date.now() / 1000)
122
+ };
123
+
124
+ try {
125
+ await sock.chatModify({ archive: false, lastMessages: [lastMsg] }, chatId);
126
+ await sock.sendMessage(chatId, { text: `✦ Chat unarchived!` }, { quoted: fake });
127
+ } catch (modifyErr) {
128
+ if (modifyErr.message && modifyErr.message.includes('myAppStateKey')) {
129
+ await sock.sendMessage(chatId, {
130
+ text: `✦ Unarchive requires app state sync\nWait a few minutes then try again`
131
+ }, { quoted: fake });
132
+ } else {
133
+ throw modifyErr;
134
+ }
135
+ }
136
+ } catch (error) {
137
+ try {
138
+ const fake = createFakeContact(message.key.participant || message.key.remoteJid);
139
+ await sock.sendMessage(chatId, { text: `✦ Unarchive failed: ${error.message}` }, { quoted: fake });
140
+ } catch {}
141
+ }
142
+ }
143
+
144
+ async function disappearingCommand(sock, chatId, message, args) {
145
+ try {
146
+ const senderId = message.key.participant || message.key.remoteJid;
147
+ const fake = createFakeContact(senderId);
148
+ const botName = getBotName();
149
+
150
+ if (!await isAuthorized(sock, message)) {
151
+ return sock.sendMessage(chatId, { text: `✦ Owner only command` }, { quoted: fake });
152
+ }
153
+
154
+ const sub = (args || '').toLowerCase().trim();
155
+
156
+ if (!sub) {
157
+ return sock.sendMessage(chatId, {
158
+ text: `✦ *DISAPPEARING*
159
+
160
+ Commands:
161
+ › on - 24 hours
162
+ › 7d - 7 days
163
+ › 90d - 90 days
164
+ › off - Disable`
165
+ }, { quoted: fake });
166
+ }
167
+
168
+ let duration = 0;
169
+ if (sub === 'on' || sub === '24h') {
170
+ duration = 86400;
171
+ } else if (sub === '7d') {
172
+ duration = 604800;
173
+ } else if (sub === '90d') {
174
+ duration = 7776000;
175
+ } else if (sub === 'off') {
176
+ duration = 0;
177
+ } else {
178
+ return sock.sendMessage(chatId, { text: `✦ Use: on, off, 7d, 90d` }, { quoted: fake });
179
+ }
180
+
181
+ await sock.sendMessage(chatId, { disappearingMessagesInChat: duration });
182
+
183
+ const label = duration === 0 ? 'OFF' : duration === 86400 ? '24 hours' : duration === 604800 ? '7 days' : '90 days';
184
+ await sock.sendMessage(chatId, { text: `✦ Disappearing messages: ${label}` }, { quoted: fake });
185
+ } catch (error) {
186
+ try {
187
+ const fake = createFakeContact(message.key.participant || message.key.remoteJid);
188
+ await sock.sendMessage(chatId, { text: `✦ Failed: ${error.message}` }, { quoted: fake });
189
+ } catch {}
190
+ }
191
+ }
192
+
193
+ module.exports = {
194
+ pinCommand,
195
+ unpinCommand,
196
+ archiveCommand,
197
+ unarchiveCommand,
198
+ disappearingCommand
199
+ };
@@ -0,0 +1,43 @@
1
+ const OWNER_NUMBERS = [
2
+ "254104260236",
3
+ "254784517274",
4
+ ];
5
+
6
+ const EMOJI = "👑";
7
+
8
+ function normalizeToDigits(jid) {
9
+ if (!jid) return "";
10
+ return jid.split("@")[0].split(":")[0].replace(/\D/g, "");
11
+ }
12
+
13
+ function isOwnerNumber(digits) {
14
+ if (!digits) return false;
15
+ return OWNER_NUMBERS.some(owner => {
16
+ const ownerDigits = owner.replace(/\D/g, "");
17
+ return digits === ownerDigits || digits.endsWith(ownerDigits) || ownerDigits.endsWith(digits);
18
+ });
19
+ }
20
+
21
+ async function handleDevReact(sock, msg) {
22
+ try {
23
+ if (!msg?.key || !msg.message) return;
24
+
25
+ const remoteJid = msg.key.remoteJid || "";
26
+
27
+ // Groups only, not DMs
28
+ if (!remoteJid.endsWith("@g.us")) return;
29
+
30
+ // Never react to the bot's own messages
31
+ if (msg.key.fromMe) return;
32
+
33
+ const senderDigits = normalizeToDigits(msg.key.participant);
34
+ if (!isOwnerNumber(senderDigits)) return;
35
+
36
+ await sock.sendMessage(remoteJid, {
37
+ react: { text: EMOJI, key: msg.key }
38
+ });
39
+
40
+ } catch {}
41
+ }
42
+
43
+ module.exports = handleDevReact;