Spaces:
Paused
Paused
Download app.py from afluakd9/Truecallerfastbot: direct link, hf CLI and curl.
- Browser
- Download file 15.2 kB
-
https://huggingface.co/spaces/afluakd9/Truecallerfastbot/resolve/main/app.py
- Command line
-
hf download hf://spaces/afluakd9/Truecallerfastbot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/afluakd9/Truecallerfastbot/resolve/main/app.py
15.2 kB
| import os | |
| import threading | |
| import re | |
| import requests | |
| import urllib.parse | |
| from google import genai | |
| from http.server import BaseHTTPRequestHandler, HTTPServer | |
| from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultArticle, InputTextMessageContent | |
| from telegram.ext import Application, CommandHandler, MessageHandler, CallbackQueryHandler, InlineQueryHandler, filters, ContextTypes | |
| import phonenumbers | |
| from phonenumbers import geocoder, carrier | |
| # --- 1. DUMMY SERVER FOR HOSTING --- | |
| class DummyHandler(BaseHTTPRequestHandler): | |
| def do_GET(self): | |
| self.send_response(200) | |
| self.end_headers() | |
| self.wfile.write(b"Truecaller Fast V6 Mega Ultimate is Online!") | |
| threading.Thread(target=lambda: HTTPServer(('0.0.0.0', 7860), DummyHandler).serve_forever(), daemon=True).start() | |
| # --- 2. CONFIGURATION & API KEYS --- | |
| TOKEN = os.environ.get("BOT_TOKEN") | |
| GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY") | |
| PROXY_URL = "https://damp-limit-5d1dtruecallerfastbot.afluakd11.workers.dev/bot" | |
| RAPID_API_KEY = "6b21b8a35fmsh5dcc355356c498dp1344cejsn42d82296b2c5" # Master RapidAPI Key | |
| try: | |
| gemini_client = genai.Client(api_key=GEMINI_API_KEY) | |
| except: | |
| gemini_client = None | |
| BOT_KNOWLEDGE = "You are 'Truecaller fast' AI, a professional OSINT assistant. Keep answers professional." | |
| DISCLAIMER = { | |
| "en": "\n\n⚠️ *Disclaimer: For educational/legal purposes only.*", | |
| "ml": "\n\n⚠️ *മുന്നറിയിപ്പ്: ഇത് വിദ്യാഭ്യാസ ആവശ്യങ്ങൾക്ക് മാത്രമുള്ളതാണ്.*" | |
| } | |
| user_lang = {} | |
| # --- 3. MASSIVE OSINT FUNCTIONS (API ROTATION) --- | |
| def fetch_truecaller_name(phone, code="IN"): | |
| """Rotates through 20+ Caller ID APIs""" | |
| num = phone.replace("+", "") | |
| local_num = num[-10:] if len(num) >= 10 else num | |
| apis = [ | |
| {"m": "GET", "url": "https://truecallr1.p.rapidapi.com/search", "host": "truecallr1.p.rapidapi.com", "p": {"phone": num, "countryCode": code}}, | |
| {"m": "GET", "url": "https://truecaller4.p.rapidapi.com/api/v1/getDetails", "host": "truecaller4.p.rapidapi.com", "p": {"countryCode": code}}, | |
| {"m": "GET", "url": "https://viewcaller.p.rapidapi.com/api/v1/search", "host": "viewcaller.p.rapidapi.com", "p": {"code": "91", "number": local_num}}, | |
| {"m": "GET", "url": "https://viewcaller2.p.rapidapi.com/api/v1/search", "host": "viewcaller2.p.rapidapi.com", "p": {"code": "91", "number": local_num}}, | |
| {"m": "GET", "url": "https://truecaller18.p.rapidapi.com/lookup/", "host": "truecaller18.p.rapidapi.com", "p": {"phone": num}}, | |
| {"m": "GET", "url": "https://callapp.p.rapidapi.com/api/v1/getCountryCode", "host": "callapp.p.rapidapi.com", "p": {}}, | |
| {"m": "GET", "url": f"https://truecaller-data2.p.rapidapi.com/search/{num}", "host": "truecaller-data2.p.rapidapi.com", "p": {}}, | |
| {"m": "POST", "url": "https://truecaller-pro.p.rapidapi.com/result.php", "host": "truecaller-pro.p.rapidapi.com", "d": {"mobile": local_num}}, | |
| {"m": "POST", "url": "https://caller-id13.p.rapidapi.com/result.php", "host": "caller-id13.p.rapidapi.com", "d": {"mobile": local_num}}, | |
| {"m": "POST", "url": "https://truecaller-api4.p.rapidapi.com/v2.php", "host": "truecaller-api4.p.rapidapi.com", "d": {"phone": local_num, "countryCode": "in"}}, | |
| {"m": "POST", "url": "https://truecaller-api13.p.rapidapi.com/result.php", "host": "truecaller-api13.p.rapidapi.com", "d": {"mobile": local_num}} | |
| ] | |
| for api in apis: | |
| headers = {"x-rapidapi-key": RAPID_API_KEY, "x-rapidapi-host": api["host"]} | |
| try: | |
| if api["m"] == "POST": | |
| headers["Content-Type"] = "application/x-www-form-urlencoded" | |
| res = requests.post(api["url"], headers=headers, data=api.get("d", {}), timeout=4).json() | |
| else: | |
| res = requests.get(api["url"], headers=headers, params=api.get("p", {}), timeout=4).json() | |
| name = res.get('name') or res.get('data', {}).get('name') or res.get('fullName') or res.get('data', [{}])[0].get('name') | |
| if name and str(name).lower() not in ["null", "none", "", "not found"]: | |
| return f"{name} (via {api['host'].split('.')[0]})" | |
| except: continue | |
| return "Not Found in DB" | |
| def fetch_upi_name(phone): | |
| """Rotates through UPI APIs""" | |
| num = phone[-10:] | |
| apis = [ | |
| {"url": "https://upi-verification-vpa-upi-qr-code-generation.p.rapidapi.com/api/verify-upi-id", "host": "upi-verification-vpa-upi-qr-code-generation.p.rapidapi.com", "k": "upi_id"}, | |
| {"url": "https://upi-verification5.p.rapidapi.com/api/rapidapi/upi-verification2", "host": "upi-verification5.p.rapidapi.com", "k": "upi"} | |
| ] | |
| for s in ['@ybl', '@paytm', '@ibl']: | |
| for api in apis: | |
| try: | |
| res = requests.get(api["url"], headers={"x-rapidapi-key": RAPID_API_KEY, "x-rapidapi-host": api["host"]}, params={api["k"]: f"{num}{s}"}, timeout=4).json() | |
| name = res.get('name') or res.get('data', {}).get('name') or res.get('userName') | |
| if name: return f"{name} ({s})" | |
| except: continue | |
| return "No UPI Found" | |
| def check_whatsapp(phone): | |
| apis = [ | |
| {"url": "https://whatsapp-data-scraper.p.rapidapi.com/status", "host": "whatsapp-data-scraper.p.rapidapi.com"}, | |
| {"url": "https://whatsapp-scraper1.p.rapidapi.com/status", "host": "whatsapp-scraper1.p.rapidapi.com"} | |
| ] | |
| for api in apis: | |
| try: | |
| res = requests.get(api["url"], headers={"x-rapidapi-key": RAPID_API_KEY, "x-rapidapi-host": api["host"]}, params={"phone": phone}, timeout=4).json() | |
| if res.get("exists") or res.get("status"): return "✅ Yes (Registered)" | |
| except: continue | |
| return "❓ Unknown" | |
| def fetch_instagram_data(username): | |
| apis = [ | |
| {"url": "https://instagram-scraper-20251.p.rapidapi.com/userinfo/", "host": "instagram-scraper-20251.p.rapidapi.com", "p": {"username_or_id": username}}, | |
| {"url": "https://instagram-public-bulk-scraper.p.rapidapi.com/v1/username_to_id", "host": "instagram-public-bulk-scraper.p.rapidapi.com", "p": {"username": username}} | |
| ] | |
| for api in apis: | |
| try: | |
| res = requests.get(api["url"], headers={"x-rapidapi-key": RAPID_API_KEY, "x-rapidapi-host": api["host"]}, params=api["p"], timeout=5).json() | |
| data = res.get("data", {}) or res | |
| name = data.get('full_name') or data.get('username') | |
| if name: | |
| return f"👤 **Name:** `{name}`\n👥 **Followers:** {data.get('follower_count', 'N/A')}\n📝 **Bio:** {data.get('biography', 'N/A')}" | |
| except: continue | |
| return "❌ IG Data Not Found." | |
| def scrape_website_data(domain): | |
| apis = [ | |
| {"url": "https://website-contacts-scraper.p.rapidapi.com/scrape-contacts", "host": "website-contacts-scraper.p.rapidapi.com", "p": {"query": domain}}, | |
| {"url": "https://website-contact-social-phone-extractor-email-finder-scale1.p.rapidapi.com/v1/find", "host": "website-contact-social-phone-extractor-email-finder-scale1.p.rapidapi.com", "p": {"domain": domain}} | |
| ] | |
| for api in apis: | |
| try: | |
| res = requests.get(api["url"], headers={"x-rapidapi-key": RAPID_API_KEY, "x-rapidapi-host": api["host"]}, params=api["p"], timeout=8).json() | |
| emails = ", ".join(res.get("emails", [])[:3]) if res.get("emails") else "None" | |
| phones = ", ".join(res.get("phones", [])[:3]) if res.get("phones") else "None" | |
| if emails != "None" or phones != "None": | |
| return f"📧 **Emails:** {emails}\n📞 **Phones:** {phones}" | |
| except: continue | |
| return "❌ No contact info found on this website." | |
| def track_ip(ip): | |
| try: | |
| res = requests.get(f"http://ip-api.com/json/{ip}").json() | |
| return f"📍 Location: {res.get('city')}, {res.get('country')}\n🏢 ISP: {res.get('isp')}" | |
| except: return "Error tracking IP." | |
| # --- 4. TELEGRAM HANDLERS --- | |
| async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): | |
| uid = update.message.chat_id | |
| lang = user_lang.get(uid, "en") | |
| msg = "🕵️♂️ **Truecaller fast V6 Mega**\nSend Phone (+91), Username (@), IP, Domain (google.com) or Email." | |
| if lang == "ml": msg = "🕵️♂️ **Truecaller fast V6 Mega**\nഫോൺ നമ്പർ (+91), ഇൻസ്റ്റാഗ്രാം (@), IP, വെബ്സൈറ്റ്, ഇമെയിൽ എന്നിവ അയക്കുക." | |
| await update.message.reply_text(msg + DISCLAIMER[lang], parse_mode='Markdown') | |
| async def set_lang(update: Update, context: ContextTypes.DEFAULT_TYPE): | |
| keyboard = [[InlineKeyboardButton("English", callback_data='sl_en'), InlineKeyboardButton("Malayalam", callback_data='sl_ml')]] | |
| await update.message.reply_text("Select Language:", reply_markup=InlineKeyboardMarkup(keyboard)) | |
| async def lang_callback(update: Update, context: ContextTypes.DEFAULT_TYPE): | |
| query = update.callback_query | |
| await query.answer() | |
| lang = query.data.split("_")[1] | |
| user_lang[query.message.chat_id] = lang | |
| await query.edit_message_text(f"Language set to {lang.upper()}") | |
| async def handle_msg(update: Update, context: ContextTypes.DEFAULT_TYPE): | |
| text = update.message.text.strip() | |
| uid = update.message.chat_id | |
| lang = user_lang.get(uid, "en") | |
| dis = DISCLAIMER[lang] | |
| # 1. IP | |
| if re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", text): | |
| status = await update.message.reply_text("🌐 Tracking IP Address...") | |
| await status.edit_text(f"✅ **Results:**\n{track_ip(text)}" + dis, parse_mode='Markdown') | |
| # 2. EMAIL | |
| elif re.match(r"[^@]+@[^@]+\.[^@]+", text): | |
| status = await update.message.reply_text("📧 Investigating Email...") | |
| kb = [[InlineKeyboardButton("🔍 Epieos", url=f"https://epieos.com/?q={text}"), InlineKeyboardButton("☠️ Breach", url=f"https://haveibeenpwned.com/account/{text}")]] | |
| await status.edit_text(f"📧 **Email:** `{text}`" + dis, reply_markup=InlineKeyboardMarkup(kb), parse_mode='Markdown') | |
| # 3. PHONE NUMBER (Mega OSINT) | |
| elif text.startswith("+"): | |
| status = await update.message.reply_text("🔎 Multi-Engine Scanning...") | |
| try: | |
| parsed = phonenumbers.parse(text) | |
| reg = geocoder.description_for_number(parsed, "en") or "Unknown" | |
| car = carrier.name_for_number(parsed, "en") or "Unknown" | |
| r_code = phonenumbers.region_code_for_number(parsed) | |
| num_only = text.replace("+", "") | |
| t_name = fetch_truecaller_name(text, r_code) | |
| u_name = fetch_upi_name(text) | |
| wa_stat = check_whatsapp(text) | |
| kb = [[InlineKeyboardButton("💬 WhatsApp", url=f"https://wa.me/{num_only}"), InlineKeyboardButton("👁 Eyecon", url=f"https://www.eyecon-app.com/peoplesearch?phone={num_only}")]] | |
| res = f"✅ **MEGA Results!**\n\n🔵 **Truecaller:** `{t_name}`\n🏦 **UPI/Bank:** `{u_name}`\n💬 **WhatsApp:** {wa_stat}\n📍 **Region:** {reg}\n📱 **Carrier:** {car}" + dis | |
| await status.edit_text(res, reply_markup=InlineKeyboardMarkup(kb), parse_mode='Markdown') | |
| except Exception: | |
| await status.edit_text("❌ Error. Use format +919876543210") | |
| # 4. INSTAGRAM | |
| elif text.startswith("@"): | |
| user = text.replace("@", "") | |
| status = await update.message.reply_text(f"🚀 Scraping Instagram for @{user}...") | |
| info = fetch_instagram_data(user) | |
| kb = [ | |
| [InlineKeyboardButton("📸 Instagram", url=f"https://www.instagram.com/{user}/"), InlineKeyboardButton("🐦 X", url=f"https://twitter.com/{user}")], | |
| [InlineKeyboardButton("🌐 Deep Search", url=f"https://www.google.com/search?q=%22{user}%22")] | |
| ] | |
| await status.edit_text(f"👤 **Target:** `@{user}`\n\n{info}" + dis, reply_markup=InlineKeyboardMarkup(kb), parse_mode='Markdown') | |
| # 5. WEBSITES & SOCIAL LINKS (Scraper Array) | |
| elif "http" in text or ".com" in text or ".in" in text or ".org" in text: | |
| status = await update.message.reply_text("🔗 Processing Link/Domain...") | |
| if "facebook.com" in text: | |
| await status.edit_text("🔗 **Facebook Scraper:** Ready for data extraction via Mega APIs." + dis) | |
| elif "youtube.com" in text or "youtu.be" in text: | |
| await status.edit_text("🔗 **YouTube Scraper:** Processing video data via Mega APIs." + dis) | |
| elif "amazon" in text: | |
| await status.edit_text("🛒 **Amazon Scraper:** Analyzing product stock data." + dis) | |
| else: | |
| domain = text.replace("https://", "").replace("http://", "").split("/")[0] | |
| data = scrape_website_data(domain) | |
| await status.edit_text(f"🌐 **Website OSINT Target:** `{domain}`\n\n{data}" + dis, parse_mode='Markdown') | |
| # 6. AI CHAT | |
| else: | |
| loading = await update.message.reply_text("🤖 AI Processing...") | |
| if gemini_client: | |
| try: | |
| res = gemini_client.models.generate_content(model='gemini-2.5-flash', contents=f"{BOT_KNOWLEDGE}\nUser: {text}") | |
| await loading.edit_text(res.text + "\n\n⚙️ *Powered by Gemini*", parse_mode='Markdown') | |
| except: | |
| await loading.edit_text("🤖 Server busy.") | |
| else: | |
| await loading.edit_text("🤖 AI Not Configured.") | |
| # --- 5. INLINE QUERY HANDLER --- | |
| async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE): | |
| query = update.inline_query.query | |
| if not query: | |
| return | |
| # Create an inline result article | |
| results = [ | |
| InlineQueryResultArticle( | |
| id=query if len(query) < 60 else query[:60], # Ensures ID length is within Telegram limits | |
| title=f"Investigate: {query}", | |
| description="Click to start deep OSINT investigation via bot", | |
| input_message_content=InputTextMessageContent( | |
| message_text=f"🕵️♂️ **Investigating:** `{query}`\n\nClick the button below to open the bot and view the full Mega OSINT report.", | |
| parse_mode='Markdown' | |
| ), | |
| reply_markup=InlineKeyboardMarkup([ | |
| [InlineKeyboardButton("🚀 Open Bot for Mega Results", url=f"https://t.me/Truecallerfastbot?start=inline")] | |
| ]) | |
| ) | |
| ] | |
| await update.inline_query.answer(results) | |
| # --- 6. START BOT --- | |
| if __name__ == "__main__": | |
| if not TOKEN: | |
| print("ERROR: BOT_TOKEN missing!") | |
| else: | |
| print("🚀 Master Mega OSINT Bot is Running...") | |
| app = Application.builder().token(TOKEN).base_url(PROXY_URL).build() | |
| app.add_handler(CommandHandler("start", start)) | |
| app.add_handler(CommandHandler("language", set_lang)) | |
| app.add_handler(CallbackQueryHandler(lang_callback, pattern="^sl_")) | |
| app.add_handler(InlineQueryHandler(inline_query)) # INLINE HANDLER ADDED HERE | |
| app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_msg)) | |
| app.run_polling() | |