From edfe38113a616b37712812db635713b6832ac138 Mon Sep 17 00:00:00 2001 From: ramforth Date: Tue, 18 Nov 2025 01:51:49 +0100 Subject: [PATCH] edrsfx --- chat_listener.py | 3 +++ listener_manager.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/chat_listener.py b/chat_listener.py index a981814..354e89a 100644 --- a/chat_listener.py +++ b/chat_listener.py @@ -25,6 +25,9 @@ class TwitchBot(twitchio.Client): ssl=True # Mandate: Explicitly use SSL for the IRC connection. ) self.channel_name = channel_name + # Health Check: If __init__ completes successfully, this flag will exist. + # If super().__init__ fails silently, this line is never reached. + self.is_initialized = True async def start(self): """ diff --git a/listener_manager.py b/listener_manager.py index a4e114a..ca57a87 100644 --- a/listener_manager.py +++ b/listener_manager.py @@ -42,6 +42,11 @@ class ListenerManager: db_user_id=user.id ) + # Verify that the bot was initialized correctly before proceeding. + # This catches silent failures from the twitchio library. + if not getattr(bot, 'is_initialized', False): + raise Exception("TwitchBot failed to initialize, likely due to an invalid token.") + task = asyncio.create_task(bot.start()) # Store both the task and the bot instance for graceful shutdown self.active_listeners[user.id] = {"task": task, "bot": bot}