From ae936ffddbf924e1a7705099a77160727ba554e5 Mon Sep 17 00:00:00 2001 From: Yuriy Yuriev Date: Wed, 20 May 2026 15:00:21 +0700 Subject: [PATCH] fix irc connect --- services/irc_service.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/services/irc_service.py b/services/irc_service.py index 9656a3f..1967a88 100644 --- a/services/irc_service.py +++ b/services/irc_service.py @@ -178,14 +178,27 @@ class TwitchIRCClient: last_message_time = datetime.now() drain_errors = 0 + # Если задача стартует на паузе — ждём resume до подключения к IRC + if is_active and not is_active(): + logger.info(f"⏸️ #{self.channel} waiting for resume before connecting...") + while is_active and not is_active(): + await asyncio.sleep(2) + logger.info(f"▶️ #{self.channel} resumed, connecting to IRC") + if not await self.connect(): raise ConnectionError(f"IRC connect failed for #{self.channel}") while duration == 0 or (datetime.now() - start_time).seconds < duration: # === ПРОВЕРКА АКТИВНОСТИ === if is_active and not is_active(): - logger.info("⏸️ Task paused/stopped, disconnecting...") - break + logger.info(f"⏸️ #{self.channel} paused, waiting for resume...") + await self.disconnect() + while is_active and not is_active(): + await asyncio.sleep(2) + logger.info(f"▶️ #{self.channel} resumed, reconnecting") + await self.connect() + last_message_time = datetime.now() + continue # Нет соединения — ждём перед повтором if not self._connected: