Fix an issue with the drops_enabled flag reporting true for sub-only drops
This commit is contained in:
1 parent
2737936739
commit
f3c189e86d
2 files changed
+14
-8
No files matched your search
+12
-8
@@ -306,6 +306,15 @@ class Channel:
|
|||||||
raise MinerException("Error while spade_url extraction: step #2")
|
raise MinerException("Error while spade_url extraction: step #2")
|
||||||
return URLType(match.group(1))
|
return URLType(match.group(1))
|
||||||
|
|
||||||
|
def _check_drops_enabled(self, available_drops: list[JsonType]) -> bool:
|
||||||
|
return any(
|
||||||
|
(
|
||||||
|
(campaign := self._twitch._campaigns.get(campaign_data["id"])) is not None
|
||||||
|
and campaign.can_earn(self)
|
||||||
|
)
|
||||||
|
for campaign_data in available_drops
|
||||||
|
)
|
||||||
|
|
||||||
def external_update(self, channel_data: JsonType, available_drops: list[JsonType]):
|
def external_update(self, channel_data: JsonType, available_drops: list[JsonType]):
|
||||||
"""
|
"""
|
||||||
Update stream information based on data provided externally.
|
Update stream information based on data provided externally.
|
||||||
@@ -317,9 +326,7 @@ class Channel:
|
|||||||
return
|
return
|
||||||
stream = Stream.from_get_stream(self, channel_data)
|
stream = Stream.from_get_stream(self, channel_data)
|
||||||
if not stream.drops_enabled:
|
if not stream.drops_enabled:
|
||||||
stream.drops_enabled = any(
|
stream.drops_enabled = self._check_drops_enabled(available_drops)
|
||||||
bool(campaign["timeBasedDrops"]) for campaign in available_drops
|
|
||||||
)
|
|
||||||
self._stream = stream
|
self._stream = stream
|
||||||
|
|
||||||
async def get_stream(self) -> Stream | None:
|
async def get_stream(self) -> Stream | None:
|
||||||
@@ -344,11 +351,8 @@ class Channel:
|
|||||||
except MinerException:
|
except MinerException:
|
||||||
logger.log(CALL, f"AvailableDrops GQL call failed for channel: {self._login}")
|
logger.log(CALL, f"AvailableDrops GQL call failed for channel: {self._login}")
|
||||||
else:
|
else:
|
||||||
stream.drops_enabled = any(
|
stream.drops_enabled = self._check_drops_enabled(
|
||||||
bool(campaign["timeBasedDrops"])
|
available_drops_campaigns["data"]["channel"]["viewerDropCampaigns"] or []
|
||||||
for campaign in (
|
|
||||||
available_drops_campaigns["data"]["channel"]["viewerDropCampaigns"] or []
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return stream
|
return stream
|
||||||
|
|
||||||
|
|||||||
@@ -429,6 +429,7 @@ class Twitch:
|
|||||||
self.wanted_games: list[Game] = []
|
self.wanted_games: list[Game] = []
|
||||||
self.inventory: list[DropsCampaign] = []
|
self.inventory: list[DropsCampaign] = []
|
||||||
self._drops: dict[str, TimedDrop] = {}
|
self._drops: dict[str, TimedDrop] = {}
|
||||||
|
self._campaigns: dict[str, DropsCampaign] = {}
|
||||||
self._mnt_triggers: deque[datetime] = deque()
|
self._mnt_triggers: deque[datetime] = deque()
|
||||||
# NOTE: GQL is pretty volatile and breaks everything if one runs into their rate limit.
|
# NOTE: GQL is pretty volatile and breaks everything if one runs into their rate limit.
|
||||||
# Do not modify the default, safe values.
|
# Do not modify the default, safe values.
|
||||||
@@ -1464,6 +1465,7 @@ class Twitch:
|
|||||||
if campaign.can_earn_within(next_hour):
|
if campaign.can_earn_within(next_hour):
|
||||||
switch_triggers.update(campaign.time_triggers)
|
switch_triggers.update(campaign.time_triggers)
|
||||||
self.inventory.append(campaign)
|
self.inventory.append(campaign)
|
||||||
|
self._campaigns[campaign.id] = campaign
|
||||||
# concurrently add the campaigns into the GUI
|
# concurrently add the campaigns into the GUI
|
||||||
# NOTE: this fetches pictures from the CDN, so might be slow without a cache
|
# NOTE: this fetches pictures from the CDN, so might be slow without a cache
|
||||||
status_update(
|
status_update(
|
||||||
|
|||||||
Reference in new issue
Block a user