File size: 3,175 Bytes
0abf1f9
b39b200
0abf1f9
 
 
 
 
 
 
 
 
5846f1b
 
 
 
0abf1f9
b39b200
2b202fe
e494c6b
 
a34117c
 
 
e494c6b
 
 
2b202fe
c4e245d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
618501b
 
c4e245d
 
618501b
c4e245d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
618501b
c4e245d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*

$$$$$$\            $$\                                               
$$  __$$\           $$ |                                              
$$ /  \__|$$\   $$\ $$$$$$$\  $$$$$$$$\  $$$$$$\   $$$$$$\   $$$$$$\  
\$$$$$$\  $$ |  $$ |$$  __$$\ \____$$  |$$  __$$\ $$  __$$\ $$  __$$\ 
 \____$$\ $$ |  $$ |$$ |  $$ |  $$$$ _/ $$$$$$$$ |$$ |  \__|$$ /  $$ |
$$\   $$ |$$ |  $$ |$$ |  $$ | $$  _/   $$   ____|$$ |      $$ |  $$ |
\$$$$$$  |\$$$$$$  |$$$$$$$  |$$$$$$$$\ \$$$$$$$\ $$ |      \$$$$$$  |
 \______/  \______/ \_______/ \________| \_______|\__|       \______/

Project Name : ENCRYPTO-27
Creator      : Diego Allies ( DUDAS OFC )
Repo         : https//github.com/mrfrank-ofc/ENCRYPTO-27
Support      : wa.me/27679291800
*/

const config = require('../config');
const { cmd, commands } = require('../command');
const { fetchJson } = require('../lib/functions');
const axios = require("axios");




cmd({
  pattern: 'mediafirepro',
  desc: 'Download MediaFire files',
  category: 'download',
  filename: __filename
}, async (conn, mek, m, {
  body,
  from,
  quoted,
  isCmd,
  command,
  args,
  q,
  isGroup,
  sender,
  senderNumber,
  botNumber2,
  botNumber,
  pushname,
  isMe,
  isOwner,
  groupMetadata,
  groupName,
  participants,
  groupAdmins,
  isBotAdmins,
  isAdmins,
  reply
}) => {
  try {
    const text = body.trim().replace(command, '').trim();
    if (!text) return reply(`*Example*: ${command} https://www.mediafire.com/file/n6tgcrktbnov1oy/Queen_Anita-V4.zip/file`);
console.log(text);
    await reply('> *Processing...*');

    const apiUrl = `https://api.davidcyriltech.my.id/mediafire?url=${encodeURIComponent(text)}`;
console.log(apiUrl);
    let retries = 0;
    const maxRetries = 3;
    const retryDelay = 500; // 500ms

    while (retries < maxRetries) {
      try {
        const apiResponse = await axios.get(apiUrl);
        console.log('API response:', apiResponse);

        if (apiResponse.data && apiResponse.data.downloadLink) {
          const { fileName, mimeType, downloadLink } = apiResponse.data;

          await conn.sendMessage(m.chat, {
            document: { url: downloadLink },
            mimetype: mimeType,
            fileName: fileName,
            caption: `📦 *File Name:* ${fileName}\n\n> ᴘᴏᴡᴇʀᴇᴅ ʙʏ sᴜʙᴢᴇʀᴏ ᴍᴅ`
          }, { quoted: m });
          return;
        } else {
          reply(`*Failed to fetch file details! Please check the MediaFire URL and try again.*`);
          return;
        }
      } catch (error) {
        console.error('Error fetching API response:', error);
        if (error.response && error.response.status === 500) {
          retries++;
          await new Promise(resolve => setTimeout(resolve, retryDelay));
        } else {
          reply(`*Error fetching API response: ${error.message}*`);
          return;
        }
      }
    }

    reply(`*Failed to fetch API response after ${maxRetries} retries.*`);
  } catch (error) {
    console.error('Error during MediaFire command:', error);
    reply(`*An error occurred while processing your request. Please try again later.*\n\nError details: ${error.message}\n${error.stack}`);
  }
});