// code from goatstore // api: https://store.agi.bd const axios = require("axios"); function cleanUsername(input = "") { return String(input) .trim() .replace(/^https?:\/\/(www\.)?tiktok\.com\/@?/i, "") .replace(/^@+/, "") .split(/[/?\s]/)[0]; } function fmt(value) { const n = Number(value); return Number.isFinite(n) ? n.toLocaleString("en-US") : "N/A"; } async function getProfile(username) { const headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/131.0.0.0 Safari/537.36", Referer: "https://www.tiktok.com/" }; try { const res = await axios.get( `https://www.tiktok.com/@${encodeURIComponent(username)}`, { headers, timeout: 15000, responseType: "text" } ); const html = res.data || ""; const patterns = [ /]*id="__UNIVERSAL_DATA_FOR_REHYDRATION__"[^>]*>([\s\S]*?)<\/script>/i, /]*id="SIGI_STATE"[^>]*>([\s\S]*?)<\/script>/i ]; let data; for (const pattern of patterns) { const match = html.match(pattern); if (!match) continue; try { data = JSON.parse(match[1]); break; } catch (_) {} } const info = data?.__DEFAULT_SCOPE__?.["webapp.user-detail"]?.userInfo; if (info?.user) { const u = info.user; const s = info.stats || {}; return { username: u.uniqueId || username, nickname: u.nickname || u.uniqueId, bio: u.signature || "", verified: Boolean(u.verified), followers: s.followerCount, following: s.followingCount, likes: s.heartCount, videos: s.videoCount }; } const users = data?.UserModule?.users; if (users) { const id = Object.keys(users)[0]; if (id) { const u = users[id]; const s = data.UserModule.stats?.[id] || {}; return { username: u.uniqueId || id, nickname: u.nickname || id, bio: u.signature || "", verified: Boolean(u.verified), followers: s.followerCount, following: s.followingCount, likes: s.heartCount, videos: s.videoCount }; } } } catch (err) { console.log("[tikinfo] TikTok error:", err.message); } try { const res = await axios.get( "https://www.tikwm.com/api/user/info", { params: { unique_id: username }, headers, timeout: 15000 } ); const root = res.data?.data; const u = root?.user || root?.userInfo || root; const s = root?.stats || root?.statsV2 || {}; if (u && (u.uniqueId || u.unique_id || u.username)) { return { username: u.uniqueId || u.unique_id || u.username || username, nickname: u.nickname || username, bio: u.signature || u.bio || "", verified: Boolean(u.verified), followers: s.followerCount ?? s.follower_count, following: s.followingCount ?? s.following_count, likes: s.heartCount ?? s.heart, videos: s.videoCount ?? s.video_count }; } } catch (err) { console.log("[tikinfo] TikWM error:", err.message); } return null; } async function sendPicture(message) { try { const response = await axios.get( "https://i.imgur.com/YSEgBLV.jpeg", { responseType: "arraybuffer", timeout: 20000, headers: { "User-Agent": "Mozilla/5.0" } } ); const imageBuffer = Buffer.from(response.data); if (!imageBuffer.length) { throw new Error("ছবির ফাইল খালি"); } await message.reply({ body: "🖼️ Profile Picture", attachment: imageBuffer }); } catch (err) { console.log("[tikinfo] Picture error:", err.message); await message.reply( "❌ ছবিটি পাঠানো যায়নি। এখানে দেখো:\nhttps://i.imgur.com/YSEgBLV.jpeg" ); } } module.exports = { config: { name: "tikinfo", version: "4.0.0", author: "Tech", countDown: 10, role: 0, shortDescription: "TikTok profile information", longDescription: "Shows TikTok profile information and a picture", category: "media", guide: "{pn} username" }, onStart: async function ({ args, message }) { const username = cleanUsername(args.join(" ")); if (!username) { return message.reply( "❌ Username দাও!\nউদাহরণ: tikinfo black___diamon" ); } await message.reply("⏳ TikTok profile খোঁজা হচ্ছে..."); let profile = null; try { profile = await getProfile(username); } catch (err) { console.log("[tikinfo] Profile error:", err.message); } if (profile) { const info = "╭━━〔 🎵 TIKTOK PROFILE 〕━━╮\n\n" + `👤 Name: ${profile.nickname || "N/A"}\n` + `🔗 Username: @${profile.username || username}\n` + `📝 Bio: ${profile.bio || "No bio"}\n` + `✅ Verified: ${profile.verified ? "Yes" : "No"}\n\n` + "📊 PROFILE STATS\n" + `👥 Followers: ${fmt(profile.followers)}\n` + `➡️ Following: ${fmt(profile.following)}\n` + `❤️ Likes: ${fmt(profile.likes)}\n` + `🎬 Videos: ${fmt(profile.videos)}\n\n` + "╰━━━━━━━━━━━━━━━━━━━━━━╯"; await message.reply(info); } else { await message.reply( "⚠️ TikTok profile information পাওয়া যায়নি।\n" + `🔗 https://www.tiktok.com/@${username}` ); } await sendPicture(message); } };