Explorar el Código

Improvements the alert message

Daniel Gibbs hace 8 años
padre
commit
3041cb1086
Se han modificado 2 ficheros con 53 adiciones y 4 borrados
  1. 51 1
      lgsm/functions/alert_discord.sh
  2. 2 3
      lgsm/functions/alert_telegram.sh

+ 51 - 1
lgsm/functions/alert_discord.sh

@@ -5,4 +5,54 @@
 # Website: https://gameservermanagers.com
 # Description: Sends Discord alert including the server status.
 
-curl -X POST --data '{ "embeds": [{"title": "${alertsubject}", "url": "https://example.com", "description": "${alertbody}", "type": "link", "thumbnail": {"url": "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/master/images/logo/lgsm-square-184-dark.png"}}] }' -H "Content-Type: application/json" "${discordwebhook}"
+json=$(cat <<EOF
+{
+"username":"LinuxGSM",
+"avatar_url":"https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/master/images/logo/lgsm-dark-square-512.png",
+"file":"content",
+
+"embeds": [{
+	"color": "2067276",
+	"author": {"name": "${alertemoji} ${alertsubject} ${alertemoji}", "icon_url": "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/master/images/logo/lgsm-dark-square-512.png"},
+	"title": "",
+	"description": "",
+	"url": "",
+	"type": "content",
+	"thumbnail": {"url": "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/master/images/logo/lgsm-dark-square-512.png"},
+	"footer": {"text": "LinuxGSM", "icon_url": "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/master/images/logo/lgsm-dark-square-512.png"},
+	"fields": [
+			{
+				"name": "Alert Message",
+				"value": "${alertbody}"
+			},
+			{
+				"name": "Game",
+				"value": "${gamename}"
+			},
+			{
+				"name": "Server name",
+				"value": "${servername}"
+			},
+			{
+				"name": "Hostname",
+				"value": "${HOSTNAME}"
+			},
+			{
+				"name": "Server IP",
+				"value": "[${ip}:${port}](https://www.gametracker.com/server_info/${ip}:${port})"
+			},
+			{
+				"name": "More info",
+				"value": "${alerturl}"
+			}
+			]
+	}]
+}
+EOF
+)
+
+#curl -X POST --data "Content-Type: application/json" -X POST -d """${json}""" "${discordwebhook}"
+
+
+echo "$json" >f
+curl -v -X POST --data @f ${discordwebhook}

+ 2 - 3
lgsm/functions/alert_telegram.sh

@@ -13,13 +13,12 @@ json=$(cat <<EOF
 {
 	"chat_id": "${telegramchatid}",
 	"parse_mode": "HTML",
-	"text": "${alertemoji} <b>${alertsubject}</b> ${alertemoji}\n<b>Message:</b> ${alertbody}\n<b>Server name:</b> ${servername}\n<b>Hostname:</b> ${HOSTNAME}\n<b>More info:</b> <a href='${alerturl}'>${alerturl}</a>",
+	"text": "${alertemoji} <b>${alertsubject}</b> ${alertemoji}\n\n<b>Message</b>\n${alertbody}\n\n<b>Game</b>\n${gamename}\n\n<b>Server name</b>\n${servername}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>Server IP</b>\n<a href='https://www.gametracker.com/server_info/${ip}:${port}'>${ip}:${port}</a>\n\n<b>More info</b>\n<a href='${alerturl}'>${alerturl}</a>",
 	"disable_web_page_preview": "yes",
-}
 EOF
 )
 
-fn_print_dots "Sending Telegram Alert"
+fn_print_dots "Sending Telegram alert"
 sleep 0.5
 telegramsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.telegram.org/bot${telegramtoken}/sendMessage" | grep -Po '(?<="description":").*?(?=")'|uniq)