publish eve_rock_watcher.py
This commit is contained in:
parent
f73dec2c37
commit
c966aafef7
1 changed files with 14 additions and 2 deletions
|
|
@ -241,6 +241,18 @@ def read_rows(cp, region, mode):
|
||||||
return parse_survey(text)
|
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():
|
def main():
|
||||||
cp = w.load_config()
|
cp = w.load_config()
|
||||||
if "--snip" in sys.argv:
|
if "--snip" in sys.argv:
|
||||||
|
|
@ -319,7 +331,7 @@ def main():
|
||||||
others = [(o, u) for (k, o, u) in keyed if k != key]
|
others = [(o, u) for (k, o, u) in keyed if k != key]
|
||||||
nxt = max(others, key=lambda x: x[1]) if others else None
|
nxt = max(others, key=lambda x: x[1]) if others else None
|
||||||
empty_at = int(now + tleft)
|
empty_at = int(now + tleft)
|
||||||
msg = f"{ore.title()} rock empties <t:{empty_at}:R> ({units:,} u left)."
|
msg = f"{ore.title()} rock empties in ~{_fmt_dur(tleft)} (<t:{empty_at}:R>) — {units:,} u left."
|
||||||
if nxt:
|
if nxt:
|
||||||
msg += f" Switch to {nxt[0].title()} ({nxt[1]:,} u)."
|
msg += f" Switch to {nxt[0].title()} ({nxt[1]:,} u)."
|
||||||
w.notify(cp, "Switch rocks", msg, priority="high", tags="pick,gem")
|
w.notify(cp, "Switch rocks", msg, priority="high", tags="pick,gem")
|
||||||
|
|
@ -330,7 +342,7 @@ def main():
|
||||||
empty_at = int(now + tleft)
|
empty_at = int(now + tleft)
|
||||||
others = [(o, u) for (k, o, u) in keyed if k != key]
|
others = [(o, u) for (k, o, u) in keyed if k != key]
|
||||||
nxt = max(others, key=lambda x: x[1]) if others else None
|
nxt = max(others, key=lambda x: x[1]) if others else None
|
||||||
line = f"🪨 {ore.title()} {units:,} u · empties <t:{empty_at}:R>"
|
line = f"🪨 {ore.title()} {units:,} u · ~{_fmt_dur(tleft)} left (empties <t:{empty_at}:R>)"
|
||||||
if nxt:
|
if nxt:
|
||||||
line += f" · next: {nxt[0].title()} ({nxt[1]:,} u)"
|
line += f" · next: {nxt[0].title()} ({nxt[1]:,} u)"
|
||||||
w._discord_live(cp, "rock", f"⛏️ {socket.gethostname()} current rock", line)
|
w._discord_live(cp, "rock", f"⛏️ {socket.gethostname()} current rock", line)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue