fix stdin2discord.bash screening problems, msg len measurement
Some checks failed
Push commit / report (push) Failing after 6s
Some checks failed
Push commit / report (push) Failing after 6s
This commit is contained in:
parent
0cd83fae0a
commit
f735d660dc
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user