{ lib , writers , curl , jq , homeserver , roomId , authToken }: writers.writeDashBin "notify" '' export PATH="$PATH:${lib.makeBinPath [ curl jq ]}" if test $(id -u) != 0; then echo 'you must be root to send a notice' exit 1 fi token=$(cat ${authToken}) url="${homeserver}/rooms/${roomId}/send/m.room.message?access_token=$token" if test $# -eq 1; then # send first arg as text msg=$(printf "%s" "$1" | jq -Rsc '{ "msgtype": "m.text", "body": . }') else # send stdin formatted as code msg=$(jq -Rsc '{ "msgtype": "m.text", "format": "org.matrix.custom.html", "body": "", "formatted_body": ("
" + . + "
")
}')
fi
curl -s "$url" -d "$msg"
''