diff --git a/chat_listener.py b/chat_listener.py index 32fbf67..78f524e 100644 --- a/chat_listener.py +++ b/chat_listener.py @@ -16,6 +16,14 @@ class TwitchBot(twitchio.Client): ) 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): """Called once when the bot goes online.""" print(f"Listener ready for #{self.channel_name}") diff --git a/listener_manager.py b/listener_manager.py index 52b1001..83aa36a 100644 --- a/listener_manager.py +++ b/listener_manager.py @@ -37,7 +37,9 @@ class ListenerManager: websocket_manager=websocket_manager, 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 async def stop_listener_for_user(self, user_id: int):