feat: dynamic embed colors

This commit is contained in:
ibo
2024-06-24 22:59:06 +02:00
committed by GitHub
parent 705f382802
commit c4dbaaf32a

View File

@@ -120,11 +120,20 @@ jobs:
avatar_url=$(echo "$user_details" | jq -r '.avatar_url')
echo "$name|$login|$avatar_url"
}
# Additional information for the goats
declare -A additional_info
additional_info["ibo"]="\n Discord: <@951737931159187457>\n AniList: [takarealist112](<https://anilist.co/user/takarealist112/>)"
additional_info["aayush262"]="\n Discord: <@918825160654598224>\n AniList: [aayush262](<https://anilist.co/user/aayush262/>)"
additional_info["rebelonion"]="\n Discord: <@714249925248024617>\n AniList: [rebelonion](<https://anilist.co/user/rebelonion/>)\n PornHub: [rebelonion](<https://www.cornhub.com/model/rebelonion>)"
additional_info["rebelonion"]="\n Discord: <@714249925248024617>\n AniList: [rebelonion](<https://anilist.co/user/rebelonion/>)\n PornHub: [rebelonion](<https://www.cornhub.com/model/rebelonion>)"
# Decimal color codes for contributors
declare -A contributor_colors
contributor_colors["ibo"]=16741632 # Hex: #ff7500
contributor_colors["aayush262"]=6121629 # Hex: #5d689d
contributor_colors["Sadwhy"]=16744085 # Hex: #ff7e95
contributor_colors["rebelonion"]=13952493 # Hex: #d4e5ed
default_color=16721401 # Hex: #ff25f9
# Count recent commits and create an associative array
declare -A recent_commit_counts
@@ -150,6 +159,7 @@ jobs:
top_contributor=""
top_contributor_count=0
top_contributor_avatar=""
embed_color=$default_color
# Process contributors in the new order
while read -r login; do
@@ -164,11 +174,14 @@ jobs:
# Update top contributor information
if [ $commit_count -gt $max_commits ]; then
max_commits=$commit_count
top_contributor="$login"
top_contributors=("$login")
top_contributor_count=1
top_contributor_avatar="$avatar_url"
embed_color=${contributor_colors[$login]:-$default_color}
elif [ $commit_count -eq $max_commits ]; then
top_contributors+=("$login")
top_contributor_count=$((top_contributor_count + 1))
embed_color=$default_color
fi
# Get commit count for this contributor on the dev branch
@@ -191,16 +204,16 @@ jobs:
else
developers="${developer_entry}"
fi
committers_count=$((committers_count + 1))
fi
done <<< "$sorted_contributors"
# Set the thumbnail URL based on top contributor(s)
# Set the thumbnail URL and color based on top contributor(s)
if [ $top_contributor_count -eq 1 ]; then
thumbnail_url="$top_contributor_avatar"
else
thumbnail_url="https://i.imgur.com/5o3Y9Jb.gif"
embed_color=$default_color
fi
# Truncate field values
@@ -220,12 +233,13 @@ jobs:
--arg footer_text "Version $VERSION" \
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \
--arg thumbnail_url "$thumbnail_url" \
--argjson embed_color "$embed_color" \
'{
"content": "<@&1225347048321191996>",
"embeds": [
{
"title": "New Alpha-Build dropped",
"color": 15532323,
"color": $embed_color,
"fields": [
{
"name": "Commits:",