diff --git a/token_bot/history_manager/history.py b/token_bot/history_manager/history.py index a131767..845681f 100644 --- a/token_bot/history_manager/history.py +++ b/token_bot/history_manager/history.py @@ -15,8 +15,6 @@ class History: self._last_price_movement : int = 0 self._latest_price_datum : Tuple[datetime.datetime, int] | None = None self._update_triggers : List[UpdateTrigger] = [] - self._squelched_alerts : List[Alert] = [] - for alert_type in AlertType: self._update_triggers.append(UpdateTrigger(Alert(alert_type, flavor, self._region))) @@ -39,9 +37,8 @@ class History: async def _process_update_triggers(self) -> List[Alert]: alerts = [] for trigger in self._update_triggers: - if trigger.check_and_update(self._latest_price_datum, self._history) and trigger.alert not in self._squelched_alerts: + if trigger.check_and_update(self._latest_price_datum, self._history): alerts.append(trigger.alert) - return alerts async def add_price(self, datum: Tuple[datetime.datetime, int]) -> List[Alert]: diff --git a/token_bot/history_manager/update_trigger.py b/token_bot/history_manager/update_trigger.py index 919d7a9..b7a46f5 100644 --- a/token_bot/history_manager/update_trigger.py +++ b/token_bot/history_manager/update_trigger.py @@ -9,6 +9,7 @@ class UpdateTrigger: def __init__(self, alert: Alert): self._alert : Alert = alert self._last_trigger : Tuple[datetime.datetime, int] | None = None + self._squelched : bool = False @property def alert(self) -> Alert: @@ -75,5 +76,9 @@ class UpdateTrigger: if comparison_operator(new_datum[1], self._last_trigger[1]): self._last_trigger = new_datum - return True + was_squelched = self._squelched + self._squelched = True + return not was_squelched # Returns True if squelched otherwise True + elif self._squelched: + self._squelched = False return False \ No newline at end of file