This commit is contained in:
2025-11-18 01:40:58 +01:00
parent 303c8430e8
commit 53c1966494
2 changed files with 11 additions and 1 deletions

View File

@@ -16,6 +16,14 @@ class TwitchBot(twitchio.Client):
) )
self.channel_name = channel_name self.channel_name = channel_name
async def start(self):
"""
A custom start method to bypass the default start() which can
unpredictably start a webserver. This gives us direct control.
"""
await self.connect()
await self.join_channels([self.channel_name])
async def event_ready(self): async def event_ready(self):
"""Called once when the bot goes online.""" """Called once when the bot goes online."""
print(f"Listener ready for #{self.channel_name}") print(f"Listener ready for #{self.channel_name}")

View File

@@ -37,7 +37,9 @@ class ListenerManager:
websocket_manager=websocket_manager, websocket_manager=websocket_manager,
db_user_id=user.id db_user_id=user.id
) )
task = asyncio.create_task(bot.start()) # We now call our custom start() method in the TwitchBot class,
# which gives us direct control over the connection process.
task = asyncio.create_task(bot.start())
self.active_listeners[user.id] = task self.active_listeners[user.id] = task
async def stop_listener_for_user(self, user_id: int): async def stop_listener_for_user(self, user_id: int):