#!/usr/bin/env python3
"""
Script per avviare il bot Telegram IRIS
"""
import logging
import sys
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root))
from src.telegram_bot.bot import create_bot_application
from src.config.settings import settings
# Setup logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO
)
logger = logging.getLogger(__name__)
def main():
"""Main function to run the bot"""
try:
logger.info("π Starting IRIS Telegram Bot...")
# Check configuration
if not settings.TELEGRAM_BOT_TOKEN:
logger.error("β TELEGRAM_BOT_TOKEN not configured!")
logger.info("Please set TELEGRAM_BOT_TOKEN in your .env file")
return
# Create bot application
application = create_bot_application()
logger.info("β
Bot application created")
# Start the bot (this handles the async setup internally)
logger.info("π€ IRIS Bot is starting...")
logger.info(f"Bot token configured: {settings.TELEGRAM_BOT_TOKEN[:10]}...")
# Use the synchronous run_polling method
application.run_polling(
allowed_updates=["message", "callback_query"],
drop_pending_updates=True
)
except KeyboardInterrupt:
logger.info("π Bot stopped by user")
except Exception as e:
logger.error(f"β Error starting bot: {e}")
raise
if __name__ == "__main__":
main()