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,403 @@
|
|
|
1
|
+
const axios = require("axios");
|
|
2
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
3
|
+
|
|
4
|
+
// Football Data API configuration
|
|
5
|
+
const apiKey = '7b6507c792f74a2b9db41cfc8fd8cf05';
|
|
6
|
+
const apiUrl = 'https://api.football-data.org/v4/competitions';
|
|
7
|
+
|
|
8
|
+
// Helper function to fetch data from football-data.org
|
|
9
|
+
const fetchFootballData = async (endpoint) => {
|
|
10
|
+
try {
|
|
11
|
+
const response = await axios.get(`${apiUrl}/${endpoint}`, {
|
|
12
|
+
headers: {
|
|
13
|
+
'X-Auth-Token': apiKey,
|
|
14
|
+
},
|
|
15
|
+
timeout: 10000
|
|
16
|
+
});
|
|
17
|
+
return response.data;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error('Football API error:', error);
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Format date helper
|
|
25
|
+
const formatDate = (dateString) => {
|
|
26
|
+
const date = new Date(dateString);
|
|
27
|
+
return date.toLocaleDateString('en-US', {
|
|
28
|
+
weekday: 'short',
|
|
29
|
+
month: 'short',
|
|
30
|
+
day: 'numeric',
|
|
31
|
+
hour: '2-digit',
|
|
32
|
+
minute: '2-digit'
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// 1. EPL Standings
|
|
37
|
+
async function eplStandingsCommand(sock, chatId, message) {
|
|
38
|
+
try {
|
|
39
|
+
const fake = createFakeContact(message);
|
|
40
|
+
const botName = getBotName();
|
|
41
|
+
await sock.sendMessage(chatId, { react: { text: '⏳', key: message.key } });
|
|
42
|
+
|
|
43
|
+
const data = await fetchFootballData('PL/standings');
|
|
44
|
+
if (!data || !data.standings) {
|
|
45
|
+
await sock.sendMessage(chatId, {
|
|
46
|
+
text: `*${botName}*\n❌ Error fetching EPL standings.`
|
|
47
|
+
}, { quoted: fake });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const standings = data.standings[0].table;
|
|
52
|
+
let standingsMessage = `╭─❖ *PREMIER LEAGUE* ❖─╮\n\n`;
|
|
53
|
+
|
|
54
|
+
standings.forEach((team, index) => {
|
|
55
|
+
const position = index + 1;
|
|
56
|
+
const emoji = position <= 4 ? '🏆' : position <= 6 ? '⚽' : position >= 18 ? '⬇️' : '🔵';
|
|
57
|
+
standingsMessage += `${emoji} ${position}. ${team.team.name}\n`;
|
|
58
|
+
standingsMessage += ` 📊 ${team.playedGames}G | ${team.won}W | ${team.draw}D | ${team.lost}L\n`;
|
|
59
|
+
standingsMessage += ` ⚽ ${team.goalsFor}:${team.goalsAgainst} (${team.goalDifference > 0 ? '+' : ''}${team.goalDifference})\n`;
|
|
60
|
+
standingsMessage += ` 📈 ${team.points} pts\n\n`;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
standingsMessage += `╰──────────────────────╯`;
|
|
64
|
+
|
|
65
|
+
await sock.sendMessage(chatId, { text: standingsMessage }, { quoted: fake });
|
|
66
|
+
await sock.sendMessage(chatId, { react: { text: '✅', key: message.key } });
|
|
67
|
+
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('EPL standings error:', error);
|
|
70
|
+
const fake = createFakeContact(message);
|
|
71
|
+
const botName = getBotName();
|
|
72
|
+
await sock.sendMessage(chatId, {
|
|
73
|
+
text: `*${botName}*\n❌ Error fetching EPL standings.`
|
|
74
|
+
}, { quoted: fake });
|
|
75
|
+
await sock.sendMessage(chatId, { react: { text: '❌', key: message.key } });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 2. EPL Matchday (Fixtures)
|
|
80
|
+
async function eplFixturesCommand(sock, chatId, message) {
|
|
81
|
+
try {
|
|
82
|
+
const fake = createFakeContact(message);
|
|
83
|
+
const botName = getBotName();
|
|
84
|
+
await sock.sendMessage(chatId, { react: { text: '⏳', key: message.key } });
|
|
85
|
+
|
|
86
|
+
const data = await fetchFootballData('PL/matches?status=SCHEDULED');
|
|
87
|
+
if (!data || !data.matches) {
|
|
88
|
+
await sock.sendMessage(chatId, {
|
|
89
|
+
text: `*${botName}*\n❌ Error fetching EPL fixtures.`
|
|
90
|
+
}, { quoted: fake });
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const matches = data.matches.slice(0, 10);
|
|
95
|
+
let fixturesMessage = `╭─❖ *UPCOMING EPL FIXTURES* ❖─╮\n\n`;
|
|
96
|
+
|
|
97
|
+
if (matches.length === 0) {
|
|
98
|
+
fixturesMessage += "No upcoming matches scheduled.\n";
|
|
99
|
+
} else {
|
|
100
|
+
matches.forEach((match, index) => {
|
|
101
|
+
const matchDate = formatDate(match.utcDate);
|
|
102
|
+
fixturesMessage += `${index + 1}. ${match.homeTeam.name} 🆚 ${match.awayTeam.name}\n`;
|
|
103
|
+
fixturesMessage += ` 📅 ${matchDate}\n`;
|
|
104
|
+
fixturesMessage += ` 🏟️ ${match.venue || 'TBA'}\n\n`;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
fixturesMessage += `╰────────────────────────────╯`;
|
|
109
|
+
|
|
110
|
+
await sock.sendMessage(chatId, { text: fixturesMessage }, { quoted: fake });
|
|
111
|
+
await sock.sendMessage(chatId, { react: { text: '✅', key: message.key } });
|
|
112
|
+
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.error('EPL fixtures error:', error);
|
|
115
|
+
const fake = createFakeContact(message);
|
|
116
|
+
const botName = getBotName();
|
|
117
|
+
await sock.sendMessage(chatId, {
|
|
118
|
+
text: `*${botName}*\n❌ Error fetching EPL fixtures.`
|
|
119
|
+
}, { quoted: fake });
|
|
120
|
+
await sock.sendMessage(chatId, { react: { text: '❌', key: message.key } });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 3. EPL Top Scorers
|
|
125
|
+
async function eplTopScorersCommand(sock, chatId, message) {
|
|
126
|
+
try {
|
|
127
|
+
const fake = createFakeContact(message);
|
|
128
|
+
const botName = getBotName();
|
|
129
|
+
await sock.sendMessage(chatId, { react: { text: '⏳', key: message.key } });
|
|
130
|
+
|
|
131
|
+
const data = await fetchFootballData('PL/scorers');
|
|
132
|
+
if (!data || !data.scorers) {
|
|
133
|
+
await sock.sendMessage(chatId, {
|
|
134
|
+
text: `*${botName}*\n❌ Error fetching EPL top scorers.`
|
|
135
|
+
}, { quoted: fake });
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const topScorers = data.scorers.slice(0, 10);
|
|
140
|
+
let scorersMessage = `╭─❖ *EPL TOP SCORERS* ❖─╮\n\n`;
|
|
141
|
+
|
|
142
|
+
topScorers.forEach((scorer, index) => {
|
|
143
|
+
const position = index + 1;
|
|
144
|
+
const emoji = position === 1 ? '🥇' : position === 2 ? '🥈' : position === 3 ? '🥉' : '⚽';
|
|
145
|
+
scorersMessage += `${emoji} ${position}. ${scorer.player.name}\n`;
|
|
146
|
+
scorersMessage += ` 👟 ${scorer.goals || scorer.numberOfGoals || 0} goals\n`;
|
|
147
|
+
scorersMessage += ` 👕 ${scorer.team?.name || 'N/A'}\n`;
|
|
148
|
+
if (scorer.assists) scorersMessage += ` 🎯 ${scorer.assists} assists\n`;
|
|
149
|
+
scorersMessage += '\n';
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
scorersMessage += `╰───────────────────────╯`;
|
|
153
|
+
|
|
154
|
+
await sock.sendMessage(chatId, { text: scorersMessage }, { quoted: fake });
|
|
155
|
+
await sock.sendMessage(chatId, { react: { text: '✅', key: message.key } });
|
|
156
|
+
|
|
157
|
+
} catch (error) {
|
|
158
|
+
console.error('EPL top scorers error:', error);
|
|
159
|
+
const fake = createFakeContact(message);
|
|
160
|
+
const botName = getBotName();
|
|
161
|
+
await sock.sendMessage(chatId, {
|
|
162
|
+
text: `*${botName}*\n❌ Error fetching EPL top scorers.`
|
|
163
|
+
}, { quoted: fake });
|
|
164
|
+
await sock.sendMessage(chatId, { react: { text: '❌', key: message.key } });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 4. Bundesliga Standings
|
|
169
|
+
async function bundesligaStandingsCommand(sock, chatId, message) {
|
|
170
|
+
try {
|
|
171
|
+
const fake = createFakeContact(message);
|
|
172
|
+
const botName = getBotName();
|
|
173
|
+
await sock.sendMessage(chatId, { react: { text: '⏳', key: message.key } });
|
|
174
|
+
|
|
175
|
+
const data = await fetchFootballData('BL1/standings');
|
|
176
|
+
if (!data || !data.standings) {
|
|
177
|
+
await sock.sendMessage(chatId, {
|
|
178
|
+
text: `*${botName}*\n❌ Error fetching Bundesliga standings.`
|
|
179
|
+
}, { quoted: fake });
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const standings = data.standings[0].table;
|
|
184
|
+
let standingsMessage = `╭─❖ *BUNDESLIGA* ❖─╮\n\n`;
|
|
185
|
+
|
|
186
|
+
standings.forEach((team, index) => {
|
|
187
|
+
const position = index + 1;
|
|
188
|
+
const emoji = position <= 4 ? '🏆' : position >= 16 ? '⬇️' : '🔵';
|
|
189
|
+
standingsMessage += `${emoji} ${position}. ${team.team.name}\n`;
|
|
190
|
+
standingsMessage += ` 📊 ${team.playedGames}G | ${team.won}W | ${team.draw}D | ${team.lost}L\n`;
|
|
191
|
+
standingsMessage += ` ⚽ ${team.goalsFor}:${team.goalsAgainst} (${team.goalDifference > 0 ? '+' : ''}${team.goalDifference})\n`;
|
|
192
|
+
standingsMessage += ` 📈 ${team.points} pts\n\n`;
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
standingsMessage += `╰───────────────────╯`;
|
|
196
|
+
|
|
197
|
+
await sock.sendMessage(chatId, { text: standingsMessage }, { quoted: fake });
|
|
198
|
+
await sock.sendMessage(chatId, { react: { text: '✅', key: message.key } });
|
|
199
|
+
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error('Bundesliga standings error:', error);
|
|
202
|
+
const fake = createFakeContact(message);
|
|
203
|
+
const botName = getBotName();
|
|
204
|
+
await sock.sendMessage(chatId, {
|
|
205
|
+
text: `*${botName}*\n❌ Error fetching Bundesliga standings.`
|
|
206
|
+
}, { quoted: fake });
|
|
207
|
+
await sock.sendMessage(chatId, { react: { text: '❌', key: message.key } });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 5. LaLiga Standings
|
|
212
|
+
async function laligaStandingsCommand(sock, chatId, message) {
|
|
213
|
+
try {
|
|
214
|
+
const fake = createFakeContact(message);
|
|
215
|
+
const botName = getBotName();
|
|
216
|
+
await sock.sendMessage(chatId, { react: { text: '⏳', key: message.key } });
|
|
217
|
+
|
|
218
|
+
const data = await fetchFootballData('PD/standings');
|
|
219
|
+
if (!data || !data.standings) {
|
|
220
|
+
await sock.sendMessage(chatId, {
|
|
221
|
+
text: `*${botName}*\n❌ Error fetching LaLiga standings.`
|
|
222
|
+
}, { quoted: fake });
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const standings = data.standings[0].table;
|
|
227
|
+
let standingsMessage = `╭─❖ *LALIGA* ❖─╮\n\n`;
|
|
228
|
+
|
|
229
|
+
standings.forEach((team, index) => {
|
|
230
|
+
const position = index + 1;
|
|
231
|
+
const emoji = position <= 4 ? '🏆' : position >= 18 ? '⬇️' : '🔵';
|
|
232
|
+
standingsMessage += `${emoji} ${position}. ${team.team.name}\n`;
|
|
233
|
+
standingsMessage += ` 📊 ${team.playedGames}G | ${team.won}W | ${team.draw}D | ${team.lost}L\n`;
|
|
234
|
+
standingsMessage += ` ⚽ ${team.goalsFor}:${team.goalsAgainst} (${team.goalDifference > 0 ? '+' : ''}${team.goalDifference})\n`;
|
|
235
|
+
standingsMessage += ` 📈 ${team.points} pts\n\n`;
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
standingsMessage += `╰────────────────╯`;
|
|
239
|
+
|
|
240
|
+
await sock.sendMessage(chatId, { text: standingsMessage }, { quoted: fake });
|
|
241
|
+
await sock.sendMessage(chatId, { react: { text: '✅', key: message.key } });
|
|
242
|
+
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error('LaLiga standings error:', error);
|
|
245
|
+
const fake = createFakeContact(message);
|
|
246
|
+
const botName = getBotName();
|
|
247
|
+
await sock.sendMessage(chatId, {
|
|
248
|
+
text: `*${botName}*\n❌ Error fetching LaLiga standings.`
|
|
249
|
+
}, { quoted: fake });
|
|
250
|
+
await sock.sendMessage(chatId, { react: { text: '❌', key: message.key } });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// 6. Serie A Standings
|
|
255
|
+
async function serieAStandingsCommand(sock, chatId, message) {
|
|
256
|
+
try {
|
|
257
|
+
const fake = createFakeContact(message);
|
|
258
|
+
const botName = getBotName();
|
|
259
|
+
await sock.sendMessage(chatId, { react: { text: '⏳', key: message.key } });
|
|
260
|
+
|
|
261
|
+
const data = await fetchFootballData('SA/standings');
|
|
262
|
+
if (!data || !data.standings) {
|
|
263
|
+
await sock.sendMessage(chatId, {
|
|
264
|
+
text: `*${botName}*\n❌ Error fetching Serie A standings.`
|
|
265
|
+
}, { quoted: fake });
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const standings = data.standings[0].table;
|
|
270
|
+
let standingsMessage = `╭─❖ *SERIE A* ❖─╮\n\n`;
|
|
271
|
+
|
|
272
|
+
standings.forEach((team, index) => {
|
|
273
|
+
const position = index + 1;
|
|
274
|
+
const emoji = position <= 4 ? '🏆' : position >= 18 ? '⬇️' : '🔵';
|
|
275
|
+
standingsMessage += `${emoji} ${position}. ${team.team.name}\n`;
|
|
276
|
+
standingsMessage += ` 📊 ${team.playedGames}G | ${team.won}W | ${team.draw}D | ${team.lost}L\n`;
|
|
277
|
+
standingsMessage += ` ⚽ ${team.goalsFor}:${team.goalsAgainst} (${team.goalDifference > 0 ? '+' : ''}${team.goalDifference})\n`;
|
|
278
|
+
standingsMessage += ` 📈 ${team.points} pts\n\n`;
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
standingsMessage += `╰────────────────╯`;
|
|
282
|
+
|
|
283
|
+
await sock.sendMessage(chatId, { text: standingsMessage }, { quoted: fake });
|
|
284
|
+
await sock.sendMessage(chatId, { react: { text: '✅', key: message.key } });
|
|
285
|
+
|
|
286
|
+
} catch (error) {
|
|
287
|
+
console.error('Serie A standings error:', error);
|
|
288
|
+
const fake = createFakeContact(message);
|
|
289
|
+
const botName = getBotName();
|
|
290
|
+
await sock.sendMessage(chatId, {
|
|
291
|
+
text: `*${botName}*\n❌ Error fetching Serie A standings.`
|
|
292
|
+
}, { quoted: fake });
|
|
293
|
+
await sock.sendMessage(chatId, { react: { text: '❌', key: message.key } });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// 7. Ligue 1 Standings
|
|
298
|
+
async function ligue1StandingsCommand(sock, chatId, message) {
|
|
299
|
+
try {
|
|
300
|
+
const fake = createFakeContact(message);
|
|
301
|
+
const botName = getBotName();
|
|
302
|
+
await sock.sendMessage(chatId, { react: { text: '⏳', key: message.key } });
|
|
303
|
+
|
|
304
|
+
const data = await fetchFootballData('FL1/standings');
|
|
305
|
+
if (!data || !data.standings) {
|
|
306
|
+
await sock.sendMessage(chatId, {
|
|
307
|
+
text: `*${botName}*\n❌ Error fetching Ligue 1 standings.`
|
|
308
|
+
}, { quoted: fake });
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const standings = data.standings[0].table;
|
|
313
|
+
let standingsMessage = `╭─❖ *LIGUE 1* ❖─╮\n\n`;
|
|
314
|
+
|
|
315
|
+
standings.forEach((team, index) => {
|
|
316
|
+
const position = index + 1;
|
|
317
|
+
const emoji = position <= 3 ? '🏆' : position >= 18 ? '⬇️' : '🔵';
|
|
318
|
+
standingsMessage += `${emoji} ${position}. ${team.team.name}\n`;
|
|
319
|
+
standingsMessage += ` 📊 ${team.playedGames}G | ${team.won}W | ${team.draw}D | ${team.lost}L\n`;
|
|
320
|
+
standingsMessage += ` ⚽ ${team.goalsFor}:${team.goalsAgainst} (${team.goalDifference > 0 ? '+' : ''}${team.goalDifference})\n`;
|
|
321
|
+
standingsMessage += ` 📈 ${team.points} pts\n\n`;
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
standingsMessage += `╰────────────────╯`;
|
|
325
|
+
|
|
326
|
+
await sock.sendMessage(chatId, { text: standingsMessage }, { quoted: fake });
|
|
327
|
+
await sock.sendMessage(chatId, { react: { text: '✅', key: message.key } });
|
|
328
|
+
|
|
329
|
+
} catch (error) {
|
|
330
|
+
console.error('Ligue 1 standings error:', error);
|
|
331
|
+
const fake = createFakeContact(message);
|
|
332
|
+
const botName = getBotName();
|
|
333
|
+
await sock.sendMessage(chatId, {
|
|
334
|
+
text: `*${botName}*\n❌ Error fetching Ligue 1 standings.`
|
|
335
|
+
}, { quoted: fake });
|
|
336
|
+
await sock.sendMessage(chatId, { react: { text: '❌', key: message.key } });
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// 8. All Leagues Today's Matches
|
|
341
|
+
async function matchesCommand(sock, chatId, message) {
|
|
342
|
+
try {
|
|
343
|
+
const fake = createFakeContact(message);
|
|
344
|
+
const botName = getBotName();
|
|
345
|
+
await sock.sendMessage(chatId, { react: { text: '⏳', key: message.key } });
|
|
346
|
+
|
|
347
|
+
const today = new Date().toISOString().split('T')[0];
|
|
348
|
+
|
|
349
|
+
const [eplData, laligaData, bundesligaData, serieAData, ligue1Data] = await Promise.all([
|
|
350
|
+
fetchFootballData(`PL/matches?dateFrom=${today}&dateTo=${today}`),
|
|
351
|
+
fetchFootballData(`PD/matches?dateFrom=${today}&dateTo=${today}`),
|
|
352
|
+
fetchFootballData(`BL1/matches?dateFrom=${today}&dateTo=${today}`),
|
|
353
|
+
fetchFootballData(`SA/matches?dateFrom=${today}&dateTo=${today}`),
|
|
354
|
+
fetchFootballData(`FL1/matches?dateFrom=${today}&dateTo=${today}`)
|
|
355
|
+
]);
|
|
356
|
+
|
|
357
|
+
let matchesMessage = `╭─❖ *TODAY'S FIXTURES* ❖─╮\n\n`;
|
|
358
|
+
|
|
359
|
+
const addLeagueMatches = (data, leagueName, flag) => {
|
|
360
|
+
if (data && data.matches && data.matches.length > 0) {
|
|
361
|
+
matchesMessage += `${flag} *${leagueName}:*\n`;
|
|
362
|
+
data.matches.forEach(match => {
|
|
363
|
+
const matchTime = formatDate(match.utcDate);
|
|
364
|
+
matchesMessage += ` • ${match.homeTeam.name} 🆚 ${match.awayTeam.name}\n`;
|
|
365
|
+
matchesMessage += ` 🕐 ${matchTime}\n`;
|
|
366
|
+
if (match.status === 'IN_PLAY') matchesMessage += ` ⚽ LIVE\n`;
|
|
367
|
+
});
|
|
368
|
+
matchesMessage += '\n';
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
addLeagueMatches(eplData, 'Premier League', '🇬🇧');
|
|
373
|
+
addLeagueMatches(laligaData, 'LaLiga', '🇪🇸');
|
|
374
|
+
addLeagueMatches(bundesligaData, 'Bundesliga', '🇩🇪');
|
|
375
|
+
addLeagueMatches(serieAData, 'Serie A', '🇮🇹');
|
|
376
|
+
addLeagueMatches(ligue1Data, 'Ligue 1', '🇫🇷');
|
|
377
|
+
|
|
378
|
+
matchesMessage += `╰───────────────────────╯`;
|
|
379
|
+
|
|
380
|
+
await sock.sendMessage(chatId, { text: matchesMessage }, { quoted: fake });
|
|
381
|
+
await sock.sendMessage(chatId, { react: { text: '✅', key: message.key } });
|
|
382
|
+
|
|
383
|
+
} catch (error) {
|
|
384
|
+
console.error('Matches command error:', error);
|
|
385
|
+
const fake = createFakeContact(message);
|
|
386
|
+
const botName = getBotName();
|
|
387
|
+
await sock.sendMessage(chatId, {
|
|
388
|
+
text: `*${botName}*\n❌ Error fetching today's matches.`
|
|
389
|
+
}, { quoted: fake });
|
|
390
|
+
await sock.sendMessage(chatId, { react: { text: '❌', key: message.key } });
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
module.exports = {
|
|
395
|
+
eplStandingsCommand,
|
|
396
|
+
eplFixturesCommand,
|
|
397
|
+
eplTopScorersCommand,
|
|
398
|
+
bundesligaStandingsCommand,
|
|
399
|
+
laligaStandingsCommand,
|
|
400
|
+
serieAStandingsCommand,
|
|
401
|
+
ligue1StandingsCommand,
|
|
402
|
+
matchesCommand
|
|
403
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const fetch = require('node-fetch');
|
|
2
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
3
|
+
|
|
4
|
+
async function handleSsCommand(sock, chatId, message, match) {
|
|
5
|
+
if (!match) {
|
|
6
|
+
await sock.sendMessage(chatId, {
|
|
7
|
+
text: `*SCREENSHOT WEB TOOL*\n\n*.ssweb <url>*\n\nCapture a screenshot of any website\n\nExample:\n.ssweb https://example.com`,
|
|
8
|
+
quoted: message
|
|
9
|
+
});
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
// Show typing indicator
|
|
15
|
+
await sock.presenceSubscribe(chatId);
|
|
16
|
+
await sock.sendPresenceUpdate('composing', chatId);
|
|
17
|
+
|
|
18
|
+
// Inform user that screenshot is being captured
|
|
19
|
+
await sock.sendMessage(chatId, {
|
|
20
|
+
text: '🖼️ Capturing screenshot, please wait...',
|
|
21
|
+
quoted: message
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Extract URL from command
|
|
25
|
+
const url = match.trim();
|
|
26
|
+
|
|
27
|
+
// Validate URL
|
|
28
|
+
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
29
|
+
return sock.sendMessage(chatId, {
|
|
30
|
+
text: 'Please provide a valid URL starting with http:// or https://\nExample: .ssweb https://example.com',
|
|
31
|
+
quoted: message
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Call the API
|
|
36
|
+
const apiUrl = `https://api.zenzxz.my.id/api/tools/ssweb?url=${encodeURIComponent(url)}`;
|
|
37
|
+
const response = await fetch(apiUrl);
|
|
38
|
+
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
throw new Error(`HTTP error ${response.status}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Get the image buffer
|
|
44
|
+
const imageBuffer = await response.buffer();
|
|
45
|
+
|
|
46
|
+
// Send the screenshot with caption
|
|
47
|
+
await sock.sendMessage(chatId, {
|
|
48
|
+
image: imageBuffer,
|
|
49
|
+
caption: `🖥️ *Screenshot of:* ${url}`
|
|
50
|
+
}, { quoted: fakeContact });
|
|
51
|
+
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error('❌ Error in ssweb command:', error);
|
|
54
|
+
await sock.sendMessage(chatId, {
|
|
55
|
+
text: `❌ Failed to capture screenshot.\nError: ${error.message}`,
|
|
56
|
+
quoted: message
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
handleSsCommand
|
|
63
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const axios = require("axios");
|
|
2
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
3
|
+
async function shortenUrlCommand(sock, chatId, message, text) {
|
|
4
|
+
try {
|
|
5
|
+
const fake = createFakeContact(message);
|
|
6
|
+
|
|
7
|
+
// Send loading reaction
|
|
8
|
+
await sock.sendMessage(chatId, { react: { text: '⏳', key: message.key } });
|
|
9
|
+
|
|
10
|
+
if (!text) {
|
|
11
|
+
await sock.sendMessage(chatId, {
|
|
12
|
+
text: '❌ You forgot the URL, genius. 🤦🏻\n\nExample: .shorten https://example.com'
|
|
13
|
+
}, { quoted: fake });
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let url = text.trim();
|
|
18
|
+
|
|
19
|
+
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
20
|
+
url = 'https://' + url;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const encodedUrl = encodeURIComponent(url);
|
|
24
|
+
const apiUrl = `https://api.nekolabs.web.id/tools/shortlink/tinyurl?url=${encodedUrl}`;
|
|
25
|
+
|
|
26
|
+
const response = await axios.get(apiUrl, {
|
|
27
|
+
headers: {
|
|
28
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
|
29
|
+
'Accept': 'application/json'
|
|
30
|
+
},
|
|
31
|
+
timeout: 10000
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (!response.data?.success || !response.data?.result) {
|
|
35
|
+
throw new Error('API returned invalid response');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const shortUrl = response.data.result;
|
|
39
|
+
const responseTime = response.data.responseTime || 'N/A';
|
|
40
|
+
|
|
41
|
+
const resultMessage = `✅ *URL SHORTENED SUCCESSFULLY*\n\n` +
|
|
42
|
+
`📎 *Original URL:*\n${url}\n\n` +
|
|
43
|
+
`🔗 *Shortened URL:*\n${shortUrl}\n\n` +
|
|
44
|
+
`⏱️ *Response Time:* ${responseTime}\n\n` +
|
|
45
|
+
`💡 *Tip:* Click/tap on the shortened URL to copy it`;
|
|
46
|
+
|
|
47
|
+
await sock.sendMessage(chatId, { text: resultMessage }, { quoted: fake });
|
|
48
|
+
|
|
49
|
+
// Send success reaction
|
|
50
|
+
await sock.sendMessage(chatId, { react: { text: '✅', key: message.key } });
|
|
51
|
+
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error('Shorten URL error:', error);
|
|
54
|
+
const fake = createFakeContact(message);
|
|
55
|
+
|
|
56
|
+
let errorMessage = "❌ Failed to shorten URL.\n\n";
|
|
57
|
+
|
|
58
|
+
if (error.response?.status === 400) {
|
|
59
|
+
errorMessage += "Invalid URL format. 🔗";
|
|
60
|
+
} else if (error.response?.status === 429) {
|
|
61
|
+
errorMessage += "Rate limit exceeded. Try again later. ⏳";
|
|
62
|
+
} else if (error.message.includes('timeout')) {
|
|
63
|
+
errorMessage += "API timeout. Please try again. ⏱️";
|
|
64
|
+
} else if (error.message.includes('ENOTFOUND')) {
|
|
65
|
+
errorMessage += "Can't reach API server. 🌐";
|
|
66
|
+
} else if (error.message.includes('Invalid response')) {
|
|
67
|
+
errorMessage += "API returned invalid response. 🗑️";
|
|
68
|
+
} else {
|
|
69
|
+
errorMessage += `Error: ${error.message}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
await sock.sendMessage(chatId, {
|
|
73
|
+
text: errorMessage
|
|
74
|
+
}, { quoted: fake });
|
|
75
|
+
|
|
76
|
+
// Send error reaction
|
|
77
|
+
await sock.sendMessage(chatId, { react: { text: '❌', key: message.key } });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
shortenUrlCommand
|
|
83
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const fetch = require('node-fetch');
|
|
2
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
3
|
+
async function handleTranslateCommand(sock, chatId, message, match) {
|
|
4
|
+
const fkontak = createFakeContact(message);
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
await sock.sendPresenceUpdate('composing', chatId);
|
|
8
|
+
|
|
9
|
+
let textToTranslate = '';
|
|
10
|
+
let lang = '';
|
|
11
|
+
|
|
12
|
+
const quotedMessage = message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
|
|
13
|
+
if (quotedMessage) {
|
|
14
|
+
textToTranslate = quotedMessage.conversation ||
|
|
15
|
+
quotedMessage.extendedTextMessage?.text ||
|
|
16
|
+
quotedMessage.imageMessage?.caption ||
|
|
17
|
+
quotedMessage.videoMessage?.caption ||
|
|
18
|
+
'';
|
|
19
|
+
|
|
20
|
+
lang = match.trim();
|
|
21
|
+
} else {
|
|
22
|
+
const args = match.trim().split(' ');
|
|
23
|
+
if (args.length < 2) {
|
|
24
|
+
return sock.sendMessage(chatId, {
|
|
25
|
+
text: `TRANSLATOR\n\nUsage:\n.translate <text> <lang> or .trt <text> <lang>\nExample: .translate hello fr\n\nLanguages:\nfr French, es Spanish, de German\nit Italian, pt Portuguese, ru Russian\nja Japanese, ko Korean, zh Chinese`,
|
|
26
|
+
quoted: fkontak
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
lang = args.pop();
|
|
31
|
+
textToTranslate = args.join(' ');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!textToTranslate) {
|
|
35
|
+
return sock.sendMessage(chatId, {
|
|
36
|
+
text: 'No text to translate.',
|
|
37
|
+
quoted: fkontak
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let translatedText = null;
|
|
42
|
+
|
|
43
|
+
// Try Google Translate API
|
|
44
|
+
try {
|
|
45
|
+
const response = await fetch(`https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=${lang}&dt=t&q=${encodeURIComponent(textToTranslate)}`);
|
|
46
|
+
if (response.ok) {
|
|
47
|
+
const data = await response.json();
|
|
48
|
+
if (data && data[0] && data[0][0] && data[0][0][0]) {
|
|
49
|
+
translatedText = data[0][0][0];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {}
|
|
53
|
+
|
|
54
|
+
// Try MyMemory API
|
|
55
|
+
if (!translatedText) {
|
|
56
|
+
try {
|
|
57
|
+
const response = await fetch(`https://api.mymemory.translated.net/get?q=${encodeURIComponent(textToTranslate)}&langpair=auto|${lang}`);
|
|
58
|
+
if (response.ok) {
|
|
59
|
+
const data = await response.json();
|
|
60
|
+
if (data && data.responseData && data.responseData.translatedText) {
|
|
61
|
+
translatedText = data.responseData.translatedText;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Try third API
|
|
68
|
+
if (!translatedText) {
|
|
69
|
+
try {
|
|
70
|
+
const response = await fetch(`https://api.dreaded.site/api/translate?text=${encodeURIComponent(textToTranslate)}&lang=${lang}`);
|
|
71
|
+
if (response.ok) {
|
|
72
|
+
const data = await response.json();
|
|
73
|
+
if (data && data.translated) {
|
|
74
|
+
translatedText = data.translated;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} catch (e) {}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!translatedText) {
|
|
81
|
+
throw new Error('All APIs failed');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
await sock.sendMessage(chatId, {
|
|
85
|
+
text: `${translatedText}`,
|
|
86
|
+
}, {
|
|
87
|
+
quoted: fkontak
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('Translate error:', error);
|
|
92
|
+
await sock.sendMessage(chatId, {
|
|
93
|
+
text: 'Failed to translate.',
|
|
94
|
+
quoted: fkontak
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = {
|
|
100
|
+
handleTranslateCommand
|
|
101
|
+
};
|