Added PrettyPrint config option

This commit is contained in:
Jeremy 2022-08-04 17:19:12 +12:00
parent f4bca1586d
commit 1fb436c53b

View file

@ -1,7 +1,7 @@
#!/usr/bin/env sh
# matrix-send: send a message to a Matrix room
version="1.0"
version="1.0.1"
###########################
#### Generic Functions ####
@ -106,6 +106,10 @@ NoCache () {
nocache="true"
}
PrettyPrint () {
prettyprint="true"
}
############################
#### Specific Functions ####
############################
@ -134,7 +138,10 @@ ClearCache () {
}
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
}
########################