Download main.py from mdsinha/otp_bot: direct link, hf CLI and curl.
- Browser
- Download file 10 kB
-
https://huggingface.co/spaces/mdsinha/otp_bot/resolve/main/main.py
- Command line
-
hf download hf://spaces/mdsinha/otp_bot/main.py
-
curl -L -o main.py https://huggingface.co/spaces/mdsinha/otp_bot/resolve/main/main.py
10 kB
| import asyncio | |
| import aiohttp | |
| import re | |
| import hashlib | |
| import time | |
| from telegram import Bot, InlineKeyboardButton, InlineKeyboardMarkup, CopyTextButton | |
| from telegram.constants import ParseMode | |
| from telegram.request import HTTPXRequest | |
| # ================= CONFIG (ULTRA FAST REFRESH) ================= | |
| API_URL = "http://147.135.212.197/crapi/time/viewstats" | |
| API_TOKEN = "RlBYNEVBgH1nYFRZQY2GaWGYkGRXglBYa19qUnVSjFVCcmF6c2U=" | |
| BOT_TOKEN = "8755428245:AAFF1_FKujO-uliDPISU98ySQ4L8LjWzmwA" | |
| CHAT_ID = -1002769074368 | |
| CHECK_INTERVAL = 1.0 # প্রতি ১ সেকেন্ডে এপিআই রিফ্রেশ হবে | |
| DELETE_AFTER = 300 # ৫ মিনিট পর মেসেজ অটো ডিলিট | |
| # ======================================================== | |
| # VPS এর লিমিটেড রিসোর্সের জন্য অপ্টিমাইজড রিকোয়েস্ট | |
| t_request = HTTPXRequest(connection_pool_size=100, read_timeout=5) | |
| bot = Bot(token=BOT_TOKEN, request=t_request) | |
| sent_messages = set() # পাঠানো মেসেজ মনে রাখার জন্য | |
| messages_to_delete = [] | |
| # ২৪২টি দেশের লিস্ট (সম্পূর্ণ) | |
| COUNTRY_MAP = {"93": ("🇦🇫", "AF"), "355": ("🇦🇱", "AL"), "213": ("🇩🇿", "DZ"), "1684": ("🇦🇸", "AS"), "376": ("🇦🇩", "AD"), "244": ("🇦🇴", "AO"), "1264": ("🇦🇮", "AI"), "672": ("🇦🇶", "AQ"), "1268": ("🇦🇬", "AG"), "54": ("🇦🇷", "AR"), "374": ("🇦🇲", "AM"), "297": ("🇦🇼", "AW"), "61": ("🇦🇺", "AU"), "43": ("🇦🇹", "AT"), "994": ("🇦🇿", "AZ"), "1242": ("🇧🇸", "BS"), "973": ("🇧🇭", "BH"), "880": ("🇧🇩", "BD"), "1246": ("🇧🇧", "BB"), "375": ("🇧🇾", "BY"), "32": ("🇧🇪", "BE"), "501": ("🇧🇿", "BZ"), "229": ("🇧🇯", "BJ"), "1441": ("🇧🇲", "BM"), "975": ("🇧🇹", "BT"), "591": ("🇧🇴", "BO"), "387": ("🇧🇦", "BA"), "267": ("🇧🇼", "BW"), "55": ("🇧🇷", "BR"), "246": ("🇮🇴", "IO"), "1284": ("🇻🇬", "VG"), "673": ("🇧🇳", "BN"), "359": ("🇧🇬", "BG"), "226": ("🇧🇫", "BF"), "257": ("🇧🇮", "BI"), "855": ("🇰🇭", "KH"), "237": ("🇨🇲", "CM"), "1": ("🇺🇸", "US"), "238": ("🇨🇻", "CV"), "1345": ("🇰🇾", "KY"), "236": ("🇨🇫", "CF"), "235": ("🇹🇩", "TD"), "56": ("🇨🇱", "CL"), "86": ("🇨🇳", "CN"), "57": ("🇨🇴", "CO"), "269": ("🇰🇲", "KM"), "385": ("🇭🇷", "HR"), "53": ("🇨🇺", "CU"), "357": ("🇨🇾", "CY"), "420": ("🇨🇿", "CZ"), "45": ("🇩🇰", "DK"), "253": ("🇩🇯", "DJ"), "1767": ("🇩🇲", "DM"), "1809": ("🇩🇴", "DO"), "593": ("🇪🇨", "EC"), "20": ("🇪🇬", "EG"), "503": ("🇸🇻", "SV"), "240": ("🇬🇶", "GQ"), "291": ("🇪🇷", "ER"), "372": ("🇪🇪", "EE"), "251": ("🇪🇹", "ET"), "679": ("🇫🇯", "FJ"), "358": ("🇫🇮", "FI"), "33": ("🇫🇷", "FR"), "241": ("🇬🇦", "GA"), "220": ("🇬🇲", "GM"), "995": ("🇬🇪", "GE"), "49": ("🇩🇪", "DE"), "233": ("🇬🇭", "GH"), "350": ("🇬🇮", "GI"), "30": ("🇬🇷", "GR"), "299": ("🇬🇱", "GL"), "1473": ("🇬🇩", "GD"), "502": ("🇬🇹", "GT"), "224": ("🇬🇳", "GN"), "245": ("🇬🇼", "GW"), "592": ("🇬🇾", "GY"), "509": ("🇭🇹", "HT"), "504": ("🇭🇳", "HN"), "852": ("🇭🇰", "HK"), "36": ("🇭🇺", "HU"), "354": ("🇮🇸", "IS"), "91": ("🇮🇳", "IN"), "62": ("🇮🇩", "ID"), "98": ("🇮🇷", "IR"), "964": ("🇮🇶", "IQ"), "353": ("🇮🇪", "IE"), "972": ("🇮🇱", "IL"), "39": ("🇮🇹", "IT"), "225": ("🇨🇮", "CI"), "1876": ("🇯🇲", "JM"), "81": ("🇯🇵", "JP"), "962": ("🇯🇴", "JO"), "7": ("🇰🇿", "KZ"), "254": ("🇰🇪", "KE"), "965": ("🇰🇼", "KW"), "996": ("🇰🇬", "KG"), "856": ("🇱🇦", "LA"), "371": ("🇱🇻", "LV"), "961": ("🇱🇧", "LB"), "266": ("🇱🇸", "LS"), "231": ("🇱🇷", "LR"), "218": ("🇱🇾", "LY"), "370": ("🇱🇹", "LT"), "352": ("🇱🇺", "LU"), "853": ("🇲🇴", "MO"), "389": ("🇲🇰", "MK"), "261": ("🇲🇬", "MG"), "265": ("🇲🇼", "MW"), "60": ("🇲🇾", "MY"), "960": ("🇲🇻", "MV"), "223": ("🇲🇱", "ML"), "356": ("🇲🇹", "MT"), "222": ("🇲🇷", "MR"), "230": ("🇲🇺", "MU"), "52": ("🇲🇽", "MX"), "373": ("🇲🇩", "MD"), "976": ("🇲🇳", "MN"), "212": ("🇲🇦", "MA"), "258": ("🇲🇿", "MZ"), "95": ("🇲🇲", "MM"), "264": ("🇳🇦", "NA"), "977": ("🇳🇵", "NP"), "31": ("🇳🇱", "NL"), "64": ("🇳🇿", "NZ"), "505": ("🇳🇮", "NI"), "227": ("🇳🇪", "NE"), "234": ("🇳🇬", "NG"), "850": ("🇰🇵", "KP"), "47": ("🇳🇴", "NO"), "968": ("🇴🇲", "OM"), "92": ("🇵🇰", "PK"), "970": ("🇵🇸", "PS"), "507": ("🇵🇦", "PA"), "675": ("🇵🇬", "PG"), "595": ("🇵🇾", "PY"), "51": ("🇵🇪", "PE"), "63": ("🇵🇭", "PH"), "48": ("🇵🇱", "PL"), "351": ("🇵🇹", "PT"), "974": ("🇶🇦", "QA"), "40": ("🇷🇴", "RO"), "7": ("🇷🇺", "RU"), "250": ("🇷🇼", "RW"), "966": ("🇸🇦", "SA"), "221": ("🇸🇳", "SN"), "381": ("🇷🇸", "RS"), "248": ("🇸🇨", "SC"), "232": ("🇸🇱", "SL"), "65": ("🇸🇬", "SG"), "421": ("🇸🇰", "SK"), "386": ("🇸🇮", "SI"), "252": ("🇸🇴", "SO"), "27": ("🇿🇦", "ZA"), "82": ("🇰🇷", "KR"), "211": ("🇸🇸", "SS"), "34": ("🇪🇸", "ES"), "94": ("🇱🇰", "LK"), "249": ("🇸🇩", "SD"), "46": ("🇸🇪", "SE"), "41": ("🇨🇭", "CH"), "963": ("🇸🇾", "SY"), "886": ("🇹🇼", "TW"), "992": ("🇹🇯", "TJ"), "255": ("🇹🇿", "TZ"), "66": ("🇹🇭", "TH"), "228": ("🇹🇬", "TG"), "216": ("🇹🇳", "TN"), "90": ("🇹🇷", "TR"), "993": ("🇹🇲", "TM"), "256": ("🇺🇬", "UG"), "380": ("🇺🇦", "UA"), "971": ("🇦🇪", "AE"), "44": ("🇬🇧", "GB"), "598": ("🇺🇾", "UY"), "998": ("🇺🇿", "UZ"), "58": ("🇻🇪", "VE"), "84": ("🇻🇳", "VN"), "967": ("🇾🇪", "YE"), "260": ("🇿🇲", "ZM"), "263": ("🇿🇼", "ZW")} | |
| def get_service_tag(msg): | |
| m = msg.lower() | |
| if "whatsapp" in m: return "#WS" | |
| elif "facebook" in m: return "#FB" | |
| elif "telegram" in m: return "#TG" | |
| elif "google" in m: return "#GGL" | |
| return "#SRV" | |
| def get_lang(msg): | |
| m = msg.lower() | |
| if any(x in m for x in ["codigo", "cuenta", "registrada"]): return "Spanish" | |
| if "votre" in m: return "French" | |
| return "English" | |
| async def auto_delete_worker(): | |
| while True: | |
| now = time.time() | |
| for item in messages_to_delete[:]: | |
| if now >= item[3]: | |
| try: | |
| await item[0].delete_message(chat_id=item[1], message_id=item[2]) | |
| messages_to_delete.remove(item) | |
| except: pass | |
| await asyncio.sleep(15) | |
| async def process_entry(d): | |
| try: | |
| num_raw = str(d.get('num', '')) | |
| msg = d.get('message', '') | |
| if not num_raw or not msg: return | |
| # ইউনিক আইডি জেনারেট করে ডুপ্লিকেট রোধ | |
| uid = hashlib.md5(f"{num_raw}{msg}".encode()).hexdigest() | |
| if uid in sent_messages: return | |
| sent_messages.add(uid) | |
| # নাম্বার এবং কান্ট্রি ফ্ল্যাগ সেট করা | |
| num_clean = re.sub(r'\D', '', num_raw) | |
| flag, sn = ("🌍", "UN") | |
| for length in [5, 4, 3, 2, 1]: | |
| if num_clean[:length] in COUNTRY_MAP: | |
| flag, sn = COUNTRY_MAP[num_clean[:length]] | |
| break | |
| # ওটিপি এক্সট্রাকশন (আপনার উদাহরণের 861-979 সাপোর্টসহ) | |
| otp = "N/A" | |
| m = re.search(r"(\d{3}-\d{3})|(\d{4,8})", msg) | |
| if m: otp = m.group(0) | |
| masked = f"{num_clean[:5]}RTS{num_clean[-3:]}" if len(num_clean) >= 8 else num_clean | |
| display_text = f"{flag} #{sn} {get_service_tag(msg)} ✆ *{masked}* 🌐\n#{get_lang(msg)}" | |
| kb = InlineKeyboardMarkup([ | |
| [InlineKeyboardButton(f"📋 {otp}", copy_text=CopyTextButton(otp))], | |
| [InlineKeyboardButton("📱 Number Channel", url="https://t.me/Sinha_Method_Universe_Number"), | |
| InlineKeyboardButton("📂 Main Channel", url="https://t.me/RockStar_main_channel")] | |
| ]) | |
| # আসা মাত্রই সরাসরি টেলিগ্রামে ডেলিভারি | |
| sent = await bot.send_message(chat_id=CHAT_ID, text=display_text, parse_mode=ParseMode.MARKDOWN, reply_markup=kb) | |
| messages_to_delete.append((bot, CHAT_ID, sent.message_id, time.time() + DELETE_AFTER)) | |
| # মেমোরি জ্যাম রোধে ওল্ড ডাটা রিমুভ | |
| if len(sent_messages) > 1000: sent_messages.clear() | |
| except: pass | |
| async def main(): | |
| print("💎 ROCKSTAR ENGINE STARTED | REFRESH: 1s") | |
| asyncio.create_task(auto_delete_worker()) | |
| async with aiohttp.ClientSession() as session: | |
| while True: | |
| try: | |
| # এপিআই হোমপেজ রিফ্রেশ (প্রতি ১ সেকেন্ডে) | |
| async with session.get(API_URL, params={"token": API_TOKEN}, timeout=4) as resp: | |
| if resp.status == 200: | |
| res = await resp.json() | |
| entries = res.get('data', []) | |
| if entries: | |
| # এপিআই-র সবার উপরের ৩টি মেসেজ চেক করবে (লেটেস্টগুলো শুরুতে থাকে) | |
| for entry in entries[:3]: | |
| await process_entry(entry) | |
| await asyncio.sleep(CHECK_INTERVAL) | |
| except: | |
| await asyncio.sleep(1) | |
| if __name__ == "__main__": | |
| asyncio.run(main()) | |