Browse Source

Add configuration to format matrix messages as html

master
Drew Short 4 years ago
parent
commit
ac518353a9
  1. 1
      README.md
  2. 5
      bin/out

1
README.md

@ -53,6 +53,7 @@ Send message to specified Matrix Room, with the configured parameters
* `text`: (string) Text to send to the Matrix room as the content.body.
* `text_file`: (string) File containing text to send to the Matrix room as the content.body.
* `msgtype`: *Optional.* Message type, m.notice, m.text (default: m.notice)
* `is_html`: *Optional.* Indicate that the input is formatted as html
* `data_file`: *Optional.* (string) Filename to post using a custom_event message type. If unset, defaults to the data_file on the resource. If it exists, the file must contain valid JSON.
* `trigger`: *Optional.* (string) Arbitrary test to add to a "trigger" data item on custom message types.
* `always_notify`: If true, send a notice even if text_file and data_file are empty. If false, and a text_file is specified but empty, a notification will not be sent.

5
bin/out

@ -23,6 +23,7 @@ matrix_server_url="$(jq -r '.source.matrix_server_url' < "${payload}")"
token="$(jq -r '.source.token' < "${payload}")"
room_id="$(jq -r '.source.room_id' < "${payload}")"
msgtype="$(jq -r '.source.msgtype // "m.notice"' < "${payload}")"
is_html="$(jq -r '.source.is_html // "false"' < "${payload}")"
data_file="$(jq -r '.source.data_file // ""' < "${payload}")"
ts="$(date +%s)"
@ -73,6 +74,10 @@ then
text=$(echo -n "${text}" | jq -R -s .)
[ -n "${formatted_body}" ] && formatted_body=$(echo -n "${formatted_body}" | jq -R -s .)
if [[ "${is_html}" = "true" ]]; then
formatted_body="${text}"
fi
[[ "${token}" != "null" ]] && username=$(echo "$token" | envsubst | jq -R -s .)
[[ "${room_id}" != "null" ]] && room_id=$(echo "$room_id" | envsubst | jq -R -s .)
body="$(cat <<EOF

Loading…
Cancel
Save