Added PrettyPrint config option

This commit is contained in:
Jeremy Baxter 2022-08-04 17:19:12 +12:00
parent 6f021541d2
commit 24daab1834

View file

@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# matrix-send: send a message to a Matrix room # matrix-send: send a message to a Matrix room
version="1.0" version="1.0.1"
########################### ###########################
#### Generic Functions #### #### Generic Functions ####
@ -106,6 +106,10 @@ NoCache () {
nocache="true" nocache="true"
} }
PrettyPrint () {
prettyprint="true"
}
############################ ############################
#### Specific Functions #### #### Specific Functions ####
############################ ############################
@ -134,7 +138,10 @@ ClearCache () {
} }
Send () { Send () {
curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" if [ -z "$prettyprint" ]
then curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token"
else curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"$mtype"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token" | jq
fi
} }
######################## ########################