diff --git a/stdin2discord.bash b/stdin2discord.bash index 3c04fb1..1a7b5ca 100644 --- a/stdin2discord.bash +++ b/stdin2discord.bash @@ -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