mirror of
https://github.com/rangermix/TwitchDropsMiner.git
synced 2026-06-04 11:29:38 +00:00
Ensure all possible time triggers are included
This commit is contained in:
10
inventory.py
10
inventory.py
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from itertools import chain
|
||||
from typing import TYPE_CHECKING
|
||||
from functools import cached_property
|
||||
from datetime import datetime, timezone
|
||||
@@ -246,6 +247,15 @@ class DropsCampaign:
|
||||
def drops(self) -> abc.Iterable[TimedDrop]:
|
||||
return self.timed_drops.values()
|
||||
|
||||
@property
|
||||
def time_triggers(self) -> set[datetime]:
|
||||
return set(
|
||||
chain(
|
||||
(self.starts_at, self.ends_at),
|
||||
*((d.starts_at, d.ends_at) for d in self.timed_drops.values()),
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def active(self) -> bool:
|
||||
return self.starts_at <= datetime.now(timezone.utc) < self.ends_at
|
||||
|
||||
@@ -1554,8 +1554,7 @@ class Twitch:
|
||||
)
|
||||
self._drops.update({drop.id: drop for drop in campaign.drops})
|
||||
if campaign.can_earn_within(next_hour):
|
||||
switch_triggers.add(campaign.starts_at)
|
||||
switch_triggers.add(campaign.ends_at)
|
||||
switch_triggers.update(campaign.time_triggers)
|
||||
# NOTE: this fetches pictures from the CDN, so might be slow without a cache
|
||||
await self.gui.inv.add_campaign(campaign)
|
||||
# this is needed here explicitly, because images aren't always fetched
|
||||
|
||||
Reference in New Issue
Block a user