39 lines
838 B
Bash
39 lines
838 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
|
|
|
|
albumtitle="$(echo "$data" | sed -n '1p')"
|
|
albumurl="$(echo "$data" | sed -n '2p')"
|
|
albumcover="$(echo "$data" | sed -n '3p')"
|
|
|
|
curl -H "Content-Type: application/json" -X POST -d "$(generate_post_data)" $discord_url
|