// code from goatstore // api: https://store.agi.bd /** * 🕌 AUTO AZAN — JASHORE * 5 Waqt + Friday Jumma * 12-Hour Time + Auto Azan Video * * Created by Asif Evo */ const axios = require("axios"); const fs = require("fs-extra"); const path = require("path"); const CONFIG = { city: "Jashore", country: "Bangladesh", method: 1, timezone: "Asia/Dhaka", // 🎵 Azan Video videoURL: "https://files.catbox.moe/4i3dm4.mp4", // ⏱️ Check every 20 seconds checkInterval: 20 * 1000, // 🕌 Friday Jumma time // 12-hour format JUMMA_TIME: "12:30 PM" }; const PRAYERS = { Fajr: "ফজর", Dhuhr: "যোহর", Asr: "আসর", Maghrib: "মাগরিব", Isha: "এশা" }; /* ========================================================= 🕌 STYLISH BANGLA CAPTIONS ========================================================= */ const CAPTIONS = { Fajr: ` ╭━━━━━━━━━━━━━━━━━━╮ 🌙 𝐅𝐀𝐉𝐑 • ফজর 🕌 ╰━━━━━━━━━━━━━━━━━━╯ 🌙┊ভোরের নীরবতায় ভেসে এলো 🕌┊আল্লাহর ঘরের পবিত্র ডাক। 🤍┊ঘুমের চেয়ে নামাজ উত্তম। ⏰┊ফজরের আজানের সময় হয়েছে। 🤲┊আল্লাহ আমাদের সবাইকে নামাজ কায়েম করার তৌফিক দান করুন। ╰─┈┈┈┈┈┈┈┈┈┈─╯ ✦ 𝐂𝐫𝐞𝐚𝐭𝐞𝐝 𝐛𝐲 𝐀𝐬𝐢𝐟 𝐄𝐯𝐨 ✦ `, Dhuhr: ` ╭━━━━━━━━━━━━━━━━━━╮ ☀️ 𝐃𝐇𝐔𝐇𝐑 • যোহর 🕌 ╰━━━━━━━━━━━━━━━━━━╯ ☀️┊ব্যস্ত দিনের মাঝেও 🕌┊ভুলে যাবেন না রবের ডাক। ⏰┊যোহরের আজানের সময় হয়েছে। 🤍┊নামাজের জন্য প্রস্তুত হোন। 🤲┊আল্লাহ আমাদের নামাজ কবুল করুন। ╰─┈┈┈┈┈┈┈┈┈┈─╯ ✦ 𝐂𝐫𝐞𝐚𝐭𝐞𝐝 𝐛𝐲 𝐀𝐬𝐢𝐟 𝐄𝐯𝐨 ✦ `, Asr: ` ╭━━━━━━━━━━━━━━━━━━╮ 🌤️ 𝐀𝐒𝐑 • আসর 🕌 ╰━━━━━━━━━━━━━━━━━━╯ 🌤️┊দুনিয়ার ব্যস্ততা একটু থামুক, 🕌┊হৃদয় ফিরে যাক সিজদার পথে। ⏰┊আসরের আজানের সময় হয়েছে। 🤍┊নামাজের জন্য প্রস্তুত হোন। 🤲┊আল্লাহ আমাদের হেদায়েত দান করুন। ╰─┈┈┈┈┈┈┈┈┈┈─╯ ✦ 𝐂𝐫𝐞𝐚𝐭𝐞𝐝 𝐛𝐲 𝐀𝐬𝐢𝐟 𝐄𝐯𝐨 ✦ `, Maghrib: ` ╭━━━━━━━━━━━━━━━━━━╮ 🌅 𝐌𝐀𝐆𝐇𝐑𝐈𝐁 • মাগরিব 🕌 ╰━━━━━━━━━━━━━━━━━━╯ 🌅┊দিনের আলো মিলিয়ে যাচ্ছে, 🕌┊ভেসে এলো মাগরিবের পবিত্র আজান। ⏰┊মাগরিবের আজানের সময় হয়েছে। 🤍┊চলুন নামাজ আদায় করি। 🤲┊আল্লাহ আমাদের গুনাহ মাফ করুন। ╰─┈┈┈┈┈┈┈┈┈┈─╯ ✦ 𝐂𝐫𝐞𝐚𝐭𝐞𝐝 𝐛𝐲 𝐀𝐬𝐢𝐟 𝐄𝐯𝐨 ✦ `, Isha: ` ╭━━━━━━━━━━━━━━━━━━╮ 🌙 𝐈𝐒𝐇𝐀 • এশা 🕌 ╰━━━━━━━━━━━━━━━━━━╯ 🌙┊নীরব রাতের আকাশে 🕌┊ভেসে এলো রবের পবিত্র ডাক। ⏰┊এশার আজানের সময় হয়েছে। 🤍┊নামাজ দিয়ে দিনটি শেষ করুন। 🤲┊আল্লাহ আমাদের সকল আমল কবুল করুন। ╰─┈┈┈┈┈┈┈┈┈┈─╯ ✦ 𝐂𝐫𝐞𝐚𝐭𝐞𝐝 𝐛𝐲 𝐀𝐬𝐢𝐟 𝐄𝐯𝐨 ✦ `, Jumma: ` ╭━━━━━━━━━━━━━━━━━━╮ 🕋 𝐉𝐔𝐌𝐌𝐀𝐇 • জুম্মা 🕌 ╰━━━━━━━━━━━━━━━━━━╯ ✨┊জুম্মা মোবারক 🤍 🕌┊পবিত্র জুমার আজানের সময় হয়েছে। 📿┊বেশি বেশি দরুদ ও ইস্তিগফার পড়ুন। 🤍┊আজকের এই পবিত্র দিনে আল্লাহর রহমত ও মাগফিরাত কামনা করি। 🤲┊আল্লাহ আমাদের সকলের জুমার নামাজ কবুল করুন। আমিন। ╭──────────────────╮ 🕋 𝐉𝐔𝐌𝐌𝐀𝐇 𝐌𝐔𝐁𝐀𝐑𝐀𝐊 🤍 ╰──────────────────╯ ✦ 𝐂𝐫𝐞𝐚𝐭𝐞𝐝 𝐛𝐲 𝐀𝐬𝐢𝐟 𝐄𝐯𝐨 ✦ ` }; /* ========================================================= 📁 CACHE ========================================================= */ const cacheDir = path.join(__dirname, "cache"); const videoPath = path.join(cacheDir, "azan.mp4"); let prayerTimes = {}; let loadedDate = ""; let lastSent = {}; /* ========================================================= 📅 DATE / TIME ========================================================= */ function getDhakaDate() { return new Intl.DateTimeFormat("en-CA", { timeZone: CONFIG.timezone, year: "numeric", month: "2-digit", day: "2-digit" }).format(new Date()); } function getCurrentDhakaTime24() { return new Intl.DateTimeFormat("en-GB", { timeZone: CONFIG.timezone, hour: "2-digit", minute: "2-digit", hour12: false }).format(new Date()); } /* * API time → 12-hour format * Example: * 13:15 → 01:15 PM */ function to12Hour(time) { if (!time) return ""; let [hour, minute] = time.split(":").map(Number); const period = hour >= 12 ? "PM" : "AM"; hour = hour % 12; if (hour === 0) { hour = 12; } return `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")} ${period}`; } /* * Current time → 12-hour format */ function getCurrentDhakaTime12() { return new Intl.DateTimeFormat("en-US", { timeZone: CONFIG.timezone, hour: "2-digit", minute: "2-digit", hour12: true }).format(new Date()); } function convertDateForAPI(date) { const [year, month, day] = date.split("-"); return `${day}-${month}-${year}`; } function isFriday() { const day = new Intl.DateTimeFormat("en-US", { timeZone: CONFIG.timezone, weekday: "short" }).format(new Date()); return day === "Fri"; } /* ========================================================= 📥 DOWNLOAD AZAN VIDEO ========================================================= */ async function downloadVideo() { await fs.ensureDir(cacheDir); if (await fs.pathExists(videoPath)) { return videoPath; } console.log("[AUTO-AZAN] Downloading Azan video..."); const response = await axios({ method: "GET", url: CONFIG.videoURL, responseType: "stream", timeout: 60000, maxRedirects: 5 }); const writer = fs.createWriteStream(videoPath); response.data.pipe(writer); return new Promise((resolve, reject) => { writer.on("finish", () => { console.log("[AUTO-AZAN] Video downloaded."); resolve(videoPath); }); writer.on("error", reject); }); } /* ========================================================= 🕌 FETCH PRAYER TIMES ========================================================= */ async function fetchPrayerTimes() { try { const date = getDhakaDate(); const apiDate = convertDateForAPI(date); const url = `https://api.aladhan.com/v1/timingsByCity/${apiDate}` + `?city=${encodeURIComponent(CONFIG.city)}` + `&country=${encodeURIComponent(CONFIG.country)}` + `&method=${CONFIG.method}` + `&school=1` + `&timezonestring=${encodeURIComponent(CONFIG.timezone)}`; const response = await axios.get(url, { timeout: 15000 }); if ( !response.data || response.data.code !== 200 || !response.data.data || !response.data.data.timings ) { throw new Error("Invalid prayer API response"); } const timings = response.data.data.timings; prayerTimes = { Fajr: timings.Fajr.slice(0, 5), Dhuhr: timings.Dhuhr.slice(0, 5), Asr: timings.Asr.slice(0, 5), Maghrib: timings.Maghrib.slice(0, 5), Isha: timings.Isha.slice(0, 5) }; loadedDate = date; console.log( "[AUTO-AZAN] Prayer times loaded:", prayerTimes ); return true; } catch (error) { console.error( "[AUTO-AZAN] Prayer API error:", error.message ); return false; } } /* ========================================================= 📤 SEND AZAN ========================================================= */ async function sendAzan(api, threadID, type) { try { const video = await downloadVideo(); let caption; if (type === "Jumma") { caption = CAPTIONS.Jumma; } else { caption = CAPTIONS[type]; } await api.sendMessage( { body: caption, attachment: fs.createReadStream(video) }, threadID ); console.log( `[AUTO-AZAN] ${type} sent → ${threadID}` ); } catch (error) { console.error( `[AUTO-AZAN] ${type} send error:`, error.message ); } } /* ========================================================= 👥 GET ALL GROUPS ========================================================= */ async function getThreads(threadsData) { try { const threads = await threadsData.getAll(); if (!Array.isArray(threads)) { return []; } return threads; } catch (error) { console.error( "[AUTO-AZAN] Thread error:", error.message ); return []; } } /* ========================================================= ⏰ CHECK PRAYER TIMES ========================================================= */ async function checkPrayerTimes(api, threadsData) { try { const today = getDhakaDate(); // New day → reload prayer times if (loadedDate !== today) { await fetchPrayerTimes(); lastSent = {}; } if (!Object.keys(prayerTimes).length) { return; } /* * API gives 24-hour time. * We convert both sides to 12-hour * before comparing. */ const currentTime = getCurrentDhakaTime12(); const threads = await getThreads(threadsData); for (const thread of threads) { const threadID = thread.threadID || thread.ID || thread.id; if (!threadID) { continue; } /* ========================================== 🕌 5 WAQT ========================================== */ for (const prayer of Object.keys(PRAYERS)) { /* * শুক্রবারে যোহরের automatic message * বন্ধ থাকবে। * * তার জায়গায় Jumma যাবে। */ if (prayer === "Dhuhr" && isFriday()) { continue; } const apiTime = prayerTimes[prayer]; if (!apiTime) { continue; } const prayerTime12 = to12Hour(apiTime); const uniqueKey = `${today}_${threadID}_${prayer}_${prayerTime12}`; if (lastSent[uniqueKey]) { continue; } if (currentTime === prayerTime12) { lastSent[uniqueKey] = true; await sendAzan( api, threadID, prayer ); } } /* ========================================== 🕋 FRIDAY JUMMA — 12:30 PM ========================================== */ if (isFriday()) { const jummaKey = `${today}_${threadID}_JUMMA_${CONFIG.JUMMA_TIME}`; if ( !lastSent[jummaKey] && currentTime === CONFIG.JUMMA_TIME ) { lastSent[jummaKey] = true; await sendAzan( api, threadID, "Jumma" ); } } } } catch (error) { console.error( "[AUTO-AZAN] Checker error:", error.message ); } } /* ========================================================= 🚀 EVENT MODULE ========================================================= */ module.exports = { config: { name: "autoazan", version: "2.0.0", author: "Asif Evo", category: "events", description: "Automatic 5 Waqt Azan + Friday Jumma for Jashore." }, onStart: async function ({ api, threadsData }) { console.log( "━━━━━━━━━━━━━━━━━━━━━━━━━━━━" ); console.log( "🕌 AUTO AZAN SYSTEM STARTED" ); console.log( "📍 Location: Jashore, Bangladesh" ); console.log( "⏰ Timezone: Asia/Dhaka" ); console.log( "🕋 Jumma: 12:30 PM" ); console.log( "👤 Created by Asif Evo" ); console.log( "━━━━━━━━━━━━━━━━━━━━━━━━━━━━" ); // Load today's prayer times await fetchPrayerTimes(); // Download video once at startup try { await downloadVideo(); } catch (error) { console.error( "[AUTO-AZAN] Video download failed:", error.message ); } // Check every 20 seconds setInterval(() => { checkPrayerTimes( api, threadsData ); }, CONFIG.checkInterval); } };