diff --git a/eve_rock_watcher.py b/eve_rock_watcher.py index 33c1465..f2405f2 100644 --- a/eve_rock_watcher.py +++ b/eve_rock_watcher.py @@ -241,6 +241,18 @@ def read_rows(cp, region, mode): return parse_survey(text) +def _fmt_dur(secs): + """Human time-left, e.g. '1h 04m', '7m 20s', '45s'.""" + secs = int(max(0, secs)) + h, rem = divmod(secs, 3600) + m, s = divmod(rem, 60) + if h: + return f"{h}h {m:02d}m" + if m: + return f"{m}m {s:02d}s" + return f"{s}s" + + def main(): cp = w.load_config() if "--snip" in sys.argv: @@ -319,7 +331,7 @@ def main(): others = [(o, u) for (k, o, u) in keyed if k != key] nxt = max(others, key=lambda x: x[1]) if others else None empty_at = int(now + tleft) - msg = f"{ore.title()} rock empties ({units:,} u left)." + msg = f"{ore.title()} rock empties in ~{_fmt_dur(tleft)} () — {units:,} u left." if nxt: msg += f" Switch to {nxt[0].title()} ({nxt[1]:,} u)." w.notify(cp, "Switch rocks", msg, priority="high", tags="pick,gem") @@ -330,7 +342,7 @@ def main(): empty_at = int(now + tleft) others = [(o, u) for (k, o, u) in keyed if k != key] nxt = max(others, key=lambda x: x[1]) if others else None - line = f"🪨 {ore.title()} {units:,} u · empties " + line = f"🪨 {ore.title()} {units:,} u · ~{_fmt_dur(tleft)} left (empties )" if nxt: line += f" · next: {nxt[0].title()} ({nxt[1]:,} u)" w._discord_live(cp, "rock", f"⛏️ {socket.gethostname()} current rock", line)