// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs-extra"); const path = require("path"); module.exports = { config: { name: "gojol", version: "2.0.0", author: "MrTomXxX", role: 0, shortDescription: { en: "Random Islamic Gojol" }, longDescription: { en: "Send a random Islamic Gojol audio." }, category: "media", guide: { en: "{pn}" }, countDown: 5 }, onStart: async function ({ api, event, message }) { const gojolList = [ "https://drive.google.com/uc?id=1xjyq3BrlW3bGrp8y7eedQSuddCbdvLMN", "https://drive.google.com/uc?id=1ySwrEG6xVqPdY5BcBP8I3YFCUOX4jV9e", "https://drive.google.com/uc?id=1xnht0PdBt9DnLGzW7GmJUTsTIJnxxByo", "https://drive.google.com/uc?id=1yHB48N_wPJnU5uV18KMZOLNqo5NE7L4W", "https://drive.google.com/uc?id=1xpwuubDL_ebjKJhujb-Ee-FikUF92oF6", "https://drive.google.com/uc?id=1yK0A3lyIJoPRp6g3UjNrC31n0yLfc1Ht", "https://drive.google.com/uc?id=1xrwhHLhsdKVAn_9umLfUysCt0S2v5QWe", "https://drive.google.com/uc?id=1yKwewV-oYbn57lGnlACykSD-yt8fOsfT", "https://drive.google.com/uc?id=1xulSi_qyJA47sF9rC9BUIPyBqh47t9Ls", "https://drive.google.com/uc?id=1y-PIYYziv-m8QRwmMBWCTl2wzuH8NpYJ", "https://drive.google.com/uc?id=1y0wV96m-notKVHnuNdF8xVCWiockSiME", "https://drive.google.com/uc?id=1xxMQnp-9-4BoLrGpReps93JQv4k8WUOP" ]; const randomURL = gojolList[Math.floor(Math.random() * gojolList.length)]; const cacheDir = path.join(__dirname, "cache"); const filePath = path.join( cacheDir, `gojol_${event.senderID}_${Date.now()}.mp3` ); try { // Create cache folder await fs.ensureDir(cacheDir); // Download audio as stream const response = await axios({ method: "GET", url: randomURL, responseType: "stream", timeout: 60000, maxRedirects: 10, headers: { "User-Agent": "Mozilla/5.0" } }); // Save audio const writer = fs.createWriteStream(filePath); response.data.pipe(writer); await new Promise((resolve, reject) => { writer.on("finish", resolve); writer.on("error", reject); response.data.on("error", reject); }); // Check downloaded file if (!(await fs.pathExists(filePath))) { throw new Error("Audio file was not created"); } const stats = await fs.stat(filePath); if (stats.size < 1000) { throw new Error("Downloaded file is too small"); } // Send audio await api.sendMessage( { body: "╭━━〔 🕌 𝐈𝐬𝐥𝐚𝐦𝐢𝐜 𝐆𝐨𝐣𝐨𝐥 〕━━╮\n" + "┃\n" + "┃ 🎵 --Islamic Gojol MrTomXxX 🕌--\n" + "┃ ❤️ 𝐋𝐢𝐬𝐭𝐞𝐧 𝐰𝐢𝐭𝐡 𝐡𝐞𝐚𝐫𝐭\n" + "┃\n" + "╰━━━━━━━━━━━━━━━━━━━━╯", attachment: fs.createReadStream(filePath) }, event.threadID ); // Delete cache after sending setTimeout(async () => { try { if (await fs.pathExists(filePath)) { await fs.remove(filePath); } } catch (error) { console.log( "[Gojol Cache Error]", error.message ); } }, 5000); } catch (error) { console.error( "[Gojol Command Error]", error.message ); // Remove failed file try { if (await fs.pathExists(filePath)) { await fs.remove(filePath); } } catch (e) {} return message.reply( "╭━━〔 ❌ 𝐄𝐫𝐫𝐨𝐫 〕━━╮\n" + "┃\n" + "┃ 🕌 Gojol পাঠানো যায়নি।\n" + "┃\n" + "┃ ⚠️ Google Drive link অথবা\n" + "┃ ফাইলটি unavailable হতে পারে।\n" + "┃\n" + "┃ 🔄 কিছুক্ষণ পর আবার চেষ্টা করুন।\n" + "┃\n" + "╰━━━━━━━━━━━━━━━━╯" ); } } };