From 2917e3995c77e2d871339ba02e37b4a5e0b173ae Mon Sep 17 00:00:00 2001 From: DevilXD Date: Sun, 5 Dec 2021 18:11:37 +0100 Subject: [PATCH] Fix a bug with websocket still running after all drops are mined out --- twitch.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/twitch.py b/twitch.py index e5b2493..f0d50c2 100644 --- a/twitch.py +++ b/twitch.py @@ -92,7 +92,6 @@ class Twitch: • Changing the stream that's being watched if necessary """ # Start our websocket connection - self.websocket.start() while True: # Claim the drops we can self.inventory = await self.get_inventory() @@ -114,6 +113,7 @@ class Twitch: "Application Terminated.\nClose the console window to exit the application.", ) await asyncio.Future() + self.websocket.start() if not channel_names: # get a list of all channels with drops enabled print("Fetching suitable live channels to watch...") @@ -122,8 +122,9 @@ class Twitch: ) for game, channels in live_streams.items(): for channel in channels: - self.channels[channel.id] = channel - print(f"Added channel: {channel.name} for game: {game.name}") + if channel.id not in self.channels: + self.channels[channel.id] = channel + print(f"Added channel: {channel.name} for game: {game.name}") else: # Fetch information about all channels we're supposed to handle for channel_name in channel_names: @@ -153,10 +154,11 @@ class Twitch: ) if self._campaign_change.is_set(): # we need to reevaluate all campaigns + # first of all, stop watching + self.stop_watching() # reconnect the websocket await self.websocket.close() - self.websocket.start() - break # cycles the outer loop + break # cycle the outer loop # otherwise, it was the channel change one for channel in self.channels.values(): if (