Просмотр исходного кода

Added discord alert (dev)

still under developement
Daniel Gibbs 9 лет назад
Родитель
Сommit
d087f0ba3c

+ 4 - 0
lgsm/config-default/config-lgsm/arkserver/_default.cfg

@@ -34,6 +34,10 @@ pushbulletalert="off"
 pushbullettoken="accesstoken"
 pushbullettoken="accesstoken"
 channeltag=""
 channeltag=""
 
 
+# Discord Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Discord
+discordalert="off"
+discordwebhook="https://discordapp.com/api/webhooks/12345/abcd12345"
+
 ## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update
 ## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update
 updateonstart="off"
 updateonstart="off"
 
 

+ 11 - 1
lgsm/functions/alert.sh

@@ -67,4 +67,14 @@ elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test
 elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 	fn_print_error_nl "Pushbullet token not set"
 	fn_print_error_nl "Pushbullet token not set"
 	fn_script_error_warn "Pushbullet token not set"
 	fn_script_error_warn "Pushbullet token not set"
-fi
+fi
+
+if [ "${discordalert}" == "on" ]&&[ -n "${discordalert}" ]; then
+	alert_discord.sh
+elif [ "${discordalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
+	fn_print_warn_nl "Discord alerts not enabled"
+	fn_script_log_warn "Discord alerts not enabled"
+elif [ -z "${discordalert}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
+	fn_print_error_nl "Discord token not set"
+	fn_script_error_warn "Discord token not set"
+fi

+ 20 - 0
lgsm/functions/alert_discord.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+# LinuxGSM alert_discord.sh function
+# Author: Daniel Gibbs
+# Contributor: faflfama
+# Website: https://gameservermanagers.com
+# Description: Sends Discord alert including the server status.
+
+if [ "$1" == "" ]; then  echo "missing message"; exit; fi
+prefix='{"content":"'
+postfix='","file":"content","embed":"content"}'
+echo "$prefix $1 $postfix" >f
+curl -v -X POST --data @f "${discordwebhook}"
+
+#if [ "${discordsend}" == "invalid_access_token" ]; then
+#	fn_print_fail_nl "Sending Discord alert: invalid_access_token"
+#	fn_script_log_fatal "Sending Discord alert: invalid_access_token"
+#else
+#	fn_print_ok_nl "Sending Discord alert"
+#	fn_script_log_pass "Sent Discord alert"
+#fi