- Reset master to upstream/main (16,697 commits) - Overlay 2,271 local-only files (skills, tools, workspace, configs, apps) - Restore IDENTITY.md and USER.md templates - Build verified, gateway running, Discord working Co-Authored-By: Claude Opus 4.6 <[email protected]>
85 lines
2.0 KiB
Bash
85 lines
2.0 KiB
Bash
#!/usr/bin/env bash
|
|
# dba-listing-alert.sh — Overvåg DBA for nye billige annoncer
|
|
# Kør via cron: 0 * * * * bash /home/alex/clawd/tools/dba-listing-alert.sh
|
|
|
|
DISCORD_TARGET="1466863360099356763"
|
|
STATE_FILE="/tmp/dba-listing-state.json"
|
|
|
|
# Produkter der overvåges: "søgeterm:max_pris"
|
|
WATCHES=(
|
|
"RTX 3090:4500"
|
|
)
|
|
|
|
# Indlæs kendte annonce-IDs
|
|
if [ -f "$STATE_FILE" ]; then
|
|
SEEN=$(cat "$STATE_FILE")
|
|
else
|
|
SEEN="{}"
|
|
fi
|
|
|
|
for WATCH in "${WATCHES[@]}"; do
|
|
QUERY="${WATCH%%:*}"
|
|
MAX="${WATCH##*:}"
|
|
|
|
RESULTS=$(python3 /home/alex/clawd/tools/dba-search.py "$QUERY" --max-price "$MAX" --json 2>/dev/null)
|
|
[ -z "$RESULTS" ] && continue
|
|
|
|
echo "$RESULTS" | python3 - "$QUERY" "$MAX" "$DISCORD_TARGET" <<'PY'
|
|
import json, sys, subprocess, re
|
|
|
|
query = sys.argv[1]
|
|
max_price = int(sys.argv[2])
|
|
discord_target = sys.argv[3]
|
|
state_file = "/tmp/dba-listing-state.json"
|
|
|
|
try:
|
|
items = json.load(sys.stdin)
|
|
except:
|
|
sys.exit(0)
|
|
|
|
try:
|
|
with open(state_file) as f:
|
|
state = json.load(f)
|
|
except:
|
|
state = {}
|
|
|
|
seen = set(state.get(query, []))
|
|
new_items = []
|
|
|
|
for item in items:
|
|
url = item.get('url', '')
|
|
# Brug URL som ID
|
|
item_id = re.search(r'/item/(\d+)', url)
|
|
item_id = item_id.group(1) if item_id else url
|
|
if item_id and item_id not in seen:
|
|
new_items.append(item)
|
|
seen.add(item_id)
|
|
|
|
# Gem opdateret state
|
|
state[query] = list(seen)
|
|
with open(state_file, 'w') as f:
|
|
json.dump(state, f, indent=2)
|
|
|
|
if not new_items:
|
|
print(f"NO_NEW: {query}")
|
|
sys.exit(0)
|
|
|
|
for item in new_items:
|
|
title = item.get('title', '?')[:60]
|
|
price = item.get('price', '?')
|
|
url = item.get('url', '')
|
|
loc = item.get('location', '')
|
|
msg = f"Ny DBA annonce: {title} — {price} kr"
|
|
if loc:
|
|
msg += f" ({loc})"
|
|
msg += f" {url}"
|
|
print(f"ALERT: {msg}")
|
|
subprocess.run([
|
|
"openclaw", "message", "send",
|
|
"--channel", "discord",
|
|
"--target", discord_target,
|
|
"-m", msg
|
|
], capture_output=True)
|
|
PY
|
|
done
|