This commit is contained in:
2025-11-18 01:51:49 +01:00
parent c249010cbd
commit edfe38113a
2 changed files with 8 additions and 0 deletions

View File

@@ -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):
"""

View File

@@ -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}