send multiple albums in one message
This commit is contained in:
parent
0e4fad2010
commit
6f30973cbd
1 changed files with 17 additions and 23 deletions
38
webhook
38
webhook
|
@ -1,6 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Settings
|
|
||||||
# Discord Webhook URL (e.g. https://discord.com/api/webhooks/WEBHOOK_ID/TOKEN)
|
# Discord Webhook URL (e.g. https://discord.com/api/webhooks/WEBHOOK_ID/TOKEN)
|
||||||
discord_url=""
|
discord_url=""
|
||||||
# Message content (e.g. :newspaper: @everyone A new album has been added!"
|
# Message content (e.g. :newspaper: @everyone A new album has been added!"
|
||||||
|
@ -10,29 +8,25 @@ embed_color=""
|
||||||
# latestalbum path (for cron job, e.g. /home/amolinae/.local/bin/latestalbum)
|
# latestalbum path (for cron job, e.g. /home/amolinae/.local/bin/latestalbum)
|
||||||
lapath=""
|
lapath=""
|
||||||
|
|
||||||
generate_post_data() {
|
|
||||||
cat <<EOF
|
|
||||||
{
|
|
||||||
"content": "$message",
|
|
||||||
"embeds": [{
|
|
||||||
"title": "$albumtitle",
|
|
||||||
"description": "$albumurl",
|
|
||||||
"color": "$embed_color",
|
|
||||||
"thumbnail": {
|
|
||||||
"url": "$albumcover"
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
data="$($lapath)"
|
data="$($lapath)"
|
||||||
|
|
||||||
if [ -z "$data" ]; then
|
if [ -z "$data" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$data" | paste -d '\t' - - - | while IFS=$'\t' read -r albumtitle albumurl albumcover; do
|
payload=$(echo "$data" | paste -d '\t' - - - | head -n10 | jq -Rn --arg msg "$message" --argjson color "$embed_color" '
|
||||||
payload=$(generate_post_data "$albumtitle" "$albumurl" "$albumcover")
|
{
|
||||||
|
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"
|
curl -H "Content-Type: application/json" -X POST -d "$payload" "$discord_url"
|
||||||
done
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue