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