// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs"); const path = require("path"); const cheerio = require("cheerio"); module.exports = { config: { name: "sent", version: "2.1.0", author: "D-Jukie × GoatBot V2", countDown: 0, role: 2, shortDescription: { en: "Apply and upload command code" }, longDescription: { en: "Apply code from Pastebin, BuildTool, TinyURL or Google Drive." }, category: "Admin", guide: { en: "{pn} " } }, onStart: async function ({ api, event, args }) { const { threadID, messageID, messageReply } = event; if (!args[0]) { return api.sendMessage( "╭───〔 𝐒𝐄𝐍𝐓 〕───╮\n" + "│\n" + "│ ❌ File name missing!\n" + "│\n" + "│ ✦ Example:\n" + "│ .sent janu\n" + "│\n" + "╰────────────────╯", threadID, messageID ); } const fileName = args[0].replace(/\.js$/i, ""); const filePath = path.join(__dirname, `${fileName}.js`); /* ========================= REPLY LINK → APPLY CODE ========================= */ if (messageReply && messageReply.body) { const text = messageReply.body.trim(); const match = text.match(/https?:\/\/[^\s<>"']+/i); if (!match) { return api.sendMessage( "╭───〔 ❌ 𝐈𝐍𝐕𝐀𝐋𝐈𝐃 𝐋𝐈𝐍𝐊 〕───╮\n" + "│\n" + "│ Reply to a message containing\n" + "│ a valid link.\n" + "│\n" + "╰────────────────────╯", threadID, messageID ); } const url = match[0].replace(/[)\],.!?]+$/, ""); try { /* ========================= PASTEBIN ========================= */ if (url.includes("pastebin.com")) { const pasteMatch = url.match( /pastebin\.com\/(?:raw\/)?([a-zA-Z0-9]+)/ ); if (!pasteMatch) { return api.sendMessage( "❌ | Invalid Pastebin link.", threadID, messageID ); } const rawURL = `https://pastebin.com/raw/${pasteMatch[1]}`; const response = await axios.get(rawURL, { timeout: 15000 }); if (!response.data || !String(response.data).trim()) { return api.sendMessage( "❌ | Pastebin code is empty.", threadID, messageID ); } fs.writeFileSync( filePath, response.data, "utf8" ); return api.sendMessage( "╭───〔 ✅ 𝐂𝐎𝐃𝐄 𝐀𝐏𝐏𝐋𝐈𝐄𝐃 〕───╮\n" + "│\n" + `│ 📁 File : ${fileName}.js\n` + "│\n" + "│ ✦ Pastebin code added.\n" + "│ ✦ Use load to activate.\n" + "│\n" + "╰────────────────────────╯", threadID, messageID ); } /* ========================= BUILDTOOL / TINYURL ========================= */ if ( url.includes("buildtool") || url.includes("tinyurl.com") ) { const response = await axios.get(url, { timeout: 20000 }); const $ = cheerio.load(response.data); let code = ""; $(".language-js").each((index, element) => { if (index === 0) { code = $(element).text(); } }); if (!code) { $("pre code").each((index, element) => { if (index === 0) { code = $(element).text(); } }); } if (!code.trim()) { return api.sendMessage( "╭───〔 ❌ 𝐂𝐎𝐃𝐄 𝐍𝐎𝐓 𝐅𝐎𝐔𝐍𝐃 〕───╮\n" + "│\n" + "│ JavaScript code not found.\n" + "│\n" + "╰──────────────────────╯", threadID, messageID ); } fs.writeFileSync( filePath, code, "utf8" ); return api.sendMessage( "╭───〔 ✅ 𝐂𝐎𝐃𝐄 𝐀𝐏𝐏𝐋𝐈𝐄𝐃 〕───╮\n" + "│\n" + `│ 📁 File : ${fileName}.js\n` + "│\n" + "│ ✦ BuildTool code added.\n" + "│ ✦ Use load to activate.\n" + "│\n" + "╰────────────────────────╯", threadID, messageID ); } /* ========================= GOOGLE DRIVE ========================= */ if (url.includes("drive.google.com")) { const idMatch = url.match( /(?:id=|\/d\/)([-\w]{25,})/ ); if (!idMatch) { return api.sendMessage( "❌ | Google Drive file ID not found.", threadID, messageID ); } const driveID = idMatch[1]; const downloadURL = `https://drive.google.com/uc?export=download&id=${driveID}`; const response = await axios.get( downloadURL, { responseType: "arraybuffer", timeout: 30000 } ); fs.writeFileSync( filePath, response.data ); return api.sendMessage( "╭───〔 ✅ 𝐃𝐑𝐈𝐕𝐄 𝐂𝐎𝐃𝐄 〕───╮\n" + "│\n" + `│ 📁 File : ${fileName}.js\n` + "│\n" + "│ ✦ File downloaded successfully.\n" + "│ ✦ Use load to activate.\n" + "│\n" + "╰──────────────────────╯", threadID, messageID ); } return api.sendMessage( "╭───〔 ❌ 𝐔𝐍𝐒𝐔𝐏𝐏𝐎𝐑𝐓𝐄𝐃 〕───╮\n" + "│\n" + "│ Supported links:\n" + "│ • Pastebin\n" + "│ • BuildTool\n" + "│ • TinyURL\n" + "│ • Google Drive\n" + "│\n" + "╰──────────────────────╯", threadID, messageID ); } catch (error) { console.error("SENT ERROR:", error); return api.sendMessage( "╭───〔 ❌ 𝐄𝐑𝐑𝐎𝐑 〕───╮\n" + "│\n" + `│ 📁 File : ${fileName}.js\n` + "│\n" + `│ ${error.message}\n` + "│\n" + "╰──────────────────╯", threadID, messageID ); } } /* ========================= UPLOAD EXISTING FILE ========================= */ if (!fs.existsSync(filePath)) { return api.sendMessage( "╭───〔 ❌ 𝐅𝐈𝐋𝐄 𝐍𝐎𝐓 𝐅𝐎𝐔𝐍𝐃 〕───╮\n" + "│\n" + `│ ${fileName}.js does not exist.\n` + "│\n" + "╰────────────────────────╯", threadID, messageID ); } try { const code = fs.readFileSync( filePath, "utf8" ); if (!code.trim()) { return api.sendMessage( `❌ | ${fileName}.js is empty.`, threadID, messageID ); } const PASTEBIN_API_KEY = "aeGtA7rxefvTnR3AKmYwG-jxMo598whT"; const params = new URLSearchParams(); params.append( "api_dev_key", PASTEBIN_API_KEY ); params.append( "api_option", "paste" ); params.append( "api_paste_code", code ); params.append( "api_paste_private", "1" ); params.append( "api_paste_expire_date", "N" ); params.append( "api_paste_name", fileName ); params.append( "api_paste_format", "javascript" ); const response = await axios.post( "https://pastebin.com/api/api_post.php", params.toString(), { headers: { "Content-Type": "application/x-www-form-urlencoded" }, timeout: 20000 } ); if ( !response.data || !String(response.data).startsWith( "https://pastebin.com/" ) ) { return api.sendMessage( "╭───〔 ❌ 𝐔𝐏𝐋𝐎𝐀𝐃 𝐅𝐀𝐈𝐋𝐄𝐃 〕───╮\n" + "│\n" + `│ ${response.data}\n` + "│\n" + "╰──────────────────────╯", threadID, messageID ); } const pasteURL = response.data; const pasteID = pasteURL.split("/").pop(); return api.sendMessage( "╭───〔 ✅ 𝐏𝐀𝐒𝐓𝐄𝐁𝐈𝐍 〕───╮\n" + "│\n" + `│ 📁 File : ${fileName}.js\n` + "│\n" + `│ 🔗 Link : ${pasteURL}\n` + "│\n" + `│ 🔗 Raw : https://pastebin.com/raw/${pasteID}\n` + "│\n" + "╰────────────────────╯", threadID, messageID ); } catch (error) { console.error("PASTEBIN ERROR:", error); return api.sendMessage( "╭───〔 ❌ 𝐔𝐏𝐋𝐎𝐀𝐃 𝐄𝐑𝐑𝐎𝐑 〕───╮\n" + "│\n" + `│ ${error.message}\n` + "│\n" + "╰──────────────────────╯", threadID, messageID ); } } };