fix irc connect
This commit is contained in:
+15
-2
@@ -178,14 +178,27 @@ class TwitchIRCClient:
|
|||||||
last_message_time = datetime.now()
|
last_message_time = datetime.now()
|
||||||
drain_errors = 0
|
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():
|
if not await self.connect():
|
||||||
raise ConnectionError(f"IRC connect failed for #{self.channel}")
|
raise ConnectionError(f"IRC connect failed for #{self.channel}")
|
||||||
|
|
||||||
while duration == 0 or (datetime.now() - start_time).seconds < duration:
|
while duration == 0 or (datetime.now() - start_time).seconds < duration:
|
||||||
# === ПРОВЕРКА АКТИВНОСТИ ===
|
# === ПРОВЕРКА АКТИВНОСТИ ===
|
||||||
if is_active and not is_active():
|
if is_active and not is_active():
|
||||||
logger.info("⏸️ Task paused/stopped, disconnecting...")
|
logger.info(f"⏸️ #{self.channel} paused, waiting for resume...")
|
||||||
break
|
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:
|
if not self._connected:
|
||||||
|
|||||||
Reference in New Issue
Block a user