discord*.sh will now break chunks at nearest newline, when input is large.
This commit is contained in:
@@ -18,6 +18,15 @@ EXTRA="${MESSAGE:1800}"
|
||||
|
||||
if [ -n "${EXTRA}" ]; then
|
||||
MESSAGE="${MESSAGE:0:1800}"
|
||||
|
||||
# as an added elegance, when spliting into pieces, find the last \n newline,
|
||||
# and break there instead, but only if the new smaller chunk is of sufficient size
|
||||
chunk1=`echo "$MESSAGE" | head -n -1`
|
||||
chunks=`echo "$MESSAGE" | tail -n 1`
|
||||
if (( "${#chunk1}" >= 1000 )); then
|
||||
MESSAGE="$chunk1"
|
||||
EXTRA="${chunks}${EXTRA}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# sed: rewrite json string, because "\u001b[m" needs to "\u001b[0m" instead
|
||||
|
||||
+10
@@ -14,8 +14,18 @@ EXTRA="${MESSAGE:1800}"
|
||||
|
||||
if [ -n "${EXTRA}" ]; then
|
||||
MESSAGE="${MESSAGE:0:1800}"
|
||||
|
||||
# as an added elegance, when spliting into pieces, find the last \n newline,
|
||||
# and break there instead, but only if the new smaller chunk is of sufficient size
|
||||
chunk1=`echo "$MESSAGE" | head -n -1`
|
||||
chunks=`echo "$MESSAGE" | tail -n 1`
|
||||
if (( "${#chunk1}" >= 1000 )); then
|
||||
MESSAGE="$chunk1"
|
||||
EXTRA="${chunks}${EXTRA}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# sed: rewrite json string, because "\u001b[m" needs to "\u001b[0m" instead
|
||||
# linux is fine with the missing zero, but discord needs it
|
||||
MESSAGE=`echo "${MESSAGE}" | jq -aRs . | sed 's/\\\\u001b\[m/\\\\u001b[0m/g'`
|
||||
|
||||
Reference in New Issue
Block a user