fix irc
This commit is contained in:
+10
-4
@@ -183,6 +183,8 @@ class TwitchIRCClient:
|
||||
logger.info(f"⏸️ #{self.channel} waiting for resume before connecting...")
|
||||
while is_active and not is_active():
|
||||
await asyncio.sleep(2)
|
||||
if not is_active and not is_active():
|
||||
return stats
|
||||
logger.info(f"▶️ #{self.channel} resumed, connecting to IRC")
|
||||
|
||||
if not await self.connect():
|
||||
@@ -190,7 +192,7 @@ class TwitchIRCClient:
|
||||
|
||||
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(f"⏸️ #{self.channel} paused, waiting for resume...")
|
||||
await self.disconnect()
|
||||
while is_active and not is_active():
|
||||
@@ -198,7 +200,7 @@ class TwitchIRCClient:
|
||||
logger.info(f"▶️ #{self.channel} resumed, reconnecting")
|
||||
await self.connect()
|
||||
last_message_time = datetime.now()
|
||||
continue
|
||||
continue
|
||||
|
||||
# Нет соединения — ждём перед повтором
|
||||
if not self._connected:
|
||||
@@ -265,7 +267,9 @@ class TwitchIRCClient:
|
||||
# Читаем строку
|
||||
try:
|
||||
line = await asyncio.wait_for(self._read_line(), timeout=5.0)
|
||||
except (asyncio.TimeoutError, asyncio.CancelledError):
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except asyncio.TimeoutError:
|
||||
continue
|
||||
except Exception as e:
|
||||
logger.warning(f"IRC read error: {e}")
|
||||
@@ -291,7 +295,9 @@ class TwitchIRCClient:
|
||||
stats["links_found"] += 1
|
||||
try:
|
||||
await on_url_found(url, msg['display_name'])
|
||||
except:
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return stats
|
||||
|
||||
Reference in New Issue
Block a user