Shuffle the Schau
2026 - Apr 6
Creating a small Mastodon bot
In his latest book, Die Känguru Rebellion, Marc-Uwe Kling tells us about an art project in which a website randomly selects titles from the German news platform Tagesschau and pairs them with a randomly selected teaser image. The resulting combinations may be irrelevant, funny, or even unsettling.
I liked the idea an thus I thought this might be a good point of a mastodon-bot.
The bot is hosted at
mastodon.social and toots every
hour. Due to the simple nature of the task I implemented the bot as shellscript
with the help of curl, awk and sed. As source for the titles and images I
use the RSS-feed. The script itself can then be started by cron.
#! bash
MYDIR=""
CRED_FILE="/credentials"
IMG="shuffleimg.jpg"
# Read credentials (strip CR/newline and leading/trailing space)
if [; then
fi
BASE_URL=
ACCESS_TOKEN=
if [ || [; then
fi
TOKEN=
RSS_URL='https://www.tagesschau.de/infoservices/alle-meldungen-100~rss2.xml'
title=
image=
resp=
# 2) extract media id (handles "id":123 or "id":"123")
# media_id=$(printf '%s' "$resp" | sed -n 's/.*"id"[[:space:]]*:[[:space:]]*"\?\([0-9][0-9]*\)"\?.*/\1/p' | head -n1)
media_id=
# 3) post status (multipart form to safely include text)
|| {
}
The source can be found at codeberg