Quellcode durchsuchen

Implement validation for Telegram bot configuration in the run method. Added error logging for missing TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID, and initialized the bot application with the configured token. Enhanced logging to indicate the version of python-telegram-bot being used.

Carles Sentis vor 1 Woche
Ursprung
Commit
42f1b0fe26
2 geänderte Dateien mit 20 neuen und 1 gelöschten Zeilen
  1. 19 0
      src/bot/core.py
  2. 1 1
      trading_bot.py

+ 19 - 0
src/bot/core.py

@@ -332,6 +332,25 @@ For support or issues, check the logs or contact the administrator.
     
     async def run(self):
         """Run the bot."""
+        if not Config.TELEGRAM_BOT_TOKEN:
+            logger.error("❌ TELEGRAM_BOT_TOKEN not configured")
+            return
+        
+        if not Config.TELEGRAM_CHAT_ID:
+            logger.error("❌ TELEGRAM_CHAT_ID not configured")
+            return
+        
+        logger.info(f"🔧 Using python-telegram-bot version: {telegram.__version__} (Running in v20.x style)")
+
+        # Create application
+        self.application = Application.builder().token(Config.TELEGRAM_BOT_TOKEN).build()
+        
+        # Connect notification manager to the bot application
+        self.notification_manager.set_bot_application(self.application)
+        
+        # Set up handlers
+        self.setup_handlers()
+
         logger.info("🚀 Initializing bot application (v20.x style)...")
         await self.application.initialize()
         

+ 1 - 1
trading_bot.py

@@ -14,7 +14,7 @@ from datetime import datetime
 from pathlib import Path
 
 # Bot version
-BOT_VERSION = "2.4.209"
+BOT_VERSION = "2.4.210"
 
 # Add src directory to Python path
 sys.path.insert(0, str(Path(__file__).parent / "src"))