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,282 @@
|
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const crypto = require('crypto');
|
|
5
|
+
const https = require('https');
|
|
6
|
+
const settings = require('../../daveset');
|
|
7
|
+
const isOwnerOrSudo = require('../../davelib/isOwner');
|
|
8
|
+
|
|
9
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
10
|
+
function run(cmd) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
exec(cmd, { windowsHide: true }, (err, stdout, stderr) => {
|
|
13
|
+
if (err) return reject(new Error(stderr || stdout || err.message));
|
|
14
|
+
resolve(stdout.toString().trim());
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const SKIP_DIRS = new Set([
|
|
20
|
+
'node_modules', '.git', 'tmp', 'temp', 'attached_assets'
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const PROTECTED_FILES = new Set([
|
|
24
|
+
'.env', 'baileys_store.json', '.migration_status.json',
|
|
25
|
+
'package-lock.json', 'creds.json', 'settings.js',
|
|
26
|
+
'replit.md', '.replit', 'replit.nix'
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const PROTECTED_DIR_PREFIXES = [
|
|
30
|
+
'session/',
|
|
31
|
+
'persistent_data/',
|
|
32
|
+
'data/',
|
|
33
|
+
'auth_info/',
|
|
34
|
+
'auth_info_baileys/',
|
|
35
|
+
'.local/'
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
function isProtected(relativePath) {
|
|
39
|
+
if (PROTECTED_FILES.has(relativePath)) return true;
|
|
40
|
+
for (const prefix of PROTECTED_DIR_PREFIXES) {
|
|
41
|
+
if (relativePath.startsWith(prefix)) return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function shouldSkipDir(dirName) {
|
|
47
|
+
return SKIP_DIRS.has(dirName);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function fileHash(filePath) {
|
|
51
|
+
try {
|
|
52
|
+
const content = fs.readFileSync(filePath);
|
|
53
|
+
return crypto.createHash('md5').update(content).digest('hex');
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function hasGitRepo() {
|
|
60
|
+
const gitDir = path.join(process.cwd(), '.git');
|
|
61
|
+
if (!fs.existsSync(gitDir)) return false;
|
|
62
|
+
try {
|
|
63
|
+
await run('git --version');
|
|
64
|
+
return true;
|
|
65
|
+
} catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function backupProtectedFiles() {
|
|
71
|
+
const backups = {};
|
|
72
|
+
const filesToBackup = [...PROTECTED_FILES];
|
|
73
|
+
for (const dir of PROTECTED_DIR_PREFIXES) {
|
|
74
|
+
const dirPath = path.join(process.cwd(), dir.replace(/\/$/, ''));
|
|
75
|
+
if (fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory()) {
|
|
76
|
+
filesToBackup.push(dir);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const file of PROTECTED_FILES) {
|
|
80
|
+
const filePath = path.join(process.cwd(), file);
|
|
81
|
+
if (fs.existsSync(filePath)) {
|
|
82
|
+
try {
|
|
83
|
+
backups[file] = fs.readFileSync(filePath);
|
|
84
|
+
} catch {}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return backups;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function restoreProtectedFiles(backups) {
|
|
91
|
+
for (const [file, content] of Object.entries(backups)) {
|
|
92
|
+
const filePath = path.join(process.cwd(), file);
|
|
93
|
+
try {
|
|
94
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
95
|
+
fs.writeFileSync(filePath, content);
|
|
96
|
+
} catch {}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function updateViaGit() {
|
|
101
|
+
const oldRev = await run('git rev-parse HEAD').catch(() => 'unknown');
|
|
102
|
+
await run('git fetch --all --prune 2>/dev/null');
|
|
103
|
+
const newRev = await run('git rev-parse origin/main').catch(() => 'unknown');
|
|
104
|
+
|
|
105
|
+
const alreadyUpToDate = oldRev === newRev;
|
|
106
|
+
const commits = alreadyUpToDate ? '' : await run(`git log --pretty=format:"%h %s" ${oldRev}..${newRev}`).catch(() => '');
|
|
107
|
+
|
|
108
|
+
const backups = backupProtectedFiles();
|
|
109
|
+
|
|
110
|
+
await run(`git reset --hard ${newRev}`);
|
|
111
|
+
await run('git clean -fd -e session/ -e data/ -e persistent_data/ -e auth_info/ -e auth_info_baileys/ -e creds.json -e settings.js -e .env');
|
|
112
|
+
|
|
113
|
+
restoreProtectedFiles(backups);
|
|
114
|
+
|
|
115
|
+
return { oldRev, newRev, alreadyUpToDate, commits };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function downloadFile(url, dest, visited = new Set()) {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
if (visited.has(url) || visited.size > 5) return reject(new Error('Too many redirects'));
|
|
121
|
+
visited.add(url);
|
|
122
|
+
|
|
123
|
+
const client = url.startsWith('https://') ? https : require('http');
|
|
124
|
+
const req = client.get(url, { headers: { 'User-Agent': 'DAVE-X-Updater/3.0' } }, res => {
|
|
125
|
+
if ([301, 302, 303, 307, 308].includes(res.statusCode)) {
|
|
126
|
+
const nextUrl = new URL(res.headers.location, url).toString();
|
|
127
|
+
res.resume();
|
|
128
|
+
return downloadFile(nextUrl, dest, visited).then(resolve).catch(reject);
|
|
129
|
+
}
|
|
130
|
+
if (res.statusCode !== 200) return reject(new Error(`HTTP ${res.statusCode}`));
|
|
131
|
+
|
|
132
|
+
const file = fs.createWriteStream(dest);
|
|
133
|
+
res.pipe(file);
|
|
134
|
+
file.on('finish', () => file.close(resolve));
|
|
135
|
+
file.on('error', err => {
|
|
136
|
+
fs.unlink(dest, () => reject(err));
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
req.on('error', err => fs.unlink(dest, () => reject(err)));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function extractZip(zipPath, outDir) {
|
|
144
|
+
if (process.platform === 'win32') {
|
|
145
|
+
await run(`powershell -NoProfile -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${outDir}' -Force"`);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
for (const tool of ['unzip', '7z', 'busybox unzip']) {
|
|
149
|
+
try {
|
|
150
|
+
await run(`command -v ${tool.split(' ')[0]}`);
|
|
151
|
+
await run(`${tool} -o '${zipPath}' -d '${outDir}'`);
|
|
152
|
+
return;
|
|
153
|
+
} catch {}
|
|
154
|
+
}
|
|
155
|
+
throw new Error("No unzip tool found");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function smartCopyRecursive(src, dest, ignoreTopLevel = [], relative = '', stats = { updated: [], skipped: [], added: [] }) {
|
|
159
|
+
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
|
160
|
+
for (const entry of fs.readdirSync(src)) {
|
|
161
|
+
if (ignoreTopLevel.includes(entry) && relative === '') continue;
|
|
162
|
+
const s = path.join(src, entry);
|
|
163
|
+
const d = path.join(dest, entry);
|
|
164
|
+
const rel = relative ? `${relative}/${entry}` : entry;
|
|
165
|
+
const stat = fs.lstatSync(s);
|
|
166
|
+
|
|
167
|
+
if (stat.isDirectory()) {
|
|
168
|
+
if (shouldSkipDir(entry)) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
smartCopyRecursive(s, d, ignoreTopLevel, rel, stats);
|
|
172
|
+
} else {
|
|
173
|
+
if (isProtected(rel)) {
|
|
174
|
+
stats.skipped.push(rel);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (fs.existsSync(d)) {
|
|
179
|
+
const srcHash = fileHash(s);
|
|
180
|
+
const destHash = fileHash(d);
|
|
181
|
+
if (srcHash && destHash && srcHash === destHash) {
|
|
182
|
+
stats.skipped.push(rel);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
stats.updated.push(rel);
|
|
186
|
+
} else {
|
|
187
|
+
stats.added.push(rel);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
fs.mkdirSync(path.dirname(d), { recursive: true });
|
|
191
|
+
fs.copyFileSync(s, d);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return stats;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async function updateViaZip(zipUrl) {
|
|
198
|
+
if (!zipUrl) throw new Error('No ZIP URL configured.');
|
|
199
|
+
|
|
200
|
+
const tmpDir = path.join(process.cwd(), 'tmp');
|
|
201
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
202
|
+
|
|
203
|
+
const zipPath = path.join(tmpDir, 'update.zip');
|
|
204
|
+
await downloadFile(zipUrl, zipPath);
|
|
205
|
+
|
|
206
|
+
const extractTo = path.join(tmpDir, 'update_extract');
|
|
207
|
+
fs.rmSync(extractTo, { recursive: true, force: true });
|
|
208
|
+
await extractZip(zipPath, extractTo);
|
|
209
|
+
|
|
210
|
+
const entries = fs.readdirSync(extractTo);
|
|
211
|
+
const root = entries.length === 1 && fs.lstatSync(path.join(extractTo, entries[0])).isDirectory()
|
|
212
|
+
? path.join(extractTo, entries[0])
|
|
213
|
+
: extractTo;
|
|
214
|
+
|
|
215
|
+
const ignoreTopLevel = ['node_modules', '.git', 'tmp', 'temp'];
|
|
216
|
+
const stats = smartCopyRecursive(root, process.cwd(), ignoreTopLevel, '', { updated: [], skipped: [], added: [] });
|
|
217
|
+
|
|
218
|
+
fs.rmSync(extractTo, { recursive: true, force: true });
|
|
219
|
+
fs.rmSync(zipPath, { force: true });
|
|
220
|
+
|
|
221
|
+
return stats;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async function restartProcess(sock, chatId, message) {
|
|
225
|
+
const fakeContact = createFakeContact(message);
|
|
226
|
+
await sock.sendMessage(chatId, { text: 'Update finished restarting' }, { quoted: fakeContact }).catch(() => {});
|
|
227
|
+
try {
|
|
228
|
+
await run('pm2 restart all');
|
|
229
|
+
} catch {
|
|
230
|
+
setTimeout(() => process.exit(0), 500);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async function updateCommand(sock, chatId, message, zipOverride) {
|
|
235
|
+
const fakeContact = createFakeContact(message);
|
|
236
|
+
const botName = getBotName();
|
|
237
|
+
const senderId = message.key.participant || message.key.remoteJid;
|
|
238
|
+
const isOwner = await isOwnerOrSudo(senderId, sock, chatId);
|
|
239
|
+
|
|
240
|
+
if (!message.key.fromMe && !isOwner) {
|
|
241
|
+
return sock.sendMessage(chatId, { text: `*${botName}*\nOwner only command!` }, { quoted: fakeContact });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let statusMessage;
|
|
245
|
+
try {
|
|
246
|
+
statusMessage = await sock.sendMessage(chatId, { text: `*${botName} UPDATE*\n\nInitializing update...\nYour settings and data will be preserved` }, { quoted: fakeContact });
|
|
247
|
+
|
|
248
|
+
if (await hasGitRepo()) {
|
|
249
|
+
await sock.sendMessage(chatId, { text: `*${botName} UPDATE*\n\nSyncing repository...`, edit: statusMessage.key });
|
|
250
|
+
const { oldRev, newRev, alreadyUpToDate } = await updateViaGit();
|
|
251
|
+
const summary = alreadyUpToDate ? 'Already up to date!' : `Updated: ${oldRev.slice(0, 7)} -> ${newRev.slice(0, 7)}`;
|
|
252
|
+
await sock.sendMessage(chatId, { text: `*${botName} UPDATE*\n\n${summary}\nInstalling dependencies...`, edit: statusMessage.key });
|
|
253
|
+
} else {
|
|
254
|
+
await sock.sendMessage(chatId, { text: `*${botName} UPDATE*\n\nDownloading update archive...`, edit: statusMessage.key });
|
|
255
|
+
const stats = await updateViaZip(zipOverride || settings.updateZipUrl || process.env.UPDATE_ZIP_URL);
|
|
256
|
+
|
|
257
|
+
let summary = `*${botName} UPDATE*\n\n`;
|
|
258
|
+
summary += `Updated: ${stats.updated.length} files\n`;
|
|
259
|
+
summary += `Added: ${stats.added.length} new files\n`;
|
|
260
|
+
summary += `Skipped: ${stats.skipped.length} files\n`;
|
|
261
|
+
summary += `Settings & data: preserved\n`;
|
|
262
|
+
summary += `Installing dependencies...`;
|
|
263
|
+
|
|
264
|
+
await sock.sendMessage(chatId, { text: summary, edit: statusMessage.key });
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
await run('npm install --no-audit --no-fund 2>/dev/null');
|
|
268
|
+
await sock.sendMessage(chatId, { text: `*${botName} UPDATE*\n\nUpdate complete! Settings preserved.\nRestarting...`, edit: statusMessage.key });
|
|
269
|
+
await restartProcess(sock, chatId, message);
|
|
270
|
+
} catch (err) {
|
|
271
|
+
console.error('Update failed:', err);
|
|
272
|
+
const safeErr = String(err.message || err).replace(/https?:\/\/[^\s]+/g, '[hidden]').slice(0, 500);
|
|
273
|
+
const errorMsg = `*${botName} UPDATE*\n\nUpdate failed: ${safeErr}`;
|
|
274
|
+
if (statusMessage?.key) {
|
|
275
|
+
await sock.sendMessage(chatId, { text: errorMsg, edit: statusMessage.key });
|
|
276
|
+
} else {
|
|
277
|
+
await sock.sendMessage(chatId, { text: errorMsg }, { quoted: fakeContact });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
module.exports = updateCommand;
|
|
Binary file
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
const fetch = require('node-fetch');
|
|
2
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
3
|
+
|
|
4
|
+
async function bibleCommand(sock, chatId, message, text, prefix) {
|
|
5
|
+
try {
|
|
6
|
+
const fake = createFakeContact(message);
|
|
7
|
+
const BASE_URL = "https://bible-api.com";
|
|
8
|
+
|
|
9
|
+
if (!text || text.trim() === '') {
|
|
10
|
+
await sock.sendMessage(chatId, {
|
|
11
|
+
text: `✦ *BIBLE*
|
|
12
|
+
╭─────────────────
|
|
13
|
+
│
|
|
14
|
+
│ Usage:
|
|
15
|
+
│ ${prefix}bible <chapter:verse>
|
|
16
|
+
│
|
|
17
|
+
│ Examples:
|
|
18
|
+
│ ${prefix}bible John 3:16
|
|
19
|
+
│ ${prefix}bible Genesis 1:1
|
|
20
|
+
│ ${prefix}bible Psalm 23
|
|
21
|
+
│
|
|
22
|
+
│ Use ${prefix}biblelist for all books
|
|
23
|
+
│
|
|
24
|
+
╰─────────────────`
|
|
25
|
+
}, { quoted: fake });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const chapterInput = encodeURIComponent(text.trim());
|
|
30
|
+
const chapterRes = await fetch(`${BASE_URL}/${chapterInput}`);
|
|
31
|
+
|
|
32
|
+
if (!chapterRes.ok) {
|
|
33
|
+
await sock.sendMessage(chatId, {
|
|
34
|
+
text: `✦ *ERROR*
|
|
35
|
+
╭─────────────────
|
|
36
|
+
│
|
|
37
|
+
│ Invalid format!
|
|
38
|
+
│
|
|
39
|
+
│ Use: Book Chapter:Verse
|
|
40
|
+
│ Example: ${prefix}bible John 3:16
|
|
41
|
+
│
|
|
42
|
+
╰─────────────────`
|
|
43
|
+
}, { quoted: fake });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const chapterData = await chapterRes.json();
|
|
48
|
+
const bibleText = `✦ *BIBLE*
|
|
49
|
+
╭─────────────────
|
|
50
|
+
│
|
|
51
|
+
│ Reference: ${chapterData.reference}
|
|
52
|
+
│ Translation: ${chapterData.translation_name}
|
|
53
|
+
│ Verses: ${chapterData.verses.length}
|
|
54
|
+
│
|
|
55
|
+
│ ${chapterData.text}
|
|
56
|
+
│
|
|
57
|
+
╰─────────────────`;
|
|
58
|
+
|
|
59
|
+
await sock.sendMessage(chatId, { text: bibleText }, { quoted: fake });
|
|
60
|
+
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Bible command error:', error);
|
|
63
|
+
const fake = createFakeContact(message);
|
|
64
|
+
await sock.sendMessage(chatId, {
|
|
65
|
+
text: `✦ *ERROR*
|
|
66
|
+
╭─────────────────
|
|
67
|
+
│
|
|
68
|
+
│ ${error.message}
|
|
69
|
+
│
|
|
70
|
+
╰─────────────────`
|
|
71
|
+
}, { quoted: fake });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function bibleListCommand(sock, chatId, message) {
|
|
76
|
+
try {
|
|
77
|
+
const fake = createFakeContact(message);
|
|
78
|
+
|
|
79
|
+
const bibleList = `✦ *OLD TESTAMENT*
|
|
80
|
+
╭────────────────────────────────
|
|
81
|
+
│ Genesis • Exodus • Leviticus • Numbers • Deuteronomy
|
|
82
|
+
│ Joshua • Judges • Ruth • 1 Samuel • 2 Samuel
|
|
83
|
+
│ 1 Kings • 2 Kings • 1 Chronicles • 2 Chronicles
|
|
84
|
+
│ Ezra • Nehemiah • Esther • Job • Psalms
|
|
85
|
+
│ Proverbs • Ecclesiastes • Song of Solomon
|
|
86
|
+
│ Isaiah • Jeremiah • Lamentations • Ezekiel
|
|
87
|
+
│ Daniel • Hosea • Joel • Amos • Obadiah
|
|
88
|
+
│ Jonah • Micah • Nahum • Habakkuk
|
|
89
|
+
│ Zephaniah • Haggai • Zechariah • Malachi
|
|
90
|
+
╰────────────────────────────────
|
|
91
|
+
|
|
92
|
+
✦ *NEW TESTAMENT*
|
|
93
|
+
╭────────────────────────────────
|
|
94
|
+
│ Matthew • Mark • Luke • John • Acts
|
|
95
|
+
│ Romans • 1 Corinthians • 2 Corinthians
|
|
96
|
+
│ Galatians • Ephesians • Philippians
|
|
97
|
+
│ Colossians • 1 Thessalonians • 2 Thessalonians
|
|
98
|
+
│ 1 Timothy • 2 Timothy • Titus • Philemon
|
|
99
|
+
│ Hebrews • James • 1 Peter • 2 Peter
|
|
100
|
+
│ 1 John • 2 John • 3 John • Jude • Revelation
|
|
101
|
+
╰────────────────────────────────
|
|
102
|
+
|
|
103
|
+
✦ *USAGE*
|
|
104
|
+
╭─────────────────
|
|
105
|
+
│ .bible John 3:16
|
|
106
|
+
│ .bible Genesis 1:1
|
|
107
|
+
╰─────────────────`;
|
|
108
|
+
|
|
109
|
+
await sock.sendMessage(chatId, { text: bibleList }, { quoted: fake });
|
|
110
|
+
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error('Bible list command error:', error);
|
|
113
|
+
const fake = createFakeContact(message);
|
|
114
|
+
await sock.sendMessage(chatId, {
|
|
115
|
+
text: `✦ *ERROR*
|
|
116
|
+
╭─────────────────
|
|
117
|
+
│
|
|
118
|
+
│ Failed to fetch Bible list
|
|
119
|
+
│
|
|
120
|
+
╰─────────────────`
|
|
121
|
+
}, { quoted: fake });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function quranCommand(sock, chatId, message, text) {
|
|
126
|
+
try {
|
|
127
|
+
const fake = createFakeContact(message);
|
|
128
|
+
|
|
129
|
+
if (!text || isNaN(parseInt(text.trim()))) {
|
|
130
|
+
await sock.sendMessage(chatId, {
|
|
131
|
+
text: `✦ *QURAN*
|
|
132
|
+
╭─────────────────
|
|
133
|
+
│
|
|
134
|
+
│ Usage:
|
|
135
|
+
│ .quran <surah>
|
|
136
|
+
│
|
|
137
|
+
│ Example:
|
|
138
|
+
│ .quran 1
|
|
139
|
+
│
|
|
140
|
+
│ Surahs available:
|
|
141
|
+
│ 1 - 114
|
|
142
|
+
│
|
|
143
|
+
╰─────────────────`
|
|
144
|
+
}, { quoted: fake });
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const surahNumber = parseInt(text.trim());
|
|
149
|
+
|
|
150
|
+
if (surahNumber < 1 || surahNumber > 114) {
|
|
151
|
+
await sock.sendMessage(chatId, {
|
|
152
|
+
text: `✦ *ERROR*
|
|
153
|
+
╭─────────────────
|
|
154
|
+
│
|
|
155
|
+
│ Invalid number!
|
|
156
|
+
│ Use 1 - 114
|
|
157
|
+
│
|
|
158
|
+
╰─────────────────`
|
|
159
|
+
}, { quoted: fake });
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const url = `https://apis.davidcyriltech.my.id/quran?surah=${surahNumber}`;
|
|
164
|
+
const res = await fetch(url);
|
|
165
|
+
const data = await res.json();
|
|
166
|
+
|
|
167
|
+
if (!data.success) {
|
|
168
|
+
await sock.sendMessage(chatId, {
|
|
169
|
+
text: `✦ *ERROR*
|
|
170
|
+
╭─────────────────
|
|
171
|
+
│
|
|
172
|
+
│ Could not fetch Surah
|
|
173
|
+
│
|
|
174
|
+
╰─────────────────`
|
|
175
|
+
}, { quoted: fake });
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const { number, name, type, ayahCount, tafsir, recitation } = data.surah;
|
|
180
|
+
|
|
181
|
+
let replyText = `✦ *SURAH ${name.english}*
|
|
182
|
+
╭─────────────────
|
|
183
|
+
│
|
|
184
|
+
│ Arabic: ${name.arabic}
|
|
185
|
+
│ Number: ${number}
|
|
186
|
+
│ Type: ${type}
|
|
187
|
+
│ Ayahs: ${ayahCount}
|
|
188
|
+
│
|
|
189
|
+
│ Tafsir:
|
|
190
|
+
│ ${tafsir.id}
|
|
191
|
+
│
|
|
192
|
+
╰─────────────────`;
|
|
193
|
+
|
|
194
|
+
// Send text first
|
|
195
|
+
await sock.sendMessage(chatId, { text: replyText }, { quoted: fake });
|
|
196
|
+
|
|
197
|
+
// Then send audio if available
|
|
198
|
+
if (recitation) {
|
|
199
|
+
try {
|
|
200
|
+
const audioRes = await fetch(recitation);
|
|
201
|
+
const audioBuffer = await audioRes.buffer();
|
|
202
|
+
|
|
203
|
+
await sock.sendMessage(chatId, {
|
|
204
|
+
audio: audioBuffer,
|
|
205
|
+
mimetype: "audio/mpeg",
|
|
206
|
+
ptt: false
|
|
207
|
+
}, { quoted: fake });
|
|
208
|
+
} catch (audioError) {
|
|
209
|
+
console.error('Audio download error:', audioError);
|
|
210
|
+
await sock.sendMessage(chatId, {
|
|
211
|
+
text: `✦ *AUDIO*
|
|
212
|
+
╭─────────────────
|
|
213
|
+
│
|
|
214
|
+
│ Recitation unavailable
|
|
215
|
+
│
|
|
216
|
+
╰─────────────────`
|
|
217
|
+
}, { quoted: fake });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.error('Quran command error:', error);
|
|
223
|
+
const fake = createFakeContact(message);
|
|
224
|
+
await sock.sendMessage(chatId, {
|
|
225
|
+
text: `✦ *ERROR*
|
|
226
|
+
╭─────────────────
|
|
227
|
+
│
|
|
228
|
+
│ Failed to fetch Quran data
|
|
229
|
+
│
|
|
230
|
+
╰─────────────────`
|
|
231
|
+
}, { quoted: fake });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
module.exports = {
|
|
236
|
+
bibleCommand,
|
|
237
|
+
bibleListCommand,
|
|
238
|
+
quranCommand
|
|
239
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
4
|
+
|
|
5
|
+
// Function to clear a single directory
|
|
6
|
+
function clearDirectory(dirPath) {
|
|
7
|
+
try {
|
|
8
|
+
if (!fs.existsSync(dirPath)) {
|
|
9
|
+
return { success: false, message: `Directory does not exist: ${dirPath}` };
|
|
10
|
+
}
|
|
11
|
+
const files = fs.readdirSync(dirPath);
|
|
12
|
+
let deletedCount = 0;
|
|
13
|
+
for (const file of files) {
|
|
14
|
+
try {
|
|
15
|
+
const filePath = path.join(dirPath, file);
|
|
16
|
+
const stat = fs.lstatSync(filePath);
|
|
17
|
+
if (stat.isDirectory()) {
|
|
18
|
+
fs.rmSync(filePath, { recursive: true, force: true });
|
|
19
|
+
} else {
|
|
20
|
+
fs.unlinkSync(filePath);
|
|
21
|
+
}
|
|
22
|
+
deletedCount++;
|
|
23
|
+
} catch (err) {
|
|
24
|
+
// Only log errors
|
|
25
|
+
console.error(`Error deleting file ${file}:`, err);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return { success: true, message: `Cleared ${deletedCount} files in ${path.basename(dirPath)}`, count: deletedCount };
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Error in clearDirectory:', error);
|
|
31
|
+
return { success: false, message: `Failed to clear files in ${path.basename(dirPath)}`, error: error.message };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Function to clear both tmp and temp directories
|
|
36
|
+
async function clearTmpDirectory() {
|
|
37
|
+
const tmpDir = path.join(process.cwd(), 'tmp');
|
|
38
|
+
const tempDir = path.join(process.cwd(), 'temp');
|
|
39
|
+
const results = [];
|
|
40
|
+
results.push(clearDirectory(tmpDir));
|
|
41
|
+
results.push(clearDirectory(tempDir));
|
|
42
|
+
// Combine results
|
|
43
|
+
const success = results.every(r => r.success);
|
|
44
|
+
const totalDeleted = results.reduce((sum, r) => sum + (r.count || 0), 0);
|
|
45
|
+
const message = results.map(r => r.message).join(' | ');
|
|
46
|
+
return { success, message, count: totalDeleted };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Function to handle manual command
|
|
50
|
+
async function clearTmpCommand(sock, chatId, msg) {
|
|
51
|
+
const fake = createFakeContact(msg);
|
|
52
|
+
const botName = getBotName();
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
// Check if user is owner
|
|
56
|
+
const isOwner = msg.key.fromMe;
|
|
57
|
+
if (!isOwner) {
|
|
58
|
+
await sock.sendMessage(chatId, {
|
|
59
|
+
text: `✦ Owner only command`
|
|
60
|
+
}, { quoted: fake });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const result = await clearTmpDirectory();
|
|
65
|
+
|
|
66
|
+
if (result.success) {
|
|
67
|
+
await sock.sendMessage(chatId, {
|
|
68
|
+
text: `✦ Cleared: ${result.message}`
|
|
69
|
+
}, { quoted: fake });
|
|
70
|
+
} else {
|
|
71
|
+
await sock.sendMessage(chatId, {
|
|
72
|
+
text: `✦ Failed: ${result.message}`
|
|
73
|
+
}, { quoted: fake });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error('Error in cleartmp command:', error);
|
|
78
|
+
await sock.sendMessage(chatId, {
|
|
79
|
+
text: `✦ Failed to clear temp files`
|
|
80
|
+
}, { quoted: fake });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Start automatic clearing every 6 hours
|
|
85
|
+
function startAutoClear() {
|
|
86
|
+
// Run immediately on startup
|
|
87
|
+
clearTmpDirectory().then(result => {
|
|
88
|
+
if (!result.success) {
|
|
89
|
+
console.error(`[Auto Clear] ${result.message}`);
|
|
90
|
+
}
|
|
91
|
+
// No log for success, regardless of count
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Set interval for every 6 hours
|
|
95
|
+
setInterval(async () => {
|
|
96
|
+
const result = await clearTmpDirectory();
|
|
97
|
+
if (!result.success) {
|
|
98
|
+
console.error(`[Auto Clear] ${result.message}`);
|
|
99
|
+
}
|
|
100
|
+
// No log for success, regardless of count
|
|
101
|
+
}, 6 * 60 * 60 * 1000); // 6 hours in milliseconds
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Start the automatic clearing
|
|
105
|
+
startAutoClear();
|
|
106
|
+
|
|
107
|
+
module.exports = clearTmpCommand;
|