diff --git a/lgsm/modules/alert_pushbullet.sh b/lgsm/modules/alert_pushbullet.sh index d6e975f586..7a6549762d 100644 --- a/lgsm/modules/alert_pushbullet.sh +++ b/lgsm/modules/alert_pushbullet.sh @@ -36,7 +36,6 @@ else fi fn_print_dots "Sending Pushbullet alert" - pushbulletsend=$(curl --connect-timeout 10 -sSL -H "Access-Token: ${pushbullettoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://api.pushbullet.com/v2/pushes" | grep "error_code") if [ -n "${pushbulletsend}" ]; then diff --git a/lgsm/modules/alert_slack.sh b/lgsm/modules/alert_slack.sh index d3af9814b3..d192e4cd4d 100644 --- a/lgsm/modules/alert_slack.sh +++ b/lgsm/modules/alert_slack.sh @@ -10,54 +10,68 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" json=$( cat << EOF { - "attachments": [ - { - "color": "#36a64f", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*LinuxGSM Alert*" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*${alertemoji} ${alerttitle}* \n ${alertmessage}" - } - }, - { - "type": "divider" - }, - { - "type": "section", - "fields": [ - { - "type": "mrkdwn", - "text": "*Game:* \n ${gamename}" - }, - { - "type": "mrkdwn", - "text": "*Server IP:* \n ${alertip}:${port}" - }, - { - "type": "mrkdwn", - "text": "*Server Name:* \n ${servername}" - } - ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "Hostname: ${HOSTNAME} / More info: ${alerturl}" - } - } - ] - } - ] + "attachments": [ + { + "color": "${alertcolourhex}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "${alerttitle}", + "emoji": true + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Game*\n${gamename}" + }, + { + "type": "mrkdwn", + "text": "*Server IP*\n\`${alertip}:${port}\`" + }, + { + "type": "mrkdwn", + "text": "*Hostname*\n${HOSTNAME}" + } + ], + "accessory": { + "type": "image", + "image_url": "${alerticon}", + "alt_text": "cute cat" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Information*\n${alertmessage}" + } + }, + { + "type": "context", + "elements": [ + { + "type": "image", + "image_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", + "alt_text": "LinuxGSM icon" + }, + { + "type": "plain_text", + "text": "Sent by LinuxGSM ${version}", + "emoji": true + } + ] + } + ] + } + ] } EOF ) diff --git a/lgsm/modules/alert_telegram.sh b/lgsm/modules/alert_telegram.sh index 6107cf47a9..085c1d8f4a 100644 --- a/lgsm/modules/alert_telegram.sh +++ b/lgsm/modules/alert_telegram.sh @@ -7,17 +7,34 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -json=$( +jsoninfo=$( cat << EOF { "chat_id": "${telegramchatid}", "parse_mode": "HTML", - "text": "${alertemoji} ${alerttitle} ${alertemoji}\n\nServer name\n${servername}\n\nMessage\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}", + "text": "${alerttitle}\n\nServer name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}", "disable_web_page_preview": "yes" } EOF ) +jsonnoinfo=$( + cat << EOF +{ + "chat_id": "${telegramchatid}", + "parse_mode": "HTML", + "text": "${alerttitle}\n\nServer name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}", + "disable_web_page_preview": "yes" +} +EOF +) + +if [ -z "${alerturl}" ]; then + json="${jsonnoinfo}" +else + json="${jsoninfo}" +fi + fn_print_dots "Sending Telegram alert" telegramsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" ${curlcustomstring} "https://${telegramapi}/bot${telegramtoken}/sendMessage" | grep "error_code")