32 lines
No EOL
789 B
Bash
32 lines
No EOL
789 B
Bash
#!/bin/sh
|
|
# 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=""
|
|
|
|
data="$($lapath)"
|
|
if [ -z "$data" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
payload=$(echo "$data" | paste -d '\t' - - - | head -n10 | jq -Rn --arg msg "$message" --argjson color "$embed_color" '
|
|
{
|
|
content: $msg,
|
|
embeds: [
|
|
inputs
|
|
| split("\t")
|
|
| {
|
|
title: .[0],
|
|
description: .[1],
|
|
color: $color,
|
|
thumbnail: { url: .[2] }
|
|
}
|
|
]
|
|
}
|
|
')
|
|
|
|
curl -H "Content-Type: application/json" -X POST -d "$payload" "$discord_url" |