// code from goatstore // api: https://store.agi.bd const { getPrefix } = global.utils; const { commands } = global.GoatBot; const fs = require("fs-extra"); const path = require("path"); const axios = require("axios"); // ━━━━━━━ NEW VIDEO LINKS ━━━━━━━ const VIDEO_URLS = [ "https://files.catbox.moe/7nuaz4.mp4", "https://files.catbox.moe/4bnlry.mp4", "https://files.catbox.moe/61ri4q.mp4", "https://files.catbox.moe/ax9ed3.mp4", "https://files.catbox.moe/pt6yiy.mp4", "https://files.catbox.moe/4lg9yr.mp4" ]; const CACHE_DIR = path.join(__dirname, "cache"); const downloading = new Set(); // ━━━━━━━ FOOTER ━━━━━━━ const FOOTER = ` » 📊 𝐓𝐨𝐭𝐚𝐥 𝐂𝐨𝐦𝐦𝐚𝐧𝐝𝐬: [ {TOTAL} ] » 👑 𝐅𝐢𝐧𝐝 𝐈𝐧𝐟𝐨: [ {PREFIX}help ] » 🔗 & 𝐅𝐚𝐜𝐞𝐛𝐨𝐨𝐤: https://www.facebook.com/Mehedi.Choudhury31 » 🎵 & 𝐓𝐢𝐤𝐓𝐨𝐤: @black___diamon » ✈️ & 𝐓𝐞𝐥𝐞𝐠𝐫𝐚𝐦: @mehedi_chowdhury29 » 📞 & 𝐖𝐡𝐚𝐭𝐬𝐀𝐩𝐏: 01882700729 ━━━━━━━━━━━━━━━━━━`; function cachePath(url) { const id = url.split("/").pop().split("?")[0]; return path.join(CACHE_DIR, "rsvid_" + id); } function isCached(url) { const file = cachePath(url); return fs.existsSync(file) && fs.statSync(file).size > 0; } async function ensureVideo(url) { if (isCached(url) || downloading.has(url)) return null; downloading.add(url); try { await fs.ensureDir(CACHE_DIR); const response = await axios.get(url, { responseType: "arraybuffer", timeout: 60000, headers: { "User-Agent": "Mozilla/5.0" } }); const file = cachePath(url); await fs.writeFile(file, response.data); return file; } catch (error) { console.log("Video download failed:", error.message); return null; } finally { downloading.delete(url); } } async function warmUp() { for (const url of VIDEO_URLS) { if (!isCached(url)) await ensureVideo(url); } } warmUp(); function nextVideoFile() { if (!VIDEO_URLS.length) return null; if (typeof global.__rsVideoIndex !== "number") { global.__rsVideoIndex = 0; } for (let i = 0; i < VIDEO_URLS.length; i++) { const index = (global.__rsVideoIndex + i) % VIDEO_URLS.length; const url = VIDEO_URLS[index]; if (isCached(url)) { global.__rsVideoIndex = (index + 1) % VIDEO_URLS.length; return cachePath(url); } } return null; } async function sendReply(message, body, total, prefix) { const footer = FOOTER .replace("{TOTAL}", String(total)) .replace("{PREFIX}", prefix); const finalBody = body + "\n" + footer; const file = nextVideoFile(); if (file) { try { return await message.reply({ body: finalBody, attachment: fs.createReadStream(file) }); } catch (error) { console.log("Video attachment failed:", error.message); } } return message.reply(finalBody); } function normKey(category) { const key = String(category || "Uncategorized") .toLowerCase() .replace(/[^\p{L}\p{N}]+/gu, " ") .trim() || "uncategorized"; if ( /(^|\s)18(\s|$)/.test(key) || key.includes("nsfw") || /^adults?$/.test(key) || key.includes("18plus") ) return "18+"; return key; } function prettyName(key) { if (key === "18+") return "18+"; return key.split(" ").map(word => word.length <= 2 ? word.toUpperCase() : word[0].toUpperCase() + word.slice(1) ).join(" "); } const EMOJIS = { info: "📚", admin: "👑", owner: "👁️", fun: "🎮", game: "🎲", music: "🎵", video: "🎬", utility: "🔧", tools: "🛠️", image: "🖼️", education: "🎓", nsfw: "🔞", "18+": "🔞", ai: "🤖", search: "🔍", security: "🛡️", love: "💖", islamic: "🕌", weather: "🌤️", study: "📖", technology: "💻", default: "📁" }; function categoryEmoji(category) { const key = category.toLowerCase(); if (EMOJIS[key]) return EMOJIS[key]; for (const [name, emoji] of Object.entries(EMOJIS)) { if (name !== "default" && key.includes(name)) return emoji; } return EMOJIS.default; } module.exports = { config: { name: "helpcategory", aliases: ["hc", "helpcat", "category"], version: "3.0.0", author: "RS•RIFAT", role: 0, countDown: 5, description: { en: "Show categories and commands" }, category: "Info", guide: { en: "{pn}: show categories\n{pn} : show commands\n{pn} : select category" } }, onStart: async function ({ message, args, event, role }) { const prefix = getPrefix(event.threadID); const categories = {}; for (const [, command] of commands) { if (command.config.role > role) continue; const name = prettyName(normKey(command.config.category)); if (!categories[name]) categories[name] = []; if (!categories[name].includes(command.config.name)) { categories[name].push(command.config.name); } } const names = Object.keys(categories).sort((a, b) => a.localeCompare(b) ); const total = Object.values(categories) .reduce((sum, list) => sum + list.length, 0); const input = args.join(" ").trim(); if (!input) { let msg = "╭━━━〔 📂 𝐂𝐀𝐓𝐄𝐆𝐎𝐑𝐈𝐄𝐒 〕━━━╮\n"; names.forEach((name, index) => { msg += `┃ ${String(index + 1).padStart(2, "0")}. ${categoryEmoji(name)} ${name} [ ${categories[name].length} ]\n`; msg += "┃ ━━━━━━━━━━━━━━━━━\n"; }); msg += `╰━━〔 📊 𝐓𝐎𝐓𝐀𝐋: ${names.length} 𝐂𝐀𝐓𝐄𝐆𝐎𝐑𝐈𝐄𝐒 〕━━╯`; return sendReply(message, msg, total, prefix); } let found = null; if (/^\d+$/.test(input)) { found = names[Number(input) - 1] || null; } if (!found) { const query = normKey(input); found = names.find(name => normKey(name) === query) || names.find(name => normKey(name).includes(query)) || null; } if (!found) { return sendReply( message, `╭━━〔 ❌ 𝐍𝐎𝐓 𝐅𝐎𝐔𝐍𝐃 〕━━╮\n┃ Category: ${input}\n┃ Use: ${prefix}helpcategory\n╰━━━━━━━━━━━━━━━━━━╯`, total, prefix ); } const list = [...categories[found]].sort(); let msg = `╭━━〔 ${categoryEmoji(found)} 𝐂𝐀𝐓𝐄𝐆𝐎𝐑𝐘: ${found.toUpperCase()} 〕━━╮\n`; for (const command of list) { msg += `┃ 👑 ${command}\n`; msg += "┃ ━━━━━━━━━━━━━━━━━\n"; } msg += `╰━━〔 📊 𝐂𝐎𝐌𝐌𝐀𝐍𝐃𝐒: ${list.length} 〕━━╯`; return sendReply(message, msg, total, prefix); } };