import logging import httpx # Required to build the custom client from telegram import Update from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes from telegram.request import HTTPXRequest # --- CONFIGURATION --- BOT_TOKEN = "7848829657:AAH4xGpRPfrdNavu30XRRd3v1zvtAtWl7Ew" # <--- PASTE YOUR TOKEN HERE # Telegram API IP Address (Bypasses DNS blocking) TELEGRAM_IP_URL = "https://149.154.167.220/bot" # --- LOGGING SETUP --- logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO ) # --- CUSTOM CLASS TO DISABLE SSL --- class InsecureRequest(HTTPXRequest): """ A custom request class that disables SSL verification. This is necessary because the SSL certificate for 'api.telegram.org' will not match the IP address '149.154.167.220'. """ def _build_client(self): # We override the client builder to force verify=False return httpx.AsyncClient(**self._client_kwargs, verify=False) async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): await context.bot.send_message(chat_id=update.effective_chat.id, text="Method 2 (IP Hardcode) is Working!") if __name__ == '__main__': # 1. Initialize our custom insecure request request = InsecureRequest(connection_pool_size=8) # 2. Build the application application = ( ApplicationBuilder() .token(BOT_TOKEN) .base_url(TELEGRAM_IP_URL) # Point to the IP address .request(request) # Use our custom insecure request .build() ) # 3. Add Handlers start_handler = CommandHandler('start', start) application.add_handler(start_handler) print(f"Bot started pointing to {TELEGRAM_IP_URL} with SSL disabled...") # 4. Run application.run_polling()