alert_ifttt.sh 1.2 KB

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # LinuxGSM alert_ifttt.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Sends IFTTT alert.
  7. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. json=$(cat <<EOF
  9. {
  10. "value1": "${selfname}",
  11. "value2": "${alertemoji} ${alerttitle} ${alertemoji}",
  12. "value3": "<b>Server name</b><br>${servername}<br><br><b>Trigger Message</b><br>${alerttriggermessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Map</b><br>${alertmap}<br><br><b>Current Players</b><br>${alertplayers}<br><br><b>Version</b><br>${alertversion}<br><br><b>Country</b><br>${country}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>More Info</b><br>${alertmoreinfourl}"
  13. }
  14. EOF
  15. )
  16. fn_print_dots "Sending IFTTT alert"
  17. iftttsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request")
  18. if [ -n "${iftttsend}" ]; then
  19. fn_print_fail_nl "Sending IFTTT alert: ${pushbulletsend}"
  20. fn_script_log_fatal "Sending IFTTT alert: ${pushbulletsend}"
  21. else
  22. fn_print_ok_nl "Sending IFTTT alert"
  23. fn_script_log_pass "Sent IFTTT alert"
  24. fi