mirror of
https://github.com/Nezumi-2711/revanced-apk-build.git
synced 2026-09-23 04:19:49 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88a00ca413 | ||
|
|
788b36f083 | ||
|
|
ae43197aa0 |
+23
-17
@@ -181,28 +181,34 @@ jobs:
|
|||||||
${APKS}
|
${APKS}
|
||||||
"
|
"
|
||||||
|
|
||||||
# Function to split messages by line and send them
|
# Function to split messages properly by ensuring correct Markdown formatting
|
||||||
send_discord_message() {
|
send_discord_message() {
|
||||||
local message="$1"
|
local message="$1"
|
||||||
local buffer=""
|
|
||||||
while IFS= read -r line || [ -n "$line" ]; do
|
|
||||||
# Check if adding the current line exceeds 2000 characters
|
|
||||||
if [ ${#buffer} -ge 2000 ]; then
|
|
||||||
# Send the current buffer and reset it
|
|
||||||
curl -X POST -H "Content-Type: application/json" \
|
|
||||||
-d "$(jq -n --arg content "$buffer" '{content: $content}')" \
|
|
||||||
"$DISCORD_WEBHOOK_URL"
|
|
||||||
buffer=""
|
|
||||||
fi
|
|
||||||
buffer+="$line\n"
|
|
||||||
done <<< "$message"
|
|
||||||
|
|
||||||
# Send any remaining content in the buffer
|
while [ ${#message} -gt 0 ]; do
|
||||||
if [ -n "$buffer" ]; then
|
# Attempt to find a safe split point within 2000 characters
|
||||||
|
local chunk="${message:0:2000}"
|
||||||
|
local cutoff=$(echo "$chunk" | awk '{print length($0) - length($NF)}') # Find last space/newline within chunk
|
||||||
|
|
||||||
|
if [ $cutoff -gt 0 ] && [ $cutoff -lt 2000 ]; then
|
||||||
|
# Use safe cutoff point if available
|
||||||
|
chunk="${message:0:$cutoff}"
|
||||||
|
message="${message:$cutoff}"
|
||||||
|
else
|
||||||
|
# Default to cutting at the 2000-character limit
|
||||||
|
chunk="${message:0:2000}"
|
||||||
|
message="${message:2000}"
|
||||||
|
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
|
||||||
curl -X POST -H "Content-Type: application/json" \
|
curl -X POST -H "Content-Type: application/json" \
|
||||||
-d "$(jq -n --arg content "$buffer" '{content: $content}')" \
|
-d "$(jq -n --arg content "$chunk" '{content: $content}')" \
|
||||||
"$DISCORD_WEBHOOK_URL"
|
"$DISCORD_WEBHOOK_URL"
|
||||||
fi
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
send_discord_message "$MSG"
|
send_discord_message "$MSG"
|
||||||
|
|||||||
Reference in New Issue
Block a user