Daniel Gibbs 8 лет назад
Родитель
Сommit
669117482e
3 измененных файлов с 36 добавлено и 1 удалено
  1. 10 1
      lgsm/functions/alert.sh
  2. 21 0
      lgsm/functions/alert_ifttt.sh
  3. 5 0
      lgsm/functions/core_functions.sh

+ 10 - 1
lgsm/functions/alert.sh

@@ -117,4 +117,13 @@ elif [ -z "${pushovertoken}" ]&&[ "${function_selfname}" == "command_test_alert.
 	fn_script_error_warn "Pushover token not set"
 fi
 
-
+if [ "${iftttalert}" == "on" ]&&[ -n "${iftttalert}" ]; then
+	alert_ifttt.sh
+elif [ "${iftttalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
+	fn_print_warn_nl "IFTTT alerts not enabled"
+	fn_script_log_warn "IFTTT alerts not enabled"
+elif [ -z "${ifttttoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
+	fn_print_error_nl "IFTTT token not set"
+	echo "	* https://github.com/GameServerManagers/LinuxGSM/wiki/IFTTT"
+	fn_script_error_warn "IFTTT token not set"
+fi

+ 21 - 0
lgsm/functions/alert_ifttt.sh

@@ -0,0 +1,21 @@
+#!/bin/bash
+# LinuxGSM alert_ifttt.sh function
+# Author: Daniel Gibbs
+# Website: https://gameservermanagers.com
+# Description: Sends IFTTT alert.
+
+local commandname="ALERT"
+local commandaction="Alert"
+local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+json=$(cat <<EOF
+{
+	"secret": "${pushjettoken}",
+	"level": "5",
+	"message": "all",
+	"link": "https://gameservermanagers.com"
+}
+EOF
+)
+
+curl -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://maker.ifttt.com/trigger/{event}/with/key/${ifttttoken}"

+ 5 - 0
lgsm/functions/core_functions.sh

@@ -402,6 +402,11 @@ functionfile="${FUNCNAME}"
 fn_fetch_function
 }
 
+alert_ifttt.sh(){
+functionfile="${FUNCNAME}"
+fn_fetch_function
+}
+
 # Logs
 
 logs.sh(){