"""Pre-check for Milestone 6: Verify bot token works before running."""
import asyncio, os, sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

async def test():
    from telegram import Bot
    from backend.config import TELEGRAM_BOT_TOKEN

    assert TELEGRAM_BOT_TOKEN and len(TELEGRAM_BOT_TOKEN) > 10, "TELEGRAM_BOT_TOKEN not set!"

    bot = Bot(token=TELEGRAM_BOT_TOKEN)
    me = await bot.get_me()
    print(f"  ✅ Bot connected: @{me.username} ({me.first_name})")
    print(f"\n  IMPORTANT: Before testing in a group:")
    print(f"  1. Open Telegram → Search @BotFather")
    print(f"  2. Send: /setprivacy")
    print(f"  3. Select @{me.username}")
    print(f"  4. Choose: Disable")
    print(f"  5. Create a test group, add @{me.username} to it")
    print(f"\n  Then run: python run_bot.py")
    print(f"  Send messages in the group, then try: /ask [question]")

asyncio.run(test())
