| import os |
| import random |
| from pyrogram import Client |
| from pyrogram import enums |
| from bot.state import state, AccountState |
| from utils.logger import log |
| from bot.proxy_manager import proxy_mgr |
|
|
| |
| bot: Client = Client( |
| "admin_bot", |
| api_id=int(os.environ.get("API_ID", 0)), |
| api_hash=os.environ.get("API_HASH", ""), |
| bot_token=os.environ.get("BOT_TOKEN", "") |
| ) |
|
|
| async def init_clients(accounts_list): |
| """ |
| Initializes the fleet of MTProto Snipe Accounts with an absolute N+11 proxy routing matrix. |
| Account 0 and Account 11 run barebone on Local Space IP. |
| """ |
| await proxy_mgr.fetch_webshare() |
| await proxy_mgr.test_all_proxies() |
| healthy_proxies = proxy_mgr.get_best_proxies(len(proxy_mgr.proxies)) |
| proxy_mgr.is_enabled = len(healthy_proxies) > 0 |
| |
| ios_versions = ["17.4.1", "17.4", "17.3.1", "17.3", "17.2.1"] |
| state["account_pool"].clear() |
| |
| for i, acc_data in enumerate(accounts_list): |
| try: |
| proxy_config = None |
| proxy_display = "[No Proxy - Local IP]" |
| |
| |
| if i == 0 or i == 11: |
| proxy_config = None |
| proxy_display = "[No Proxy - Local IP Control Row]" |
| elif proxy_mgr.is_enabled and healthy_proxies: |
| p_idx = (i - 1) if i < 11 else (i - 12) |
| assigned_proxy = healthy_proxies[p_idx % len(healthy_proxies)] |
| |
| proxy_config = { |
| "scheme": assigned_proxy["scheme"], |
| "hostname": assigned_proxy["hostname"], |
| "port": assigned_proxy["port"], |
| "username": assigned_proxy["username"], |
| "password": assigned_proxy["password"] |
| } |
| proxy_display = f"[Proxy Array #{p_idx}: {assigned_proxy['hostname']} ({assigned_proxy['ping']}ms)]" |
|
|
| assigned_ios = random.choice(ios_versions) |
| client = Client( |
| name=f"user_{i}", |
| session_string=acc_data["session_string"], |
| api_id=acc_data.get("api_id", int(os.environ.get("API_ID", 0))), |
| api_hash=acc_data.get("api_hash", os.environ.get("API_HASH", "")), |
| proxy=proxy_config, |
| in_memory=True, |
| no_updates=True, |
| device_model="iPhone 15 Pro Max", |
| system_version=assigned_ios, |
| app_version="10.12.0", |
| lang_code="en" |
| ) |
| await client.start() |
| |
| me = await client.get_me() |
| user_info = await client.get_users(me.id) |
| phone = me.phone_number or me.first_name or f"ID: {me.id}" |
| |
| u_status = str(user_info.status).split(".")[-1] if user_info.status else "UNKNOWN" |
| at_risk = (user_info.status == enums.UserStatus.LONG_AGO) |
| |
| acc_state = AccountState( |
| index=i, |
| client=client, |
| status="active", |
| checks_this_hour=0, |
| cooldown_until=None, |
| last_used=None, |
| phone=phone, |
| proxy=proxy_config, |
| user_status=u_status, |
| at_risk=at_risk |
| ) |
| state["account_pool"].append(acc_state) |
| |
| risk_str = "[AT RISK]" if at_risk else "" |
| log(f"✅ Account {i} ({phone}) initialized {proxy_display} {risk_str} [Spoofed as iOS {assigned_ios}]") |
| |
| except Exception as e: |
| log(f"❌ Failed to initialize account {i}: {e}") |