import requests
from pxy_bots.models import TelegramBot

BASE_URL = "https://your-domain.com/bots/webhook/"

def set_telegram_webhooks():
    """Sets webhooks for all active bots."""
    bots = TelegramBot.objects.filter(is_active=True)
    for bot in bots:
        webhook_url = f"{BASE_URL}{bot.name}/"
        response = requests.post(
            f"https://api.telegram.org/bot{bot.token}/setWebhook",
            data={"url": webhook_url}
        )
        print(f"Webhook for {bot.name} ({bot.username}) set to: {webhook_url}")
        print("Response:", response.json())
