publish eve_combat_watcher.py

This commit is contained in:
brockdarnold 2026-06-15 04:20:55 +00:00
parent ca77f3e5e2
commit 6506fa06e7

View file

@ -41,6 +41,8 @@ HOLDFULL = re.compile(r"\(notify\).*(cargo (?:hold )?is full|hold is full|"
CAPEMPTY = re.compile(r"\(notify\).*(capacitor is empty|not enough (?:capacitor|energy))", CAPEMPTY = re.compile(r"\(notify\).*(capacitor is empty|not enough (?:capacitor|energy))",
re.IGNORECASE) re.IGNORECASE)
BOUNTY = re.compile(r"\(bounty\)\s*([\d,]+(?:\.\d+)?)\s*ISK", re.IGNORECASE) 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)
def find_gamelogs(cp): def find_gamelogs(cp):
@ -63,6 +65,10 @@ def main():
cp = w.load_config() cp = w.load_config()
g = lambda k, d: (cp.getint("combat", k, fallback=d) if cp.has_section("combat") else d) g = lambda k, d: (cp.getint("combat", k, fallback=d) if cp.has_section("combat") else d)
cooldown, min_dmg, milestone = g("cooldown_secs", 60), g("min_damage", 1), g("bounty_milestone", 25000000) cooldown, min_dmg, milestone = g("cooldown_secs", 60), g("min_damage", 1), g("bounty_milestone", 25000000)
# mining-stall = lasers stopped pulling ore (rock depleted / out of range / you stopped).
# 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)
if "--test" in sys.argv: if "--test" in sys.argv:
w.notify(cp, "Gamelog watcher test", "Combat/tackle/hold/bounty alerts will reach you.", w.notify(cp, "Gamelog watcher test", "Combat/tackle/hold/bounty alerts will reach you.",
@ -83,6 +89,9 @@ def main():
last_dmg = 0.0 last_dmg = 0.0
bounty_total = 0.0 bounty_total = 0.0
bounty_reported = 0.0 bounty_reported = 0.0
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
while True: while True:
nl = newest(gdir) nl = newest(gdir)
@ -97,9 +106,25 @@ def main():
time.sleep(3); continue time.sleep(3); continue
line = fh.readline() line = fh.readline()
if not line: if not line:
# no new log line — check if mining has stalled (lasers stopped → switch rocks)
if last_mine and not mine_alerted and w.bot_mining(cp) and not w.bot_muted(cp) \
and time.time() - last_mine > mining_stall:
mine_alerted = True
ore = (last_ore.strip().title() + " ") if last_ore else ""
w.notify(cp, "Switch rocks", f"Lasers stopped pulling {ore}ore "
f"({int(time.time()-last_mine)}s) — rock depleted or out of range. "
"Lock a new rock.", priority="high", tags="pick")
print("[gamelog] mining stall — switch-rocks alert")
time.sleep(1); continue time.sleep(1); continue
clean = TAG.sub("", line) clean = TAG.sub("", line)
mm = MINING.search(clean)
if mm:
last_mine = time.time()
last_ore = mm.group(2)
mine_alerted = False # re-arm: lasers are pulling again
continue
if "(notify)" in line: if "(notify)" in line:
if DANGER.search(clean): if DANGER.search(clean):
w.notify(cp, "⚠ TACKLED / EWAR", w.notify(cp, "⚠ TACKLED / EWAR",