This commit is contained in:
Yuriy Yuriev
2026-07-05 16:59:33 +07:00
parent f262616aad
commit 44ce29d2e0
9 changed files with 188 additions and 31 deletions
+12 -1
View File
@@ -5,6 +5,7 @@ Twitch чат через IRC over WebSocket (wss://irc-ws.chat.twitch.tv:443).
import asyncio
import logging
import random
import re
from typing import Optional, Callable, Awaitable, List
from datetime import datetime
@@ -34,7 +35,13 @@ class TwitchGQLChatClient:
):
self.channel = channel.lower()
self.target_username = target_username.lower()
self.irc_username = irc_username or settings.IRC_USERNAME
# Anonymous Twitch login (justinfanNNNNN) is shared across all clients by
# default, so parallel monitors on the same nick get kicked by Twitch
# (one connection per nick) — randomize it unless a real login is configured.
if irc_username or settings.IRC_USERNAME != "justinfan12345":
self.irc_username = irc_username or settings.IRC_USERNAME
else:
self.irc_username = f"justinfan{random.randint(10000, 99999)}"
self.irc_oauth = irc_oauth or settings.IRC_OAUTH
self._ws: Optional[aiohttp.ClientWebSocketResponse] = None
@@ -257,6 +264,10 @@ class TwitchGQLChatClient:
raise
except Exception:
pass
else:
logger.info(
f"🚫 Домен не разрешён: {url} (allowed_domains={allowed_domains})"
)
return stats