Compare commits

...
1 Commits
15 ... 16
Author SHA1 Message Date
nezumi 88a00ca413 update config 2025-01-22 19:41:27 +07:00
+16 -10
View File
@@ -184,20 +184,26 @@ jobs:
# Function to split messages properly by ensuring correct Markdown formatting # Function to split messages properly by ensuring correct Markdown formatting
send_discord_message() { send_discord_message() {
local message="$1" local message="$1"
local chunk=""
local remainder="$message"
while [ ${#remainder} -gt 0 ]; do while [ ${#message} -gt 0 ]; do
# Try to split at the last newline within the 2000-character limit # Attempt to find a safe split point within 2000 characters
chunk="${remainder:0:2000}" local chunk="${message:0:2000}"
local cutoff=$(echo "$chunk" | awk 'END {print length($0) - length($NF)}') # Find last space/newline local cutoff=$(echo "$chunk" | awk '{print length($0) - length($NF)}') # Find last space/newline within chunk
if [ "$cutoff" -lt 2000 ]; then
chunk="${remainder:0:$cutoff}" # Safe chunk if [ $cutoff -gt 0 ] && [ $cutoff -lt 2000 ]; then
remainder="${remainder:$cutoff}" # Remaining text # Use safe cutoff point if available
chunk="${message:0:$cutoff}"
message="${message:$cutoff}"
else else
remainder="${remainder:2000}" # Fallback to default split # Default to cutting at the 2000-character limit
chunk="${message:0:2000}"
message="${message:2000}"
fi fi
# Remove leading/trailing whitespace in the chunk and message
chunk=$(echo "$chunk" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
message=$(echo "$message" | sed 's/^[[:space:]]*//')
# Send the chunk to Discord # Send the chunk to Discord
curl -X POST -H "Content-Type: application/json" \ curl -X POST -H "Content-Type: application/json" \
-d "$(jq -n --arg content "$chunk" '{content: $content}')" \ -d "$(jq -n --arg content "$chunk" '{content: $content}')" \