import asyncio import httpx from dotenv import load_dotenv import os load_dotenv() # Load from .env # Token provided by user TOKEN = "7734361434:AAGGKvlHN6BaND61F1Lr-0TQiBPsRWdmrRo" APP_URL = "https://microfunnel-production.up.railway.app" async def register_webhook(): token = TOKEN if not token: print("❌ Token not found in settings!") return # User's Railway domain from webhook.py logic usually # But here we hardcode the known production domain or ask user? # Based on verify_webhook_status call in logs: https://microfunnel-production.up.railway.app # Let's use that. webhook_url = f"{APP_URL}/api/v1/webhook/telegram/global" print(f"🔌 Registering webhook for token {token[:5]}... to {webhook_url}") async with httpx.AsyncClient() as client: # 1. Delete # await client.get(f"https://api.telegram.org/bot{token}/deleteWebhook") # 2. Set res = await client.post( f"https://api.telegram.org/bot{token}/setWebhook", json={ "url": webhook_url, "allowed_updates": ["message", "my_chat_member", "channel_post"] } ) print(f"📡 Response: {res.json()}") if __name__ == "__main__": asyncio.run(register_webhook())