publish eve_orehold_watcher.py

This commit is contained in:
brockdarnold 2026-06-15 03:48:29 +00:00
parent 2b90438d62
commit f73dec2c37

View file

@ -433,6 +433,13 @@ def run_ocr(cp):
# stall = hold not growing -> lasers/drones stopped (depleted rock, idle drones)
stall_secs = cp.getint("watcher", "stall_secs", fallback=75)
status_secs = cp.getint("watcher", "status_secs", fallback=90) # live Discord readout
# The "X/Y m³" text vanishes when items are selected/compressed, so OCR can lock
# onto the wrong gauge (e.g. hull) and post a bogus low %. Until the visual fill-bar
# read is in, only post the hold % to Discord when the read is *trusted* — i.e. we've
# actually watched it grow this session. Off by default; flip [watcher] post_hold=true
# once the fill-bar method proves out.
post_hold = cp.getboolean("watcher", "post_hold", fallback=False)
ever_grew = False
region_s = cp.get("ocr", "region", fallback="").strip()
if region_s:
@ -478,8 +485,10 @@ def run_ocr(cp):
rate_m3min = dc / dt * 60 if dc > 0 else 0.0
write_rate(rate_m3min, cur, cap)
# --- live status feed to Discord during a mining session ---
# trust the read only once we've watched the hold actually grow; a static
# low % that never moves is the wrong-gauge / selection-summary misread.
mining = bot_mining(cp)
if mining and not bot_muted(cp) and \
if mining and post_hold and ever_grew and not bot_muted(cp) and \
(not was_mining or time.time() - last_status >= status_secs):
free = cap - cur
if rate_m3min > 0:
@ -498,8 +507,11 @@ def run_ocr(cp):
# --- still mining? (hold should be growing) ---
if cur > last_cur:
last_grow = time.time()
if last_cur >= 0:
ever_grew = True
last_cur = cur
if pct < alert_pct - 1 and time.time() - last_grow > stall_secs \
if post_hold and ever_grew and pct < alert_pct - 1 \
and time.time() - last_grow > stall_secs \
and time.time() - last_stall_alert > cooldown:
notify(cp, "Mining stopped?",
f"Hold hasn't grown in {stall_secs}s at {pct:.0f}% — rock "
@ -507,7 +519,7 @@ def run_ocr(cp):
priority="high", tags="warning")
last_stall_alert = time.time()
# --- hold full ---
if armed and pct >= alert_pct and \
if post_hold and ever_grew and armed and pct >= alert_pct and \
time.time() - last_alert > cooldown:
notify(cp, "Hold full — compress",
f"Hold at {pct:.0f}% ({cur:,}/{cap:,} m3). "