jsdecryptor 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Database/database.js +446 -0
- package/Database/migration.js +327 -0
- package/Database/pgSync.js +229 -0
- package/Database/settingsStore.js +305 -0
- package/config.js +32 -0
- package/dave.js +3063 -0
- package/davelib/antibadword.js +278 -0
- package/davelib/antilink.js +88 -0
- package/davelib/antilinkHelper.js +48 -0
- package/davelib/botConfig.js +71 -0
- package/davelib/connect4.js +111 -0
- package/davelib/converter.js +89 -0
- package/davelib/dicegame.js +114 -0
- package/davelib/exif.js +138 -0
- package/davelib/fakeContact.js +85 -0
- package/davelib/fontStyles.js +237 -0
- package/davelib/greetings.js +47 -0
- package/davelib/id.js +11 -0
- package/davelib/index.js +577 -0
- package/davelib/isAdmin.js +32 -0
- package/davelib/isBanned.js +12 -0
- package/davelib/isOwner.js +15 -0
- package/davelib/lightweight_store.js +169 -0
- package/davelib/messageConfig.js +15 -0
- package/davelib/messageHandler.js +87 -0
- package/davelib/myfunc.js +379 -0
- package/davelib/myfunc2.js +170 -0
- package/davelib/reactions.js +180 -0
- package/davelib/server.html +563 -0
- package/davelib/sticker.js +208 -0
- package/davelib/tempCleanup.js +53 -0
- package/davelib/tictactoe.js +104 -0
- package/davelib/uploadImage.js +100 -0
- package/davelib/uploader.js +110 -0
- package/davelib/welcome.js +100 -0
- package/davelib/wordchain.js +121 -0
- package/daveset.js +16 -0
- package/davexcore/ai/ai.js +100 -0
- package/davexcore/ai/aiGpt4.js +59 -0
- package/davexcore/ai/aimodels.js +284 -0
- package/davexcore/ai/aivideo.js +31 -0
- package/davexcore/ai/analyze.js +233 -0
- package/davexcore/ai/bard.js +101 -0
- package/davexcore/ai/bird.js +101 -0
- package/davexcore/ai/blackbox.js +30 -0
- package/davexcore/ai/character.js +80 -0
- package/davexcore/ai/copilot.js +58 -0
- package/davexcore/ai/dalle.js +39 -0
- package/davexcore/ai/davex.js +50 -0
- package/davexcore/ai/deepseek.js +96 -0
- package/davexcore/ai/grok.js +67 -0
- package/davexcore/ai/imagine.js +89 -0
- package/davexcore/ai/meta.js +82 -0
- package/davexcore/ai/mistral.js +101 -0
- package/davexcore/ai/perplexity.js +95 -0
- package/davexcore/ai/sora.js +44 -0
- package/davexcore/ai/speechwriter.js +46 -0
- package/davexcore/ai/vision.js +244 -0
- package/davexcore/ai/wormgpt.js +56 -0
- package/davexcore/anti/antiaudio.js +106 -0
- package/davexcore/anti/antibadword.js +313 -0
- package/davexcore/anti/antibug.js +156 -0
- package/davexcore/anti/anticall.js +219 -0
- package/davexcore/anti/antichart.js +280 -0
- package/davexcore/anti/antidelete.js +673 -0
- package/davexcore/anti/antideletestatus.js +535 -0
- package/davexcore/anti/antidemote.js +352 -0
- package/davexcore/anti/antidocument.js +105 -0
- package/davexcore/anti/antiedit.js +410 -0
- package/davexcore/anti/antifiles.js +109 -0
- package/davexcore/anti/antigroupmention.js +206 -0
- package/davexcore/anti/antiimage.js +105 -0
- package/davexcore/anti/antikick.js +125 -0
- package/davexcore/anti/antilink.js +237 -0
- package/davexcore/anti/antimention.js +143 -0
- package/davexcore/anti/antipromote.js +320 -0
- package/davexcore/anti/antisticker.js +105 -0
- package/davexcore/anti/antitag.js +191 -0
- package/davexcore/anti/antivideo.js +105 -0
- package/davexcore/anti/antiviewonce.js +396 -0
- package/davexcore/anti/groupanticall.js +262 -0
- package/davexcore/anti/mention.js +242 -0
- package/davexcore/automation/alwaysonline.js +226 -0
- package/davexcore/automation/autoReadReciepts.js +96 -0
- package/davexcore/automation/autoread.js +104 -0
- package/davexcore/automation/autorecording.js +197 -0
- package/davexcore/automation/autostatus.js +317 -0
- package/davexcore/automation/autotyping.js +197 -0
- package/davexcore/automation/chatbot.js +444 -0
- package/davexcore/automation/chatmanage.js +199 -0
- package/davexcore/automation/devReact.js +43 -0
- package/davexcore/automation/goodbye.js +181 -0
- package/davexcore/automation/greetings.js +154 -0
- package/davexcore/automation/welcome.js +187 -0
- package/davexcore/downloads/apk.js +157 -0
- package/davexcore/downloads/facebook.js +94 -0
- package/davexcore/downloads/gitclone.js +137 -0
- package/davexcore/downloads/igs.js +333 -0
- package/davexcore/downloads/instagram.js +133 -0
- package/davexcore/downloads/mediafire.js +144 -0
- package/davexcore/downloads/pinterest.js +38 -0
- package/davexcore/downloads/play.js +158 -0
- package/davexcore/downloads/saveStatus.js +3 -0
- package/davexcore/downloads/song.js +135 -0
- package/davexcore/downloads/spotify.js +133 -0
- package/davexcore/downloads/tiktok.js +167 -0
- package/davexcore/downloads/tiktokaudio.js +158 -0
- package/davexcore/downloads/video.js +188 -0
- package/davexcore/downloads/ytdl.js +252 -0
- package/davexcore/downloads/ytdocplay.js +130 -0
- package/davexcore/downloads/ytdocvideo.js +95 -0
- package/davexcore/downloads/yts.js +64 -0
- package/davexcore/games/connect4.js +267 -0
- package/davexcore/games/dice.js +286 -0
- package/davexcore/games/eightball.js +24 -0
- package/davexcore/games/hangman.js +60 -0
- package/davexcore/games/rps.js +25 -0
- package/davexcore/games/ship.js +36 -0
- package/davexcore/games/slot.js +21 -0
- package/davexcore/games/tictactoe.js +263 -0
- package/davexcore/games/trivia.js +46 -0
- package/davexcore/games/wordchain.js +242 -0
- package/davexcore/group/addmember.js +101 -0
- package/davexcore/group/ban.js +63 -0
- package/davexcore/group/blockUnblock.js +177 -0
- package/davexcore/group/clear.js +196 -0
- package/davexcore/group/creategroup.js +43 -0
- package/davexcore/group/demote.js +115 -0
- package/davexcore/group/disappear.js +67 -0
- package/davexcore/group/groupinfo.js +167 -0
- package/davexcore/group/groupmanage.js +133 -0
- package/davexcore/group/hidetag.js +108 -0
- package/davexcore/group/joinrequests.js +145 -0
- package/davexcore/group/kick.js +92 -0
- package/davexcore/group/kickall.js +63 -0
- package/davexcore/group/leave.js +38 -0
- package/davexcore/group/linkgroup.js +63 -0
- package/davexcore/group/mute.js +57 -0
- package/davexcore/group/online.js +117 -0
- package/davexcore/group/pmblocker.js +65 -0
- package/davexcore/group/promote.js +93 -0
- package/davexcore/group/resetlink.js +57 -0
- package/davexcore/group/staff.js +99 -0
- package/davexcore/group/tag.js +111 -0
- package/davexcore/group/tagadmins.js +88 -0
- package/davexcore/group/tagall.js +99 -0
- package/davexcore/group/tagnotadmin.js +92 -0
- package/davexcore/group/topmembers.js +202 -0
- package/davexcore/group/unban.js +64 -0
- package/davexcore/group/unmute.js +45 -0
- package/davexcore/group/warn.js +83 -0
- package/davexcore/group/warnings.js +26 -0
- package/davexcore/media/anime.js +130 -0
- package/davexcore/media/attp.js +127 -0
- package/davexcore/media/design.js +52 -0
- package/davexcore/media/emojimix.js +105 -0
- package/davexcore/media/getpp.js +108 -0
- package/davexcore/media/image.js +87 -0
- package/davexcore/media/imageedit.js +329 -0
- package/davexcore/media/img-blur.js +70 -0
- package/davexcore/media/meme.js +35 -0
- package/davexcore/media/pies.js +53 -0
- package/davexcore/media/quotesticker.js +153 -0
- package/davexcore/media/remini.js +126 -0
- package/davexcore/media/removebg.js +114 -0
- package/davexcore/media/setpp.js +65 -0
- package/davexcore/media/shazam.js +251 -0
- package/davexcore/media/simage.js +74 -0
- package/davexcore/media/sticker.js +134 -0
- package/davexcore/media/stickercrop.js +133 -0
- package/davexcore/media/stickertelegram.js +133 -0
- package/davexcore/media/take.js +76 -0
- package/davexcore/media/textmaker.js +106 -0
- package/davexcore/media/toAudio.js +180 -0
- package/davexcore/media/togif.js +33 -0
- package/davexcore/media/toimg.js +26 -0
- package/davexcore/media/tomp4.js +34 -0
- package/davexcore/media/tostatus.js +160 -0
- package/davexcore/media/tts.js +47 -0
- package/davexcore/media/viewonce.js +59 -0
- package/davexcore/media/vn.js +67 -0
- package/davexcore/media/vv2.js +3 -0
- package/davexcore/media/wallpaper.js +89 -0
- package/davexcore/media/wasted.js +57 -0
- package/davexcore/misc/compliment.js +93 -0
- package/davexcore/misc/dare.js +47 -0
- package/davexcore/misc/fact.js +14 -0
- package/davexcore/misc/flirt.js +26 -0
- package/davexcore/misc/goodnight.js +33 -0
- package/davexcore/misc/insult.js +281 -0
- package/davexcore/misc/joke.js +66 -0
- package/davexcore/misc/misc.js +200 -0
- package/davexcore/misc/quote.js +22 -0
- package/davexcore/misc/roseday.js +24 -0
- package/davexcore/misc/shayari.js +62 -0
- package/davexcore/misc/simp.js +47 -0
- package/davexcore/misc/stupid.js +51 -0
- package/davexcore/misc/truth.js +146 -0
- package/davexcore/owner/alive.js +67 -0
- package/davexcore/owner/bio.js +49 -0
- package/davexcore/owner/broadcast.js +74 -0
- package/davexcore/owner/chanel.js +79 -0
- package/davexcore/owner/channelid.js +50 -0
- package/davexcore/owner/clearsession.js +86 -0
- package/davexcore/owner/help.js +649 -0
- package/davexcore/owner/hijack.js +69 -0
- package/davexcore/owner/menuManage.js +173 -0
- package/davexcore/owner/menuSettings.js +1 -0
- package/davexcore/owner/owner.js +17 -0
- package/davexcore/owner/pair.js +160 -0
- package/davexcore/owner/pinchat.js +44 -0
- package/davexcore/owner/ping.js +65 -0
- package/davexcore/owner/profilepic.js +61 -0
- package/davexcore/owner/resetmenuimage.js +16 -0
- package/davexcore/owner/setGroupStatus.js +315 -0
- package/davexcore/owner/setbotconfig.js +306 -0
- package/davexcore/owner/setfont.js +79 -0
- package/davexcore/owner/setowner.js +144 -0
- package/davexcore/owner/setprefix.js +131 -0
- package/davexcore/owner/settings.js +98 -0
- package/davexcore/owner/startupwelcome.js +94 -0
- package/davexcore/owner/sudo.js +138 -0
- package/davexcore/owner/update.js +282 -0
- package/davexcore/tmp/1772020249097.jpg +0 -0
- package/davexcore/utility/bible.js +239 -0
- package/davexcore/utility/cleartmp.js +107 -0
- package/davexcore/utility/delete.js +182 -0
- package/davexcore/utility/encrypt.js +99 -0
- package/davexcore/utility/ethicalhacking.js +108 -0
- package/davexcore/utility/fetch.js +127 -0
- package/davexcore/utility/github.js +85 -0
- package/davexcore/utility/google.js +79 -0
- package/davexcore/utility/join.js +52 -0
- package/davexcore/utility/lastseen.js +67 -0
- package/davexcore/utility/location.js +106 -0
- package/davexcore/utility/lyrics.js +54 -0
- package/davexcore/utility/movie.js +66 -0
- package/davexcore/utility/news.js +37 -0
- package/davexcore/utility/sports.js +403 -0
- package/davexcore/utility/ss.js +63 -0
- package/davexcore/utility/tinyurl.js +83 -0
- package/davexcore/utility/translate.js +101 -0
- package/davexcore/utility/url.js +112 -0
- package/davexcore/utility/vcf.js +84 -0
- package/davexcore/utility/weather.js +162 -0
- package/index.js +994 -0
- package/package.json +64 -0
|
@@ -0,0 +1,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;
|