#!/bin/sh
# news-de — top German news headlines via bullpen @callboy (tagesschau RSS).
# Goes through the room (callboy fetches + saves to /bullpen (mneme), so @librarian can
# recall it later), then prints the clean headline list for the caller to filter.
NICK="${1:-newsdesk}"
REPLY=$(room-ask --from "$NICK" --timeout 90 @callboy "fetch https://www.tagesschau.de/index~rss2.xml")
P=$(printf '%s' "$REPLY" | grep -oE '/var/lib/bullpen/artifacts/[0-9]+\.txt' | head -1)
if [ -z "$P" ]; then
    # small fetch (no artifact) or an error — pass callboy's reply through
    printf '%s\n' "$REPLY"; exit 1
fi
# item <title>s only (skip the channel title on line 1)
grep -oE '<title>[^<]+</title>' "$P" | sed 's/<[^>]*>//g' | sed '1d'
