publish eve_orehold_watcher.py

This commit is contained in:
brockdarnold 2026-06-14 16:18:08 +00:00
parent ef950fdccd
commit 48fd3bcb17

View file

@ -335,6 +335,7 @@ def run_ocr(cp):
cooldown = cp.getint("watcher", "cooldown_secs", fallback=120)
# stall = hold not growing -> lasers/drones stopped (depleted rock, idle drones)
stall_secs = cp.getint("watcher", "stall_secs", fallback=150)
status_secs = cp.getint("watcher", "status_secs", fallback=90) # live Discord readout
region_s = cp.get("ocr", "region", fallback="").strip()
if region_s:
@ -357,6 +358,9 @@ def run_ocr(cp):
last_stall_alert = 0.0
misses = 0
samples = [] # recent (t, cur) for the live fill-rate estimate
rate_m3min = 0.0
last_status = 0.0
was_mining = False
while True:
try:
img = grab_region(region)
@ -374,7 +378,22 @@ def run_ocr(cp):
if len(samples) >= 2 and (samples[-1][0] - samples[0][0]) >= 20:
dc = samples[-1][1] - samples[0][1]
dt = samples[-1][0] - samples[0][0]
write_rate(dc / dt * 60 if dc > 0 else 0.0, cur, cap)
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 ---
mining = bot_mining(cp)
if mining and not bot_muted(cp) and \
(not was_mining or time.time() - last_status >= status_secs):
free = cap - cur
if rate_m3min > 0:
full_at = int(time.time() + free / rate_m3min * 60)
tail = f"filling {rate_m3min:,.0f} m³/min · full <t:{full_at}:R>"
else:
tail = "not growing yet — lasers/drones idle?"
_discord(cp, "⛏️ Ore hold",
f"{pct:.0f}% ({cur:,}/{cap:,} m³) · {tail}")
last_status = time.time()
was_mining = mining
if pct < reset_pct:
armed = True
# --- still mining? (hold should be growing) ---