Update stdin2discord.bash
All checks were successful
Push commit / report (push) Successful in 6s

This commit is contained in:
a31 2023-11-18 23:12:18 +03:00
parent 54701da1d9
commit bff7d0ec1e

View File

@ -1,29 +1,30 @@
#!/bin/bash
set -e
send() {
local _msg=$1
if [[ -z $_msg ]]; then
return
fi
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"content\":\"\`\`\`diff\n$_msg\`\`\`\"}" \
"$DISCORD_WEBHOOK"
}
msg=""
while IFS= read -r line; do
line="$(sed 's@"@\\"@g' <<< "$line")" # Json screening
len="$(wc -m <<< "$msg$line")"
if [[ $len -ge 1985 ]]; then
send "$msg"
msg="$line"
else
msg+="$line\\n"
fi
done
send "$msg"
#!/bin/bash
set -e
set -x
send() {
local _msg=$1
if [[ -z $_msg ]]; then
return
fi
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"content\":\"\`\`\`diff\n$_msg\`\`\`\"}" \
"$DISCORD_WEBHOOK"
}
msg=""
while IFS= read -r line; do
line="$(sed 's@"@\\"@g' <<< "$line")" # Json screening
len="$(wc -m <<< "$msg$line")"
if [[ $len -ge 1985 ]]; then
send "$msg"
msg="$line"
else
msg+="$line\\n"
fi
done
send "$msg"