diff options
author | Ali Borhani <aliborhani1@gmail.com> | 2017-04-08 15:58:43 +0430 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-08 15:58:43 +0430 |
commit | 208bf033af84ec16466a510e9ce71d6b5716b281 (patch) | |
tree | b14fee0e5cce9a8f72299374cb4c617c8aefd1b7 | |
parent | d6f10544d8755a280132ece47aff85f31760ce0e (diff) |
Add emoji for telegram notifications
- Warning: ⚠️
- Critical: 🔴
- Clear: ✅
- Other: ⚪️
-rwxr-xr-x | plugins.d/alarm-notify.sh | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins.d/alarm-notify.sh b/plugins.d/alarm-notify.sh index d0188fe3b1..b8d65c9b2b 100755 --- a/plugins.d/alarm-notify.sh +++ b/plugins.d/alarm-notify.sh @@ -939,9 +939,16 @@ send_messagebird() { # telegram sender send_telegram() { - local bottoken="${1}" chatids="${2}" message="${3}" httpcode sent=0 chatid disableNotification="" + local bottoken="${1}" chatids="${2}" message="${3}" httpcode sent=0 chatid emoji disableNotification="" if [ "${status}" = "CLEAR" ]; then disableNotification="--data-urlencode disable_notification=true"; fi + + case "${status}" in + WARNING) emoji="⚠️" ;; + CRITICAL) emoji="🔴" ;; + CLEAR) emoji="✅" ;; + *) emoji="⚪️" ;; + esac if [ "${SEND_TELEGRAM}" = "YES" -a ! -z "${bottoken}" -a ! -z "${chatids}" -a ! -z "${message}" ]; then @@ -951,7 +958,7 @@ send_telegram() { httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null ${disableNotification} \ --data-urlencode "parse_mode=HTML" \ --data-urlencode "disable_web_page_preview=true" \ - --data-urlencode "text=${message}" \ + --data-urlencode "text=${emoji} ${message}" \ "https://api.telegram.org/bot${bottoken}/sendMessage?chat_id=${chatid}") if [ "${httpcode}" == "200" ] |