publish eve_orehold_watcher.py
This commit is contained in:
parent
7260c0a649
commit
0ef5e7f367
1 changed files with 23 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ import configparser
|
|||
import json
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
import urllib.request
|
||||
|
|
@ -40,6 +41,27 @@ HERE = os.path.dirname(os.path.abspath(__file__))
|
|||
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
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
|
@ -396,6 +418,7 @@ def main():
|
|||
return
|
||||
mode = cp.get("watcher", "mode", fallback="ocr").strip().lower()
|
||||
print(f"=== eve_orehold_watcher starting (mode={mode}) ===")
|
||||
heartbeat(cp, "orehold")
|
||||
if mode == "ocr":
|
||||
run_ocr(cp)
|
||||
elif mode == "timer":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue