stark91611/GAMA_EXPERT_BOTPublic · Bot Template
AIThis Telegram bot offers multiple utility features including Instagram media downloading, random quote generation, AI-driven chat responses, and Pinterest image searching. It also features channel join verification, automated reaction handlers, and comprehensive administrative tools such as broadcasting and role management.
Utilityinstagramdownloaderaipinterestbroadcastadmin
15 commands0 envUpdated 24d agoCreated Sep 22, 2026
commands/_instagram.js
javascript · 90 lines
1/**#command2name: /instagram3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// Regex to validate the Instagram URL format13const instaRegex = /(?:https?:\/\/)?(?:www\.)?instagram\.com\/(p|reel|tv)\/([a-zA-Z0-9\-_]+)/;14 15// 1. Validate the input16if (!params || !instaRegex.test(params)) {17 return msg.reply(18 "<b>Invalid Format</b>\n\nPlease provide a valid Instagram Post or Reel link after the command.\n\n" +19 "<b>Example:</b>\n<code>/instagram https://www.instagram.com/reel/C...</code>",20 { parse_mode: "HTML" }21 );22}23 24let url = params;25let waitMsg = await msg.reply("<b>⏳ Downloading...</b>\nPlease wait a moment.", { parse_mode: "HTML" });26 27try {28 // 2. Call the API29 const apiUrl = `https://tele-social.vercel.app/down?url=${encodeURIComponent(url)}`;30 const res = await HTTP.get({ url: apiUrl, timeout: 25000 });31 32 // 3. Process the successful response33 if (res.ok && res.data && res.data.status === true) {34 const data = res.data.data;35 const mediaUrl = data.media.video || data.media.image;36 37 if (!mediaUrl) {38 throw new Error("Media URL not found in the API response.");39 }40 41 // 4. Create the professional caption with a clickable user link42 let userName = user.first_name;43 if (user.last_name) {44 userName += " " + user.last_name;45 }46 // This creates the HTML link: <a href="tg://user?id=USER_ID">User Name</a>47 const userProfileLink = `<a href="tg://user?id=${user.id}">${userName}</a>`;48 49 const caption = `✅ <b>Download Complete!</b>\n\n` +50 `👤 <b>Requested by:</b> ${userProfileLink}\n` +51 `🤖 <b>Downloaded via:</b> @${bot.name}`;52 53 // 5. Send the correct media type54 if (data.type === "video") {55 Api.sendVideo({56 chat_id: chat.id,57 video: mediaUrl,58 caption: caption,59 parse_mode: "HTML"60 });61 } else if (data.type === "image") {62 Api.sendPhoto({63 chat_id: chat.id,64 photo: mediaUrl,65 caption: caption,66 parse_mode: "HTML"67 });68 } else {69 throw new Error("Unsupported media type received.");70 }71 72 // 6. Clean up the chat73 Api.deleteMessage({74 chat_id: chat.id,75 message_id: waitMsg.result.message_id76 });77 78 } else {79 let apiError = (res.data && res.data.message) ? res.data.message : "Could not process the link.";80 throw new Error(apiError);81 }82} catch (err) {83 // 7. Handle any failures84 Api.editMessageText({85 chat_id: chat.id,86 message_id: waitMsg.result.message_id,87 text: `<b>❌ Download Failed</b>\n\n<b>Reason:</b> <i>${err.message}</i>\n\nThis might be a private post, an invalid link, or a server issue. Please try again.`,88 parse_mode: "HTML"89 });90 }