- 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 <noreply@anthropic.com>
104 lines
3.2 KiB
Bash
104 lines
3.2 KiB
Bash
#!/usr/bin/env bash
|
|
# dba-check-inbox.sh — tjekker DBA indbakke for nye svar
|
|
# Metode 1: DBA messages siden via Chromium (primær)
|
|
# Metode 2: Outlook email (backup)
|
|
# Kør 1x/time via cron.
|
|
|
|
STATE_FILE="/tmp/dba-inbox-state.json"
|
|
DISPLAY_NUM=":99"
|
|
|
|
check_dba_page() {
|
|
WIN=$(DISPLAY=$DISPLAY_NUM xdotool search --class "chromium" 2>/dev/null | head -1)
|
|
[ -z "$WIN" ] && return 1
|
|
|
|
# Naviger til indbakke
|
|
DISPLAY=$DISPLAY_NUM xdotool key --window "$WIN" F6
|
|
sleep 0.4
|
|
DISPLAY=$DISPLAY_NUM xdotool key --window "$WIN" ctrl+a
|
|
sleep 0.2
|
|
DISPLAY=$DISPLAY_NUM xdotool type --window "$WIN" --clearmodifiers "https://www.dba.dk/messages"
|
|
DISPLAY=$DISPLAY_NUM xdotool key --window "$WIN" Return
|
|
sleep 7
|
|
|
|
# Hent page tekst — select all + clipboard
|
|
DISPLAY=$DISPLAY_NUM xdotool key --window "$WIN" ctrl+a
|
|
sleep 0.3
|
|
DISPLAY=$DISPLAY_NUM xdotool key --window "$WIN" ctrl+c
|
|
sleep 0.5
|
|
|
|
PAGE=$(DISPLAY=$DISPLAY_NUM xclip -o -selection clipboard 2>/dev/null || echo "")
|
|
[ -z "$PAGE" ] && return 1
|
|
|
|
# Parse: find samtaler uden "Dig:" prefix = sælger har svaret
|
|
python3 - "$PAGE" <<'PYEOF'
|
|
import sys, json, os, datetime, re
|
|
|
|
page = sys.argv[1] if len(sys.argv) > 1 else ""
|
|
state_file = '/tmp/dba-inbox-state.json'
|
|
|
|
try:
|
|
with open(state_file) as f:
|
|
prev = json.load(f)
|
|
except Exception:
|
|
prev = {}
|
|
|
|
prev_convs = prev.get('conversations', {})
|
|
new_replies = []
|
|
|
|
# Parse conversation lines fra DBA clipboard tekst
|
|
# Format: "Titel\nDig: tekst..." eller "Titel\nSælger tekst..."
|
|
lines = [l.strip() for l in page.split('\n') if l.strip()]
|
|
|
|
tracked = ['RTX 3090 24GB', 'Full face snorkelmaske til børn', 'CRUZ Full Face Snorkelmaske']
|
|
current_convs = {}
|
|
|
|
for i, line in enumerate(lines):
|
|
for title in tracked:
|
|
if title.lower() in line.lower():
|
|
# Next non-empty line is the preview
|
|
for j in range(i+1, min(i+4, len(lines))):
|
|
preview = lines[j].strip()
|
|
if preview and len(preview) > 5:
|
|
current_convs[title] = preview
|
|
break
|
|
|
|
# Check for changes — ny svar = preview ændret OG starter ikke med "Dig:"
|
|
for title, preview in current_convs.items():
|
|
old_preview = prev_convs.get(title, '')
|
|
is_our_msg = preview.lower().startswith('dig:')
|
|
if not is_our_msg and preview != old_preview:
|
|
new_replies.append({'title': title, 'preview': preview})
|
|
|
|
# Gem state
|
|
prev['conversations'] = current_convs
|
|
prev['checkedAt'] = datetime.datetime.now().isoformat()
|
|
with open(state_file, 'w') as f:
|
|
json.dump(prev, f, indent=2, ensure_ascii=False)
|
|
|
|
if new_replies:
|
|
for r in new_replies:
|
|
print(f"NEW:📬 **Nyt svar på DBA!**\n**{r['title']}**\n_{r['preview']}_")
|
|
else:
|
|
print("NO_NEW")
|
|
PYEOF
|
|
}
|
|
|
|
check_email() {
|
|
node /home/alex/clawd/tools/dba-inbox-check.cjs 2>/dev/null
|
|
}
|
|
|
|
# Prøv DBA-siden først, derefter email
|
|
RESULT=$(check_dba_page 2>/dev/null)
|
|
if [ -z "$RESULT" ] || [ "$RESULT" = "NO_NEW" ]; then
|
|
RESULT=$(check_email 2>/dev/null)
|
|
fi
|
|
|
|
echo "$(date '+%Y-%m-%d %H:%M'): $RESULT"
|
|
|
|
# Send Discord notifikation hvis nyt svar
|
|
if echo "$RESULT" | grep -q "^NEW:"; then
|
|
MSG=$(echo "$RESULT" | sed 's/^NEW://' | tr '\n' ' ')
|
|
openclaw message send --channel discord --target "1466863360099356763" \
|
|
-m "$MSG" 2>/dev/null || true
|
|
fi
|