|
@@ -367,10 +367,8 @@ For support or issues, check the logs or contact the administrator.
|
|
await self.market_monitor.start()
|
|
await self.market_monitor.start()
|
|
|
|
|
|
logger.info("▶️ Starting PTB application's internal tasks (update processing, job queue).")
|
|
logger.info("▶️ Starting PTB application's internal tasks (update processing, job queue).")
|
|
- await self.application.start() # This is non-blocking and starts the Application's processing loop.
|
|
|
|
-
|
|
|
|
- logger.info(f"▶️ Starting polling (drop_pending_updates={Config.TELEGRAM_DROP_PENDING_UPDATES})...")
|
|
|
|
- await self.application.run_polling(drop_pending_updates=Config.TELEGRAM_DROP_PENDING_UPDATES)
|
|
|
|
|
|
+ await self.application.start()
|
|
|
|
+ await self.application.updater.start_polling(drop_pending_updates=Config.TELEGRAM_DROP_PENDING_UPDATES)
|
|
|
|
|
|
logger.info("✅ Bot is initialized and polling. Awaiting stop signal or Ctrl+C.")
|
|
logger.info("✅ Bot is initialized and polling. Awaiting stop signal or Ctrl+C.")
|
|
# No need for keep_running_future with run_polling
|
|
# No need for keep_running_future with run_polling
|
|
@@ -389,11 +387,18 @@ For support or issues, check the logs or contact the administrator.
|
|
logger.info("Market monitor stopped.")
|
|
logger.info("Market monitor stopped.")
|
|
|
|
|
|
if self.application:
|
|
if self.application:
|
|
- # Stop the application's own processing
|
|
|
|
- if self.application.running: # Check if application was started
|
|
|
|
|
|
+ # Stop the updater first
|
|
|
|
+ if self.application.updater and self.application.updater.running:
|
|
|
|
+ logger.info("Stopping PTB updater...")
|
|
|
|
+ await self.application.updater.stop()
|
|
|
|
+ logger.info("PTB updater stopped.")
|
|
|
|
+
|
|
|
|
+ # Then stop the application's own processing
|
|
|
|
+ if self.application.running:
|
|
logger.info("Stopping PTB application components (handlers, job queue)...")
|
|
logger.info("Stopping PTB application components (handlers, job queue)...")
|
|
- await self.application.stop()
|
|
|
|
|
|
+ await self.application.stop()
|
|
logger.info("PTB application components stopped.")
|
|
logger.info("PTB application components stopped.")
|
|
|
|
+
|
|
# Finally, shutdown the application
|
|
# Finally, shutdown the application
|
|
logger.info("Shutting down PTB application (bot, persistence, etc.)...")
|
|
logger.info("Shutting down PTB application (bot, persistence, etc.)...")
|
|
await self.application.shutdown()
|
|
await self.application.shutdown()
|