jsdecryptor 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/Database/database.js +446 -0
  2. package/Database/migration.js +327 -0
  3. package/Database/pgSync.js +229 -0
  4. package/Database/settingsStore.js +305 -0
  5. package/config.js +32 -0
  6. package/dave.js +3063 -0
  7. package/davelib/antibadword.js +278 -0
  8. package/davelib/antilink.js +88 -0
  9. package/davelib/antilinkHelper.js +48 -0
  10. package/davelib/botConfig.js +71 -0
  11. package/davelib/connect4.js +111 -0
  12. package/davelib/converter.js +89 -0
  13. package/davelib/dicegame.js +114 -0
  14. package/davelib/exif.js +138 -0
  15. package/davelib/fakeContact.js +85 -0
  16. package/davelib/fontStyles.js +237 -0
  17. package/davelib/greetings.js +47 -0
  18. package/davelib/id.js +11 -0
  19. package/davelib/index.js +577 -0
  20. package/davelib/isAdmin.js +32 -0
  21. package/davelib/isBanned.js +12 -0
  22. package/davelib/isOwner.js +15 -0
  23. package/davelib/lightweight_store.js +169 -0
  24. package/davelib/messageConfig.js +15 -0
  25. package/davelib/messageHandler.js +87 -0
  26. package/davelib/myfunc.js +379 -0
  27. package/davelib/myfunc2.js +170 -0
  28. package/davelib/reactions.js +180 -0
  29. package/davelib/server.html +563 -0
  30. package/davelib/sticker.js +208 -0
  31. package/davelib/tempCleanup.js +53 -0
  32. package/davelib/tictactoe.js +104 -0
  33. package/davelib/uploadImage.js +100 -0
  34. package/davelib/uploader.js +110 -0
  35. package/davelib/welcome.js +100 -0
  36. package/davelib/wordchain.js +121 -0
  37. package/daveset.js +16 -0
  38. package/davexcore/ai/ai.js +100 -0
  39. package/davexcore/ai/aiGpt4.js +59 -0
  40. package/davexcore/ai/aimodels.js +284 -0
  41. package/davexcore/ai/aivideo.js +31 -0
  42. package/davexcore/ai/analyze.js +233 -0
  43. package/davexcore/ai/bard.js +101 -0
  44. package/davexcore/ai/bird.js +101 -0
  45. package/davexcore/ai/blackbox.js +30 -0
  46. package/davexcore/ai/character.js +80 -0
  47. package/davexcore/ai/copilot.js +58 -0
  48. package/davexcore/ai/dalle.js +39 -0
  49. package/davexcore/ai/davex.js +50 -0
  50. package/davexcore/ai/deepseek.js +96 -0
  51. package/davexcore/ai/grok.js +67 -0
  52. package/davexcore/ai/imagine.js +89 -0
  53. package/davexcore/ai/meta.js +82 -0
  54. package/davexcore/ai/mistral.js +101 -0
  55. package/davexcore/ai/perplexity.js +95 -0
  56. package/davexcore/ai/sora.js +44 -0
  57. package/davexcore/ai/speechwriter.js +46 -0
  58. package/davexcore/ai/vision.js +244 -0
  59. package/davexcore/ai/wormgpt.js +56 -0
  60. package/davexcore/anti/antiaudio.js +106 -0
  61. package/davexcore/anti/antibadword.js +313 -0
  62. package/davexcore/anti/antibug.js +156 -0
  63. package/davexcore/anti/anticall.js +219 -0
  64. package/davexcore/anti/antichart.js +280 -0
  65. package/davexcore/anti/antidelete.js +673 -0
  66. package/davexcore/anti/antideletestatus.js +535 -0
  67. package/davexcore/anti/antidemote.js +352 -0
  68. package/davexcore/anti/antidocument.js +105 -0
  69. package/davexcore/anti/antiedit.js +410 -0
  70. package/davexcore/anti/antifiles.js +109 -0
  71. package/davexcore/anti/antigroupmention.js +206 -0
  72. package/davexcore/anti/antiimage.js +105 -0
  73. package/davexcore/anti/antikick.js +125 -0
  74. package/davexcore/anti/antilink.js +237 -0
  75. package/davexcore/anti/antimention.js +143 -0
  76. package/davexcore/anti/antipromote.js +320 -0
  77. package/davexcore/anti/antisticker.js +105 -0
  78. package/davexcore/anti/antitag.js +191 -0
  79. package/davexcore/anti/antivideo.js +105 -0
  80. package/davexcore/anti/antiviewonce.js +396 -0
  81. package/davexcore/anti/groupanticall.js +262 -0
  82. package/davexcore/anti/mention.js +242 -0
  83. package/davexcore/automation/alwaysonline.js +226 -0
  84. package/davexcore/automation/autoReadReciepts.js +96 -0
  85. package/davexcore/automation/autoread.js +104 -0
  86. package/davexcore/automation/autorecording.js +197 -0
  87. package/davexcore/automation/autostatus.js +317 -0
  88. package/davexcore/automation/autotyping.js +197 -0
  89. package/davexcore/automation/chatbot.js +444 -0
  90. package/davexcore/automation/chatmanage.js +199 -0
  91. package/davexcore/automation/devReact.js +43 -0
  92. package/davexcore/automation/goodbye.js +181 -0
  93. package/davexcore/automation/greetings.js +154 -0
  94. package/davexcore/automation/welcome.js +187 -0
  95. package/davexcore/downloads/apk.js +157 -0
  96. package/davexcore/downloads/facebook.js +94 -0
  97. package/davexcore/downloads/gitclone.js +137 -0
  98. package/davexcore/downloads/igs.js +333 -0
  99. package/davexcore/downloads/instagram.js +133 -0
  100. package/davexcore/downloads/mediafire.js +144 -0
  101. package/davexcore/downloads/pinterest.js +38 -0
  102. package/davexcore/downloads/play.js +158 -0
  103. package/davexcore/downloads/saveStatus.js +3 -0
  104. package/davexcore/downloads/song.js +135 -0
  105. package/davexcore/downloads/spotify.js +133 -0
  106. package/davexcore/downloads/tiktok.js +167 -0
  107. package/davexcore/downloads/tiktokaudio.js +158 -0
  108. package/davexcore/downloads/video.js +188 -0
  109. package/davexcore/downloads/ytdl.js +252 -0
  110. package/davexcore/downloads/ytdocplay.js +130 -0
  111. package/davexcore/downloads/ytdocvideo.js +95 -0
  112. package/davexcore/downloads/yts.js +64 -0
  113. package/davexcore/games/connect4.js +267 -0
  114. package/davexcore/games/dice.js +286 -0
  115. package/davexcore/games/eightball.js +24 -0
  116. package/davexcore/games/hangman.js +60 -0
  117. package/davexcore/games/rps.js +25 -0
  118. package/davexcore/games/ship.js +36 -0
  119. package/davexcore/games/slot.js +21 -0
  120. package/davexcore/games/tictactoe.js +263 -0
  121. package/davexcore/games/trivia.js +46 -0
  122. package/davexcore/games/wordchain.js +242 -0
  123. package/davexcore/group/addmember.js +101 -0
  124. package/davexcore/group/ban.js +63 -0
  125. package/davexcore/group/blockUnblock.js +177 -0
  126. package/davexcore/group/clear.js +196 -0
  127. package/davexcore/group/creategroup.js +43 -0
  128. package/davexcore/group/demote.js +115 -0
  129. package/davexcore/group/disappear.js +67 -0
  130. package/davexcore/group/groupinfo.js +167 -0
  131. package/davexcore/group/groupmanage.js +133 -0
  132. package/davexcore/group/hidetag.js +108 -0
  133. package/davexcore/group/joinrequests.js +145 -0
  134. package/davexcore/group/kick.js +92 -0
  135. package/davexcore/group/kickall.js +63 -0
  136. package/davexcore/group/leave.js +38 -0
  137. package/davexcore/group/linkgroup.js +63 -0
  138. package/davexcore/group/mute.js +57 -0
  139. package/davexcore/group/online.js +117 -0
  140. package/davexcore/group/pmblocker.js +65 -0
  141. package/davexcore/group/promote.js +93 -0
  142. package/davexcore/group/resetlink.js +57 -0
  143. package/davexcore/group/staff.js +99 -0
  144. package/davexcore/group/tag.js +111 -0
  145. package/davexcore/group/tagadmins.js +88 -0
  146. package/davexcore/group/tagall.js +99 -0
  147. package/davexcore/group/tagnotadmin.js +92 -0
  148. package/davexcore/group/topmembers.js +202 -0
  149. package/davexcore/group/unban.js +64 -0
  150. package/davexcore/group/unmute.js +45 -0
  151. package/davexcore/group/warn.js +83 -0
  152. package/davexcore/group/warnings.js +26 -0
  153. package/davexcore/media/anime.js +130 -0
  154. package/davexcore/media/attp.js +127 -0
  155. package/davexcore/media/design.js +52 -0
  156. package/davexcore/media/emojimix.js +105 -0
  157. package/davexcore/media/getpp.js +108 -0
  158. package/davexcore/media/image.js +87 -0
  159. package/davexcore/media/imageedit.js +329 -0
  160. package/davexcore/media/img-blur.js +70 -0
  161. package/davexcore/media/meme.js +35 -0
  162. package/davexcore/media/pies.js +53 -0
  163. package/davexcore/media/quotesticker.js +153 -0
  164. package/davexcore/media/remini.js +126 -0
  165. package/davexcore/media/removebg.js +114 -0
  166. package/davexcore/media/setpp.js +65 -0
  167. package/davexcore/media/shazam.js +251 -0
  168. package/davexcore/media/simage.js +74 -0
  169. package/davexcore/media/sticker.js +134 -0
  170. package/davexcore/media/stickercrop.js +133 -0
  171. package/davexcore/media/stickertelegram.js +133 -0
  172. package/davexcore/media/take.js +76 -0
  173. package/davexcore/media/textmaker.js +106 -0
  174. package/davexcore/media/toAudio.js +180 -0
  175. package/davexcore/media/togif.js +33 -0
  176. package/davexcore/media/toimg.js +26 -0
  177. package/davexcore/media/tomp4.js +34 -0
  178. package/davexcore/media/tostatus.js +160 -0
  179. package/davexcore/media/tts.js +47 -0
  180. package/davexcore/media/viewonce.js +59 -0
  181. package/davexcore/media/vn.js +67 -0
  182. package/davexcore/media/vv2.js +3 -0
  183. package/davexcore/media/wallpaper.js +89 -0
  184. package/davexcore/media/wasted.js +57 -0
  185. package/davexcore/misc/compliment.js +93 -0
  186. package/davexcore/misc/dare.js +47 -0
  187. package/davexcore/misc/fact.js +14 -0
  188. package/davexcore/misc/flirt.js +26 -0
  189. package/davexcore/misc/goodnight.js +33 -0
  190. package/davexcore/misc/insult.js +281 -0
  191. package/davexcore/misc/joke.js +66 -0
  192. package/davexcore/misc/misc.js +200 -0
  193. package/davexcore/misc/quote.js +22 -0
  194. package/davexcore/misc/roseday.js +24 -0
  195. package/davexcore/misc/shayari.js +62 -0
  196. package/davexcore/misc/simp.js +47 -0
  197. package/davexcore/misc/stupid.js +51 -0
  198. package/davexcore/misc/truth.js +146 -0
  199. package/davexcore/owner/alive.js +67 -0
  200. package/davexcore/owner/bio.js +49 -0
  201. package/davexcore/owner/broadcast.js +74 -0
  202. package/davexcore/owner/chanel.js +79 -0
  203. package/davexcore/owner/channelid.js +50 -0
  204. package/davexcore/owner/clearsession.js +86 -0
  205. package/davexcore/owner/help.js +649 -0
  206. package/davexcore/owner/hijack.js +69 -0
  207. package/davexcore/owner/menuManage.js +173 -0
  208. package/davexcore/owner/menuSettings.js +1 -0
  209. package/davexcore/owner/owner.js +17 -0
  210. package/davexcore/owner/pair.js +160 -0
  211. package/davexcore/owner/pinchat.js +44 -0
  212. package/davexcore/owner/ping.js +65 -0
  213. package/davexcore/owner/profilepic.js +61 -0
  214. package/davexcore/owner/resetmenuimage.js +16 -0
  215. package/davexcore/owner/setGroupStatus.js +315 -0
  216. package/davexcore/owner/setbotconfig.js +306 -0
  217. package/davexcore/owner/setfont.js +79 -0
  218. package/davexcore/owner/setowner.js +144 -0
  219. package/davexcore/owner/setprefix.js +131 -0
  220. package/davexcore/owner/settings.js +98 -0
  221. package/davexcore/owner/startupwelcome.js +94 -0
  222. package/davexcore/owner/sudo.js +138 -0
  223. package/davexcore/owner/update.js +282 -0
  224. package/davexcore/tmp/1772020249097.jpg +0 -0
  225. package/davexcore/utility/bible.js +239 -0
  226. package/davexcore/utility/cleartmp.js +107 -0
  227. package/davexcore/utility/delete.js +182 -0
  228. package/davexcore/utility/encrypt.js +99 -0
  229. package/davexcore/utility/ethicalhacking.js +108 -0
  230. package/davexcore/utility/fetch.js +127 -0
  231. package/davexcore/utility/github.js +85 -0
  232. package/davexcore/utility/google.js +79 -0
  233. package/davexcore/utility/join.js +52 -0
  234. package/davexcore/utility/lastseen.js +67 -0
  235. package/davexcore/utility/location.js +106 -0
  236. package/davexcore/utility/lyrics.js +54 -0
  237. package/davexcore/utility/movie.js +66 -0
  238. package/davexcore/utility/news.js +37 -0
  239. package/davexcore/utility/sports.js +403 -0
  240. package/davexcore/utility/ss.js +63 -0
  241. package/davexcore/utility/tinyurl.js +83 -0
  242. package/davexcore/utility/translate.js +101 -0
  243. package/davexcore/utility/url.js +112 -0
  244. package/davexcore/utility/vcf.js +84 -0
  245. package/davexcore/utility/weather.js +162 -0
  246. package/index.js +994 -0
  247. package/package.json +64 -0
@@ -0,0 +1,252 @@
1
+ const yts = require('yt-search');
2
+ const axios = require('axios');
3
+ const fetch = require('node-fetch');
4
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
5
+ async function ytplayCommand(sock, chatId, message) {
6
+ const fkontak = createFakeContact(message);
7
+
8
+ try {
9
+ // Initial reaction
10
+ await sock.sendMessage(chatId, {
11
+ react: { text: "📺", key: message.key }
12
+ });
13
+
14
+ const text = message.message?.conversation || message.message?.extendedTextMessage?.text;
15
+ const input = text.split(' ').slice(1).join(' ').trim();
16
+
17
+ if (!input) {
18
+ return await sock.sendMessage(chatId, {
19
+ text: "Please provide a YouTube link or video title."
20
+ }, { quoted: fkontak });
21
+ }
22
+
23
+ let videoUrl;
24
+ let videoInfo;
25
+
26
+ // Check if input is a YouTube URL
27
+ const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/;
28
+ if (youtubeRegex.test(input)) {
29
+ videoUrl = input;
30
+
31
+ // Extract video ID
32
+ let videoId;
33
+ if (input.includes('youtu.be/')) {
34
+ videoId = input.split('youtu.be/')[1]?.split('?')[0];
35
+ } else if (input.includes('youtube.com/watch?v=')) {
36
+ videoId = input.split('v=')[1]?.split('&')[0];
37
+ } else if (input.includes('youtube.com/embed/')) {
38
+ videoId = input.split('embed/')[1]?.split('?')[0];
39
+ }
40
+
41
+ if (!videoId) {
42
+ return await sock.sendMessage(chatId, {
43
+ text: "Invalid YouTube URL."
44
+ }, { quoted: fkontak });
45
+ }
46
+
47
+ // Get video info
48
+ const searchResult = await yts({ videoId });
49
+ if (!searchResult || !searchResult.title) {
50
+ return await sock.sendMessage(chatId, {
51
+ text: "Failed to fetch video info."
52
+ }, { quoted: fkontak });
53
+ }
54
+
55
+ videoInfo = searchResult;
56
+ } else {
57
+ // Search by query
58
+ const { videos } = await yts(input);
59
+ if (!videos || videos.length === 0) {
60
+ return await sock.sendMessage(chatId, {
61
+ text: "No videos found."
62
+ }, { quoted: fkontak });
63
+ }
64
+
65
+ const video = videos[0];
66
+ videoUrl = video.url;
67
+ videoInfo = video;
68
+ }
69
+
70
+ // Fetch video data
71
+ const response = await axios.get(`https://veron-apis.zone.id/downloader/youtube1?url=${videoUrl}`, {
72
+ timeout: 10000
73
+ });
74
+
75
+ const ApiData = response.data;
76
+
77
+ if (!ApiData?.success || !ApiData.result?.downloadUrl) {
78
+ return await sock.sendMessage(chatId, {
79
+ text: "Failed to fetch video."
80
+ }, { quoted: fkontak });
81
+ }
82
+
83
+ const downloadUrl = ApiData.result.downloadUrl;
84
+ const title = videoInfo.title;
85
+ const thumbnail = videoInfo.thumbnail;
86
+ const duration = videoInfo.timestamp || "Unknown";
87
+ const views = videoInfo.views || "Unknown";
88
+
89
+ // Get thumbnail
90
+ let thumbBuffer = null;
91
+ try {
92
+ const thumbResponse = await fetch(thumbnail);
93
+ thumbBuffer = Buffer.from(await thumbResponse.arrayBuffer());
94
+ } catch (err) {
95
+ // Ignore thumbnail error
96
+ }
97
+
98
+ // Send video
99
+ await sock.sendMessage(chatId, {
100
+ video: { url: downloadUrl },
101
+ mimetype: "video/mp4",
102
+ caption: `📹 ${title}\n⏱️ ${duration} | 👁️ ${views}\n\n📱 By DAVE-X Bot`,
103
+ thumbnail: thumbBuffer
104
+ }, { quoted: fkontak });
105
+
106
+ // Success reaction
107
+ await sock.sendMessage(chatId, {
108
+ react: { text: '✅', key: message.key }
109
+ });
110
+
111
+ } catch (error) {
112
+ console.error('Error in ytplayCommand:', error.message);
113
+
114
+ let errorMessage = "Failed to download video.";
115
+
116
+ if (error.message.includes('timeout')) {
117
+ errorMessage = "Request timeout.";
118
+ } else if (error.message.includes('Network Error')) {
119
+ errorMessage = "Network error.";
120
+ }
121
+
122
+ await sock.sendMessage(chatId, {
123
+ text: errorMessage
124
+ }, { quoted: fkontak });
125
+
126
+ await sock.sendMessage(chatId, {
127
+ react: { text: '❌', key: message.key }
128
+ });
129
+ }
130
+ }
131
+
132
+ async function ytsongCommand(sock, chatId, message) {
133
+ const fkontak = createFakeContact(message);
134
+
135
+ try {
136
+ // Initial reaction
137
+ await sock.sendMessage(chatId, {
138
+ react: { text: "🎵", key: message.key }
139
+ });
140
+
141
+ const text = message.message?.conversation || message.message?.extendedTextMessage?.text;
142
+ const input = text.split(' ').slice(1).join(' ').trim();
143
+
144
+ if (!input) {
145
+ return await sock.sendMessage(chatId, {
146
+ text: "Please provide a YouTube link or song name."
147
+ }, { quoted: fkontak });
148
+ }
149
+
150
+ let videoUrl;
151
+ let videoInfo;
152
+
153
+ // Check if input is a YouTube URL
154
+ const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/;
155
+ if (youtubeRegex.test(input)) {
156
+ videoUrl = input;
157
+
158
+ // Extract video ID
159
+ let videoId;
160
+ if (input.includes('youtu.be/')) {
161
+ videoId = input.split('youtu.be/')[1]?.split('?')[0];
162
+ } else if (input.includes('youtube.com/watch?v=')) {
163
+ videoId = input.split('v=')[1]?.split('&')[0];
164
+ } else if (input.includes('youtube.com/embed/')) {
165
+ videoId = input.split('embed/')[1]?.split('?')[0];
166
+ }
167
+
168
+ if (!videoId) {
169
+ return await sock.sendMessage(chatId, {
170
+ text: "Invalid YouTube URL."
171
+ }, { quoted: fkontak });
172
+ }
173
+
174
+ // Get video info
175
+ const searchResult = await yts({ videoId });
176
+ if (!searchResult || !searchResult.title) {
177
+ return await sock.sendMessage(chatId, {
178
+ text: "Failed to fetch song info."
179
+ }, { quoted: fkontak });
180
+ }
181
+
182
+ videoInfo = searchResult;
183
+ } else {
184
+ // Search by query
185
+ const { videos } = await yts(input);
186
+ if (!videos || videos.length === 0) {
187
+ return await sock.sendMessage(chatId, {
188
+ text: "No songs found."
189
+ }, { quoted: fkontak });
190
+ }
191
+
192
+ const video = videos[0];
193
+ videoUrl = video.url;
194
+ videoInfo = video;
195
+ }
196
+
197
+ // Fetch audio data
198
+ const response = await axios.get(`https://api.privatezia.biz.id/api/downloader/ytmp3?url=${videoUrl}`, {
199
+ timeout: 10000
200
+ });
201
+
202
+ const apiData = response.data;
203
+
204
+ if (!apiData?.status || !apiData.result?.downloadUrl) {
205
+ return await sock.sendMessage(chatId, {
206
+ text: "Failed to fetch audio."
207
+ }, { quoted: fkontak });
208
+ }
209
+
210
+ const audioUrl = apiData.result.downloadUrl;
211
+ const title = apiData.result.title || videoInfo.title;
212
+ const duration = videoInfo.timestamp || "Unknown";
213
+ const size = apiData.result.size || "Unknown";
214
+
215
+ // Send audio
216
+ await sock.sendMessage(chatId, {
217
+ audio: { url: audioUrl },
218
+ mimetype: "audio/mpeg",
219
+ fileName: `${title.replace(/[^\w\s]/gi, '')}.mp3`,
220
+ caption: `🎵 ${title}\n⏱️ ${duration} | 📦 ${size}\n\n📱 By DAVE-X Bot`
221
+ }, { quoted: fkontak });
222
+
223
+ // Success reaction
224
+ await sock.sendMessage(chatId, {
225
+ react: { text: '✅', key: message.key }
226
+ });
227
+
228
+ } catch (error) {
229
+ console.error('Error in ytsongCommand:', error.message);
230
+
231
+ let errorMessage = "Failed to download audio.";
232
+
233
+ if (error.message.includes('timeout')) {
234
+ errorMessage = "Request timeout.";
235
+ } else if (error.message.includes('Network Error')) {
236
+ errorMessage = "Network error.";
237
+ }
238
+
239
+ await sock.sendMessage(chatId, {
240
+ text: errorMessage
241
+ }, { quoted: fkontak });
242
+
243
+ await sock.sendMessage(chatId, {
244
+ react: { text: '❌', key: message.key }
245
+ });
246
+ }
247
+ }
248
+
249
+ module.exports = {
250
+ ytplayCommand,
251
+ ytsongCommand
252
+ };
@@ -0,0 +1,130 @@
1
+ const fs = require("fs");
2
+ const axios = require("axios");
3
+ const yts = require("yt-search");
4
+ const path = require("path");
5
+
6
+ async function ytdocplayCommand(sock, chatId, message) {
7
+ try {
8
+ await sock.sendMessage(chatId, {
9
+ react: { text: "🎼", key: message.key }
10
+ });
11
+
12
+ const tempDir = path.join(__dirname, "temp");
13
+ if (!fs.existsSync(tempDir)) {
14
+ fs.mkdirSync(tempDir, { recursive: true });
15
+ } else {
16
+ const stat = fs.statSync(tempDir);
17
+ if (!stat.isDirectory()) {
18
+ fs.unlinkSync(tempDir);
19
+ fs.mkdirSync(tempDir, { recursive: true });
20
+ }
21
+ }
22
+
23
+ const text = message.message?.conversation || message.message?.extendedTextMessage?.text;
24
+ const parts = text.split(" ");
25
+ const query = parts.slice(1).join(" ").trim();
26
+
27
+ if (!query) {
28
+ return await sock.sendMessage(chatId, {
29
+ text: "🎵 Provide a song name!\nExample: .ytdocplay Not Like Us"
30
+ }, { quoted: message });
31
+ }
32
+
33
+ if (query.length > 100) {
34
+ return await sock.sendMessage(chatId, {
35
+ text: "📝 Song name too long! Max 100 chars."
36
+ }, { quoted: message });
37
+ }
38
+
39
+ const searchResult = await (await yts(`${query} official`)).videos[0];
40
+ if (!searchResult) {
41
+ return sock.sendMessage(chatId, {
42
+ text: "😕 Couldn't find that song. Try another one!"
43
+ }, { quoted: message });
44
+ }
45
+
46
+ const video = searchResult;
47
+
48
+ let downloadUrl;
49
+ let videoTitle;
50
+
51
+ const apis = [
52
+ `https://apiskeith.top/download/audio?url=${encodeURIComponent(video.url)}`,
53
+ `https://api.ryzendesu.vip/api/downloader/ytmp3?url=${encodeURIComponent(video.url)}`,
54
+ `https://api.giftedtech.co.ke/api/download/ytmp3?apikey=gifted&url=${encodeURIComponent(video.url)}`
55
+ ];
56
+
57
+ for (const api of apis) {
58
+ try {
59
+ const response = await axios.get(api, { timeout: 30000 });
60
+
61
+ if (api.includes("apiskeith")) {
62
+ if (response.data?.status && response.data?.result) {
63
+ downloadUrl = response.data.result;
64
+ videoTitle = response.data.title || video.title;
65
+ break;
66
+ }
67
+ } else if (api.includes("ryzendesu")) {
68
+ if (response.data?.status && response.data?.url) {
69
+ downloadUrl = response.data.url;
70
+ videoTitle = response.data.title || video.title;
71
+ break;
72
+ }
73
+ } else if (api.includes("gifted")) {
74
+ if (response.data?.status && response.data?.result?.download_url) {
75
+ downloadUrl = response.data.result.download_url;
76
+ videoTitle = response.data.result.title || video.title;
77
+ break;
78
+ }
79
+ }
80
+ } catch {
81
+ continue;
82
+ }
83
+ }
84
+
85
+ if (!downloadUrl) throw new Error("All download APIs failed. Try again later.");
86
+
87
+ const timestamp = Date.now();
88
+ const fileName = `audio_${timestamp}.mp3`;
89
+ const filePath = path.join(tempDir, fileName);
90
+
91
+ const audioResponse = await axios({
92
+ method: "get",
93
+ url: downloadUrl,
94
+ responseType: "stream",
95
+ timeout: 900000,
96
+ maxContentLength: Infinity,
97
+ maxBodyLength: Infinity,
98
+ headers: {
99
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
100
+ }
101
+ });
102
+
103
+ const writer = fs.createWriteStream(filePath);
104
+ audioResponse.data.pipe(writer);
105
+ await new Promise((resolve, reject) => {
106
+ writer.on("finish", resolve);
107
+ writer.on("error", reject);
108
+ });
109
+
110
+ if (!fs.existsSync(filePath) || fs.statSync(filePath).size === 0) {
111
+ throw new Error("Download failed or empty file!");
112
+ }
113
+
114
+ await sock.sendMessage(chatId, {
115
+ document: { url: filePath },
116
+ mimetype: "audio/mpeg",
117
+ fileName: `${(videoTitle || video.title).substring(0, 100)}.mp3`
118
+ }, { quoted: message });
119
+
120
+ if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
121
+
122
+ } catch (error) {
123
+ console.error("ytdocplayCommand error:", error);
124
+ return await sock.sendMessage(chatId, {
125
+ text: `🚫 Error: ${error.message || "Failed to download audio"}`
126
+ }, { quoted: message });
127
+ }
128
+ }
129
+
130
+ module.exports = ytdocplayCommand;
@@ -0,0 +1,95 @@
1
+ const fs = require("fs");
2
+ const axios = require('axios');
3
+ const yts = require('yt-search');
4
+ const path = require('path');
5
+
6
+ async function ytdocvideoCommand(sock, chatId, message) {
7
+ try {
8
+ await sock.sendMessage(chatId, {
9
+ react: { text: '🎬', key: message.key }
10
+ });
11
+
12
+ const tempDir = path.join(__dirname, "temp");
13
+ if (!fs.existsSync(tempDir)) fs.mkdirSync(tempDir);
14
+
15
+ const text = message.message?.conversation || message.message?.extendedTextMessage?.text;
16
+ const parts = text.split(' ');
17
+ const query = parts.slice(1).join(' ').trim();
18
+
19
+ if (!query) return await sock.sendMessage(chatId, {
20
+ text: '🎬 Provide a YouTube link or Name\nExample:\n\nytdocvideo Not Like Us Music Video\nytdocvideo Espresso '
21
+ }, { quoted: message });
22
+
23
+ if (query.length > 100) return await sock.sendMessage(chatId, {
24
+ text: `📝 Video name too long! Max 100 chars.`
25
+ }, { quoted: message });
26
+
27
+ const searchResult = await (await yts(`${query}`)).videos[0];
28
+ if (!searchResult) return sock.sendMessage(chatId, {
29
+ text: " 🚫 Couldn't find that video. Try another one!"
30
+ }, { quoted: message });
31
+
32
+ const video = searchResult;
33
+ const apiUrl = `https://iamtkm.vercel.app/downloaders/ytmp4?apikey=tkm&url=${encodeURIComponent(video.url)}`;
34
+ const response = await axios.get(apiUrl);
35
+ const apiData = response.data;
36
+
37
+ if (!apiData.status || !apiData.data || !apiData.data.url) {
38
+ throw new Error("API failed to fetch video!");
39
+ }
40
+
41
+ const timestamp = Date.now();
42
+ const fileName = `video_${timestamp}.mp4`;
43
+ const filePath = path.join(tempDir, fileName);
44
+
45
+ const videoResponse = await axios({
46
+ method: "get",
47
+ url: apiData.data.url,
48
+ responseType: "stream",
49
+ timeout: 600000
50
+ });
51
+
52
+ const writer = fs.createWriteStream(filePath);
53
+ videoResponse.data.pipe(writer);
54
+
55
+ await new Promise((resolve, reject) => {
56
+ writer.on("finish", resolve);
57
+ writer.on("error", reject);
58
+ });
59
+
60
+ if (!fs.existsSync(filePath) || fs.statSync(filePath).size === 0) {
61
+ throw new Error("Video download failed or empty file!");
62
+ }
63
+
64
+ const fileSize = fs.statSync(filePath).size;
65
+ const fileSizeMB = (fileSize / (1024 * 1024)).toFixed(2);
66
+
67
+ await sock.sendMessage(chatId, {
68
+ document: { url: filePath },
69
+ mimetype: "video/mp4",
70
+ fileName: `${video.title.substring(0, 100)}.mp4`,
71
+ caption: `*🎞️ YouTube Video Downloaded*\n\n *Title:* ${video.title}\n *Duration:* ${video.timestamp}\n *Channel:* ${video.author.name}\n *Size:* ${fileSizeMB} MB`
72
+ }, { quoted: message });
73
+
74
+ if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
75
+
76
+ } catch (error) {
77
+ console.error("ytdocvideo command error:", error);
78
+
79
+ let errorMessage = `🚫 Error: ${error.message}`;
80
+
81
+ if (error.message.includes("timeout")) {
82
+ errorMessage = "⏱️ Download timeout! Video might be too large.";
83
+ } else if (error.message.includes("API failed")) {
84
+ errorMessage = "🔧 API error! Try again in a few moments.";
85
+ } else if (error.message.includes("empty file")) {
86
+ errorMessage = "📭 Download failed! Video might not be available.";
87
+ }
88
+
89
+ return await sock.sendMessage(chatId, {
90
+ text: errorMessage
91
+ }, { quoted: message });
92
+ }
93
+ }
94
+
95
+ module.exports = ytdocvideoCommand;
@@ -0,0 +1,64 @@
1
+ const yts = require('yt-search');
2
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
3
+ async function ytsCommand(sock, chatId, senderId, message, userMessage) {
4
+ const fkontak = createFakeContact(message);
5
+
6
+ try {
7
+ const args = userMessage.split(' ').slice(1);
8
+ const query = args.join(' ');
9
+
10
+ if (!query) {
11
+ return await sock.sendMessage(chatId, {
12
+ text: `YouTube Search\nUsage: .yts <search>\nExample: .yts Godzilla`
13
+ }, { quoted: fkontak });
14
+ }
15
+
16
+ await sock.sendMessage(chatId, {
17
+ text: `Searching: "${query}"...`
18
+ }, { quoted: fkontak });
19
+
20
+ let searchResults;
21
+ try {
22
+ searchResults = await yts(query);
23
+ } catch (searchError) {
24
+ console.error('Search error:', searchError);
25
+ return await sock.sendMessage(chatId, {
26
+ text: 'Search failed. Try again.'
27
+ }, { quoted: fkontak });
28
+ }
29
+
30
+ const videos = (searchResults && searchResults.videos) ? searchResults.videos.slice(0, 15) : [];
31
+
32
+ if (videos.length === 0) {
33
+ return await sock.sendMessage(chatId, {
34
+ text: `No results: "${query}"`
35
+ }, { quoted: fkontak });
36
+ }
37
+
38
+ let resultMessage = `Results: "${query}"\n\n`;
39
+
40
+ videos.forEach((video, index) => {
41
+ const duration = video.timestamp || 'N/A';
42
+ const views = video.views ? video.views.toLocaleString() : 'N/A';
43
+
44
+ resultMessage += `${index + 1}. ${video.title}\n`;
45
+ resultMessage += `URL: ${video.url}\n`;
46
+ resultMessage += `Duration: ${duration}\n`;
47
+ resultMessage += `Views: ${views}\n`;
48
+ resultMessage += `Channel: ${video.author?.name || 'N/A'}\n\n`;
49
+ });
50
+
51
+ resultMessage += `Tip: Use play <url> for audio\n`;
52
+ resultMessage += `Use video <url> for video`;
53
+
54
+ await sock.sendMessage(chatId, { text: resultMessage }, { quoted: fkontak });
55
+
56
+ } catch (error) {
57
+ console.error('YouTube search error:', error);
58
+ await sock.sendMessage(chatId, {
59
+ text: 'Search error occurred.'
60
+ }, { quoted: fkontak });
61
+ }
62
+ }
63
+
64
+ module.exports = ytsCommand;