publish eve_combat_watcher.py

This commit is contained in:
brockdarnold 2026-06-15 05:31:11 +00:00
parent 82b9ef3605
commit e872cc1b13

View file

@ -43,6 +43,40 @@ CAPEMPTY = re.compile(r"\(notify\).*(capacitor is empty|not enough (?:capacitor|
BOUNTY = re.compile(r"\(bounty\)\s*([\d,]+(?:\.\d+)?)\s*ISK", re.IGNORECASE)
# "(mining) You mined 76 units of Omber II-Grade" (after color/font tags stripped)
MINING = re.compile(r"\(mining\).*?mined\s+([\d,]+)\s+units?\s+of\s+(.+?)\s*$", re.IGNORECASE)
# "(notify) Successfully compressed Omber into 3029 Compressed Omber." -> hold was just freed
COMPRESSED = re.compile(r"successfully compressed", re.IGNORECASE)
# raw ore m³/unit (base name, longest first so 'dark ochre' beats 'ochre')
ORE_VOL = {"dark ochre": 8.0, "veldspar": 0.1, "scordite": 0.15, "pyroxeres": 0.3,
"plagioclase": 0.35, "omber": 0.6, "kernite": 1.2, "jaspet": 2.0,
"hemorphite": 3.0, "hedbergite": 3.0, "gneiss": 5.0, "crokite": 16.0,
"spodumain": 16.0, "bistot": 16.0, "arkonor": 16.0, "mercoxit": 40.0}
def ore_vol(name):
n = name.strip().lower()
for base in sorted(ORE_VOL, key=len, reverse=True):
if base in n:
return ORE_VOL[base]
return 0.6 # default ~Omber
def seed_raw_since_compress(path):
"""Sum raw ore m³ mined since the last 'Successfully compressed' in this log, so the
compress-tracker is accurate immediately after a restart (not reset to zero)."""
m3 = 0.0
try:
lines = open(path, "r", encoding="utf-8", errors="ignore").read().splitlines()
except Exception:
return 0.0
for ln in lines:
clean = TAG.sub("", ln)
if COMPRESSED.search(clean):
m3 = 0.0 # everything before a compress is gone
continue
mm = MINING.search(clean)
if mm:
m3 += int(mm.group(1).replace(",", "")) * ore_vol(mm.group(2))
return m3
def find_gamelogs(cp):
@ -69,6 +103,9 @@ def main():
# Reliable "switch rocks" signal straight from the log — no window or OCR needed.
# Must exceed a normal cycle gap (~35s observed) so it doesn't false-fire between cycles.
mining_stall = g("mining_stall_secs", 90)
# compress reminder: ping when raw ore piled up since your last compression crosses this
# many m³ (default 18,000 ≈ what Brock sits on). Tune via [combat] compress_at_m3.
compress_at_m3 = g("compress_at_m3", 18000)
if "--test" in sys.argv:
w.notify(cp, "Gamelog watcher test", "Combat/tackle/hold/bounty alerts will reach you.",
@ -92,6 +129,10 @@ def main():
last_mine = 0.0 # last time a "You mined N units" line appeared
last_ore = "" # ore on the most recent mining cycle
mine_alerted = False # fired the stall alert; re-arm on the next mining line
raw_m3 = seed_raw_since_compress(cur) if cur else 0.0 # uncompressed ore in hold
compress_alerted = False
print(f"[gamelog] raw ore since last compress ~{raw_m3:,.0f} m3 "
f"(alert at {compress_at_m3:,})")
while True:
nl = newest(gdir)
@ -123,6 +164,20 @@ def main():
last_mine = time.time()
last_ore = mm.group(2)
mine_alerted = False # re-arm: lasers are pulling again
raw_m3 += int(mm.group(1).replace(",", "")) * ore_vol(mm.group(2))
if raw_m3 >= compress_at_m3 and not compress_alerted \
and w.bot_mining(cp) and not w.bot_muted(cp):
compress_alerted = True
w.notify(cp, "Compress now",
f"~{raw_m3:,.0f} m³ of raw ore piled up since your last "
f"compression — run the compressor to free the hold.",
priority="high", tags="package")
print(f"[gamelog] compress alert at {raw_m3:,.0f} m3")
continue
if COMPRESSED.search(clean): # you compressed -> hold freed, re-arm
raw_m3 = 0.0
compress_alerted = False
continue
if "(notify)" in line: