diff --git a/scripts/price_monitor.py b/scripts/price_monitor.py index 7c9a4a88..a2dcb491 100644 --- a/scripts/price_monitor.py +++ b/scripts/price_monitor.py @@ -333,6 +333,15 @@ def run_once(round_label=""): state_updated = False # 时间冷却:同股同区间30分钟内不重复推 _push_cooldown = {} + _cooldown_file = "/home/hmo/.hermes/.price_push_cooldown.json" + try: + import os + if os.path.exists(_cooldown_file): + with open(_cooldown_file) as _f: + _push_cooldown = json.load(_f) + except Exception: + _push_cooldown = {} + def _can_push(code, zone_key): now = time.time() key = f"{code}_{zone_key}" @@ -340,6 +349,12 @@ def run_once(round_label=""): if now - last < 1800: # 30分钟 return False _push_cooldown[key] = now + # 持久化写入 + try: + with open(_cooldown_file, "w") as _f: + json.dump(_push_cooldown, _f) + except Exception: + pass return True # 收集所有需要检查的代码