38 lines
874 B
Bash
38 lines
874 B
Bash
#!/bin/sh
|
|
|
|
# Settings
|
|
# Discord Webhook URL (e.g. https://discord.com/api/webhooks/WEBHOOK_ID/TOKEN)
|
|
discord_url=""
|
|
# Message content (e.g. :newspaper: @everyone A new album has been added!"
|
|
message=""
|
|
# Embed color (e.g. 45973)
|
|
embed_color=""
|
|
# latestalbum path (for cron job, e.g. /home/amolinae/.local/bin/latestalbum)
|
|
lapath=""
|
|
|
|
generate_post_data() {
|
|
cat <<EOF
|
|
{
|
|
"content": "$message",
|
|
"embeds": [{
|
|
"title": "$albumtitle",
|
|
"description": "$albumurl",
|
|
"color": "$embed_color",
|
|
"thumbnail": {
|
|
"url": "$albumcover"
|
|
}
|
|
}]
|
|
}
|
|
EOF
|
|
}
|
|
|
|
data="$($lapath)"
|
|
|
|
if [ -z "$data" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
echo "$data" | paste -d '\t' - - - | while IFS=$'\t' read -r albumtitle albumurl albumcover; do
|
|
payload=$(generate_post_data "$albumtitle" "$albumurl" "$albumcover")
|
|
curl -H "Content-Type: application/json" -X POST -d "$payload" "$discord_url"
|
|
done
|