ghost_bots/ghost_tg_info_botPublic · Bot Template

AIThis bot helps users find Telegram IDs for users, groups, channels, and bots. The /start command shows a keyboard that uses Telegram's chat and user share requests to capture a selected chat or user, and the wildcard handler replies with the corresponding ID. /me displays the current user's profile details, while /inline_query returns the user's Telegram info as an inline result. It also includes a /help command explaining usage and supports copying IDs via inline keyboard buttons.

Utilitytelegram-iduser-idchat-idinline-querychat-shareid-finder
ProfileTelegram
6 commands0 envUpdated 5d agoCreated Sep 2, 2026
Back to folder

commands/_.js

javascript · 129 lines

Raw
1/**#command2name: *3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12function makeKeyboard(id) {13 14  let linkBtns = [15    [{16      text: "Copy ID",17      copy_text: {18        text: id19      }20    }]21  ]22 23 24  //handling channel links25  if (id.toString().startsWith("-100")) {26    let spit_id = id.toString().replace("-100", "")27    //https://t.me/c/2440965237/1000000028    let btns = [{29      text: "Open Chat",30      url: "https://t.me/c/" + spit_id + "/10000000"31    }]32    linkBtns.push(btns)33  } else {34    // For users35    // for Android: tg://openmessage?user_id=7400xxxxxx36    // for iOS: https://t.me/@id7400xxxxxx37    let btns = [{38      text: "Open Chat",39      url: "https://t.me/c/" + spit_id + "/10000000"40    }41    ]42    linkBtns.push(btns)43  }44  return linkBtns45}46 47function send(text, id) {48  Api.sendMessage({49    text,50    parse_mode: "HTML",51    reply_markup: {52      inline_keyboard: makeKeyboard(id)53    }54  });55}56 57if (update.message) {58  if (update.message.chat_shared) {59    const {60      chat_id,61      title,62      username63    } = update.message.chat_shared;64    if (chat_id) {65      const chatName = title || username || "this chat";66      const message = `🪪 The ID of <b>${chatName}</b> is: <code>${chat_id}</code>`;67      send(message, chat_id);68    }69  }70 71  if (update.message.users_shared) {72    const {73      users74    } = update.message.users_shared;75    let message = "";76 77    users.forEach(user => {78      const {79        user_id,80        first_name,81        last_name82      } = user;83      if (user_id) {84        const fullName = [first_name, last_name].filter(Boolean).join(' ');85        const userName = fullName || `user ${user_id}`;86        message += `🪪 The ID of <b>${userName}</b> is: <code>${user_id}</code>\n`;87        // Send message for each user to have proper button88        const userMessage = `🪪 The ID of <b>${userName}</b> is: <code>${user_id}</code>`;89        send(userMessage, user_id);90      }91    });92 93    if (message && users.length === 0) {94      // Fallback if users array is empty but we have user_id in user_shared95      return;96    }97    return;98  }99 100  if (update.message.user_shared) {101    const {102      user_id103    } = update.message.user_shared;104    if (user_id) {105      const userName = `user ${user_id}`;106      const message = `🪪 The ID of <b>${userName}</b> is: <code>${user_id}</code>`;107      send(message, user_id);108    }109  }110 111  if (update.message.forward_from) {112    const fwd = update.message.forward_from;113    if (fwd && fwd.id) {114      const fullName = [fwd.first_name, fwd.last_name].filter(Boolean).join(' ');115      const userName = fullName || fwd.username || "forwarded user";116      const message = `🪪 The ID of <b>${userName}</b> is: <code>${fwd.id}</code>`;117      send(message, fwd.id);118    }119  }120 121  if (update.message.forward_from_chat) {122    const chat = update.message.forward_from_chat;123    if (chat && chat.id) {124      const chatName = chat.title || chat.username || "forwarded chat";125      const message = `🪪 The ID of <b>${chatName}</b> is: <code>${chat.id}</code>`;126      send(message, chat.id);127    }128  }129}