// code from goatstore // api: https://store.agi.bd const axios = require("axios"); const fs = require("fs-extra"); const path = require("path"); const baseApiUrl = async () => { const base = await axios.get("https://raw.githubusercontent.com/mahmudx7/HINATA/main/baseApiUrl.json"); return base.data.mahmud; }; module.exports = { config: { name: "ani", aliases: ["aniusr", "anisearch"], version: "1.0", author: "š’šˆš˜š€šŒ-š‡š€š’š€š", countDown: 5, role: 0, description: "Search random TikTok video by keyword", category: "Media", guide: "{pn} \nExample: {pn} naruto" }, langs: { en: { noInput: "āš ļø Give a keyword!\nExample: {pn} naruto", tooLarge: "āŒ Video is too large (25MB+). Try another!", success: "šŸŽ¬ Here is your video\nšŸ” Search: %1", error: "āŒ Error: %1" } }, onStart: async function ({ api, event, args, message, getLang }) { const keyword = args.join(" "); if (!keyword) return message.reply(getLang("noInput")); const cacheDir = path.join(__dirname, "cache"); if (!fs.existsSync(cacheDir)) fs.mkdirSync(cacheDir, { recursive: true }); const videoPath = path.join(cacheDir, `unisr_${Date.now()}.mp4`); let waitMsgID; try { // ā³ waiting message const waitMsg = await message.reply( "━━━━━━━━━━━━━━━━━\n" + "ā³ ą¦•ą¦æą¦›ą§ą¦•ą§ą¦·ą¦£ ą¦…ą¦Ŗą§‡ą¦•ą§ą¦·ą¦¾ করুন...\n" + "━━━━━━━━━━━━━━━━━" ); waitMsgID = waitMsg.messageID; const apiUrl = await baseApiUrl(); const res = await axios({ method: "GET", url: `${apiUrl}/api/tiksr`, params: { sr: keyword }, responseType: "stream" }); const writer = fs.createWriteStream(videoPath); res.data.pipe(writer); await new Promise((resolve, reject) => { writer.on("finish", resolve); writer.on("error", reject); }); const stat = fs.statSync(videoPath); if (stat.size > 26214400) { fs.unlinkSync(videoPath); if (waitMsgID) api.unsendMessage(waitMsgID); return message.reply(getLang("tooLarge")); } // šŸŽ¬ SEND VIDEO FIRST await message.reply({ body: [ "━━━━━━━━━━━━━━━━━", "šŸŽ¬ Here is your video", "━━━━━━━━━━━━━━━━━", `šŸ” Search: ${keyword}`, "━━━━━━━━━━━━━━━━━" ].join("\n"), attachment: fs.createReadStream(videoPath) }); // ā³ THEN UNSEND WAIT MESSAGE (SAFE DELAY) if (waitMsgID) { setTimeout(() => { api.unsendMessage(waitMsgID); }, 800); } fs.unlink(videoPath, () => {}); } catch (err) { console.error(err); if (waitMsgID) api.unsendMessage(waitMsgID); if (fs.existsSync(videoPath)) fs.unlinkSync(videoPath); return message.reply(getLang("error", err.message)); } } };