// code from goatstore // api: https://store.agi.bd const fs = require("fs-extra"); const path = require("path"); module.exports = { config: { name: "heppi2", version: "3.0", author: "SHAKIB", countDown: 5, role: 0, shortDescription: { en: "Random TikTok Hot Video" }, category: "media", guide: { en: "{pn}" } }, onStart: async function ({ api, event }) { const cacheDir = path.join(__dirname, "cache"); if (!fs.existsSync(cacheDir)) fs.mkdirSync(cacheDir, { recursive: true }); const filePath = path.join(cacheDir, `heppi2_${Date.now()}.mp4`); try { // Random TikTok viral video search - keyword trending const keywords = ["viral", "trending", "hot", "foryou", "fyp"]; const randomKeyword = keywords[Math.floor(Math.random() * keywords.length)]; // TikWM search API দিয়ে random video ID বের করা const searchRes = await axios.get(`https://www.tikwm.com/api/feed/search?keywords=${randomKeyword}&count=20`, { headers: { "User-Agent": "Mozilla/5.0" } }); const videos = searchRes.data?.data?.videos; if (!videos || videos.length === 0) throw new Error("TikTok video পাওয়া যায়নি, আবার Try করো"); const randomVideo = videos[Math.floor(Math.random() * videos.length)]; const videoUrl = randomVideo.play; const title = randomVideo.title || "Random TikTok Hot Video 🔥"; const videoData = await axios.get(videoUrl, { responseType: "arraybuffer", timeout: 120000, headers: { "User-Agent": "Mozilla/5.0" } }); fs.writeFileSync(filePath, Buffer.from(videoData.data)); await api.sendMessage({ body: title, attachment: fs.createReadStream(filePath) }, event.threadID, () => { if (fs.existsSync(filePath)) fs.unlinkSync(filePath); }, event.messageID); } catch (e) { console.log(e); return api.sendMessage(`❌ Failed: ${e.message} - আবার heppi2 লিখো`, event.threadID, event.messageID); } } };