From 5e3e7b6f4f7cc58e1bc4d4cbe8420bc5850dff3d Mon Sep 17 00:00:00 2001 From: DevilXD Date: Tue, 15 Nov 2022 21:45:44 +0100 Subject: [PATCH] Fix an issue with trying to mine a completed campaign --- twitch.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/twitch.py b/twitch.py index 8ebe088..03835dc 100644 --- a/twitch.py +++ b/twitch.py @@ -695,14 +695,19 @@ class Twitch: """ if not self.wanted_games: return False - return ( - channel.online # stream online - and channel.drops_enabled # drops are enabled - # it's one of the games we've selected - and (game := channel.game) is not None and game in self.wanted_games - # we can progress any campaign for the selected game - and any(campaign.can_earn(channel) for campaign in self.inventory) - ) + # exit early if + if ( + not channel.online # stream is offline + or not channel.drops_enabled # drops aren't enabled + # there's no game or it's not one of the games we've selected + or (game := channel.game) is None or game not in self.wanted_games + ): + return False + # check if we can progress any campaign for the played game + for campaign in self.inventory: + if campaign.game == game and campaign.can_earn(channel): + return True + return False def should_switch(self, channel: Channel) -> bool: """