#!/bin/bash # LinuxGSM alert_matrix.sh module # Contributors: http://linuxgsm.com/contrib # Website: https://linuxgsm.com # Description: Sends Matrix alert. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" json=$(cat <${alertemoji} ${alertsubject} ${alertemoji}

\n

Server name

${servername}

\n

Message

${alertbody}

\n

Game

${gamename}

\n

Server IP

${alertip}:${port}

\n

Hostname

${HOSTNAME}

\n

More info

${alerturl}" } EOF ) fn_print_dots "Sending Matrix alert" matrixsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://${matrixhomeserver}/_matrix/client/r0/rooms/${matrixroom}/send/m.room.message?access_token=${matrixtoken}" | grep "error") if [ -n "${matrixsend}" ]; then fn_print_fail_nl "Sending Matrix alert: ${matrixsend}" fn_script_log_fatal "Sending Matrix alert: ${matrixsend}" else fn_print_ok_nl "Sending Matrix alert" fn_script_log_pass "Sent Matrix alert" fi