fix stdin2discord.bash screening problems, msg len measurement
Some checks failed
Push commit / report (push) Failing after 6s

This commit is contained in:
norohind 2023-10-20 20:17:32 +03:00
parent 0cd83fae0a
commit f735d660dc
Signed by: norohind
GPG Key ID: 01C3BECC26FB59E1

View File

@ -9,18 +9,20 @@ send() {
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"content\":\"$_msg\"}" \
-d "{\"content\":\"\`\`\`diff\n$_msg\`\`\`\"}" \
"$DISCORD_WEBHOOK"
}
msg=""
while IFS= read -r line; do
if [[ ${#msg}${#line} -ge 2000 ]]; then
line="$(sed 's@"@\\"@g' <<< "$line")" # Json screening
len="$(wc -m <<< "$msg$line")"
if [[ $len -ge 1985 ]]; then
send "$msg"
msg=""
msg="$line"
else
msg+="$line"
msg+="$line\\n"
fi
done