publish eve_orehold_watcher.py

This commit is contained in:
brockdarnold 2026-06-14 08:05:56 +00:00
parent 7260c0a649
commit 0ef5e7f367

View file

@ -32,6 +32,7 @@ import configparser
import json import json
import os import os
import re import re
import socket
import sys import sys
import time import time
import urllib.request import urllib.request
@ -40,6 +41,27 @@ HERE = os.path.dirname(os.path.abspath(__file__))
CONFIG_PATH = os.path.join(HERE, "config.ini") CONFIG_PATH = os.path.join(HERE, "config.ini")
def heartbeat(cp, source):
"""Post a one-line 'watcher online' to Discord so installs are verifiable at a
glance. Deduped to at most once per 6h per source to avoid restart spam."""
marker = os.path.join(HERE, f".hb_{source}")
try:
if os.path.exists(marker) and time.time() - os.path.getmtime(marker) < 6 * 3600:
return
except Exception:
pass
try:
host = socket.gethostname()
except Exception:
host = "PC"
_discord(cp, "🟢 Watcher online", f"`{source}` running on **{host}**.")
try:
with open(marker, "w") as f:
f.write(str(int(time.time())))
except Exception:
pass
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
# Config # Config
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
@ -396,6 +418,7 @@ def main():
return return
mode = cp.get("watcher", "mode", fallback="ocr").strip().lower() mode = cp.get("watcher", "mode", fallback="ocr").strip().lower()
print(f"=== eve_orehold_watcher starting (mode={mode}) ===") print(f"=== eve_orehold_watcher starting (mode={mode}) ===")
heartbeat(cp, "orehold")
if mode == "ocr": if mode == "ocr":
run_ocr(cp) run_ocr(cp)
elif mode == "timer": elif mode == "timer":