add stiky

This commit is contained in:
Yuriy Yuriev
2026-05-29 21:47:40 +07:00
parent 61ff90e51b
commit b02b7518cf
6 changed files with 109 additions and 220 deletions
+7 -2
View File
@@ -142,7 +142,6 @@ class TwitchGQLChatClient:
on_drain_fail: Callable[[], Awaitable[None]] = None,
) -> dict:
stats = {"links_found": 0, "messages": 0, "reconnects": 0}
start_time = datetime.now()
last_message_time = datetime.now()
drain_errors = 0
@@ -154,12 +153,18 @@ class TwitchGQLChatClient:
if not await self.connect():
raise ConnectionError(f"IRC WS connect failed for #{self.channel}")
while duration == 0 or (datetime.now() - start_time).seconds < duration:
# start_time после паузы и подключения — пауза не считается в длительность
start_time = datetime.now()
while duration == 0 or (datetime.now() - start_time).total_seconds() < duration:
if is_active and not is_active():
logger.info(f"⏸️ #{self.channel} пауза...")
await self._cleanup()
pause_begin = datetime.now()
while is_active and not is_active():
await asyncio.sleep(2)
# Исключаем время паузы из отсчёта длительности
start_time += datetime.now() - pause_begin
logger.info(f"▶️ #{self.channel} resume, переподключение...")
if not await self.connect():
drain_errors += 1