Skip to content

Instantly share code, notes, and snippets.

@ataliba
Last active April 26, 2017 17:07
Show Gist options
  • Save ataliba/95c9ee25cd33d24c07db9576663a1dd5 to your computer and use it in GitHub Desktop.
Save ataliba/95c9ee25cd33d24c07db9576663a1dd5 to your computer and use it in GitHub Desktop.
Simple Telegram bot Notification for Zabbix
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Ataliba Teixeira - https://github.com/ataliba
# Simple script to use on Zabbix Notification ( based on https://github.com/GabrielRF/Zabbix-Telegram-Notification )
#
import telebot,sys
# your bot token
BOT_TOKEN=''
DESTINATION=sys.argv[1]
SUBJECT=sys.argv[2]
MESSAGE=sys.argv[3]
emoji_map = {
"ok": "✅",
"problem": "❗",
"information": "ℹ️",
"warning": "⚠️",
"disaster": "❌",
"average": "💣",
"high": "🔥",
"hankey": "💩",
}
MESSAGE = MESSAGE.replace('/n','\n')
Subject_final = ''
# replace text with emojis
for k, v in emoji_map.iteritems():
if SUBJECT.lower().find(k) != -1:
emoji_str = v + ' ' + k.upper()
Subject_final = (SUBJECT.lower().replace(k,emoji_str)).upper()
tb = telebot.TeleBot(BOT_TOKEN)
tb.send_message(DESTINATION,Subject_final + '\n' + MESSAGE, disable_web_page_preview=True, parse_mode='HTML')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment