// code from goatstore // api: https://store.agi.bd const fs = require("fs-extra"); const path = require("path"); const axios = require("axios"); module.exports = { config: { name: "sigmaboy", version: "13.1.0", author: "M treksR ཐི༏ཋྀ JU treksW treksELꜛཐི༏ཋྀ࿐", countDown: 0, role: 0, description: { en: "Random Sigma Boy video", vi: "Video Sigma Boy ngẫu nhiên" }, category: "sigma", guide: { en: "{pn} | {pn} | {pn} unban ", vi: "{pn} | {pn} | {pn} unban " } }, onStart: async function ({ api, args, message, event, role }) { const videoList = [ "https://i.imgur.com/gX1UC6Z.mp4", "https://i.imgur.com/XOZHscf.mp4", "https://i.imgur.com/oSea5n7.mp4", "https://i.imgur.com/sdYiLgj.mp4", "https://i.imgur.com/ARtdo3y.mp4", "https://i.imgur.com/ehShfsH.mp4", "https://i.imgur.com/96od2AY.mp4", "https://i.imgur.com/yPsoM7y.mp4", "https://i.imgur.com/Z6yzxVr.mp4", "https://i.imgur.com/wpTyRAk.mp4", "https://i.imgur.com/vfnCCEJ.mp4", "https://i.imgur.com/mMls0Lw.mp4", "https://i.imgur.com/hcmsiAt.mp4", "https://i.imgur.com/ovOe6Ld.mp4", "https://i.imgur.com/u9a1wC5.mp4", "https://i.imgur.com/lovWQSe.mp4", "https://i.imgur.com/P4L6u20.mp4", "https://i.imgur.com/bEcPmra.mp4", "https://i.imgur.com/2sD8aOo.mp4", "https://i.imgur.com/P9Ih9qX.mp4", "https://i.imgur.com/wDccwCw.mp4", "https://i.imgur.com/wvO12h7.mp4", "https://i.imgur.com/2EPpIwc.mp4", "https://i.imgur.com/e7NGkxO.mp4", "https://i.imgur.com/X1x55j0.mp4", "https://i.imgur.com/rczUIjt.mp4", "https://i.imgur.com/i2JUOos.mp4", "https://i.imgur.com/ljCsOaB.mp4", "https://i.imgur.com/7afYjRL.mp4", "https://i.imgur.com/WqnDkow.mp4" ]; const CACHE_DIR = path.join(__dirname, "cache", "sigmaboy_cache"); const DATA_FILE = path.join(__dirname, "cache", "sigmaboy_data.json"); await fs.ensureDir(CACHE_DIR); // ===== Persistent Ban Storage ===== function loadBanned() { try { const data = JSON.parse(fs.readFileSync(DATA_FILE, "utf8")); return data.banned || {}; } catch (e) { return {}; } } function saveBanned(banned) { try { fs.writeFileSync(DATA_FILE, JSON.stringify({ banned }, null, 2)); } catch (e) { console.log("Ban save error:", e); } } // ===== Global Trackers ===== if (!global.sigmaboy) { global.sigmaboy = { banned: loadBanned(), spamTracker: {}, cooldown: {}, last: {} }; } // ===== Bold Font ===== function toBoldFont(text) { const normal = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; const bold = Array.from("𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗"); return Array.from(text).map(ch => { const i = normal.indexOf(ch); return i > -1 ? bold[i] : ch; }).join(""); } // ===== Admin Check ===== function isAdmin() { return role >= 2; } // ===== No-Repeat Random Picker ===== function pickIndex(threadID) { if (videoList.length <= 1) return 0; const last = global.sigmaboy.last[threadID]; let idx; do { idx = Math.floor(Math.random() * videoList.length); } while (idx === last); global.sigmaboy.last[threadID] = idx; return idx; } // ===== Reliable Download (arraybuffer) ===== async function downloadVideo(url, dest) { const response = await axios.get(url, { responseType: "arraybuffer", timeout: 60000, headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" }, maxRedirects: 5 }); if (response.status !== 200) { throw new Error("HTTP " + response.status); } const buffer = Buffer.from(response.data); if (buffer.length < 1000) { throw new Error("File too small / invalid"); } await fs.writeFile(dest, buffer); } // ===== Get Cached Video ===== async function getVideoFile(index) { const url = videoList[index]; const fileName = path.basename(url); const file = path.join(CACHE_DIR, fileName); if (await fs.pathExists(file)) { const stat = await fs.stat(file); if (stat.size > 1000) return file; } await downloadVideo(url, file); return file; } // ===== Ban / Spam / Cooldown Check ===== function checkUser(senderID) { if (isAdmin()) return true; const now = Date.now(); if (global.sigmaboy.banned[senderID]) { message.reply(toBoldFont("🚫 You are BANNED! You cannot use this command.")); return false; } if (!global.sigmaboy.spamTracker[senderID]) { global.sigmaboy.spamTracker[senderID] = []; } global.sigmaboy.spamTracker[senderID] = global.sigmaboy.spamTracker[senderID] .filter(t => now - t < 60000); global.sigmaboy.spamTracker[senderID].push(now); if (global.sigmaboy.spamTracker[senderID].length > 5) { global.sigmaboy.banned[senderID] = true; saveBanned(global.sigmaboy.banned); message.reply(toBoldFont("🚫 SPAM DETECTED! You sent 5+ commands in 1 minute.\nYou have been BANNED.")); return false; } const lastUsed = global.sigmaboy.cooldown[senderID] || 0; const remaining = 15 - Math.floor((now - lastUsed) / 1000); if (remaining > 0) { message.reply(toBoldFont(`⏳ Please wait ${remaining}s before using this command again!`)); return false; } global.sigmaboy.cooldown[senderID] = now; return true; } // ===== Send Video ===== async function sendVideo(index) { try { const file = await getVideoFile(index); const bodyText = toBoldFont("Sigma Boy Video"); await message.reply({ body: bodyText, attachment: fs.createReadStream(file) }); } catch (e) { console.error("SigmaBoy Video Error:", e.message || e); message.reply(toBoldFont("❌ Failed to download video. Try again!\nError: " + (e.message || "Unknown"))); } } // ===== Main Logic ===== const { threadID, senderID } = event; // Unban if (args[0] && args[0].toLowerCase() === "unban") { if (!isAdmin()) { return message.reply(toBoldFont("❌ Only admin can use unban.")); } const target = args[1]; if (!target) { return message.reply(toBoldFont("⚠️ Usage: sigmaboy unban ")); } if (!global.sigmaboy.banned[target]) { return message.reply(toBoldFont("ℹ️ This user is not banned.")); } delete global.sigmaboy.banned[target]; delete global.sigmaboy.spamTracker[target]; delete global.sigmaboy.cooldown[target]; saveBanned(global.sigmaboy.banned); return message.reply(toBoldFont(`✅ Unbanned ${target}`)); } if (videoList.length === 0) { return message.reply(toBoldFont("⚠️ No videos added yet!")); } let index = null; if (args[0]) { const n = parseInt(args[0], 10); if (isNaN(n) || n < 1 || n > videoList.length) { return message.reply(toBoldFont(`❌ Invalid number! Choose between 1 and ${videoList.length}`)); } index = n - 1; } if (!checkUser(senderID)) return; if (index === null) { index = pickIndex(threadID); } else { global.sigmaboy.last[threadID] = index; } await sendVideo(index); } };