From df24ee4e9e3c0e7bfe86bdcac2249476ab0f33b1 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Wed, 1 Feb 2017 20:41:35 +0100 Subject: [PATCH] Update Telegram.py Added FMS and ZVEI support --- plugins/Telegram/Telegram.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index c787405..0d890c8 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -113,11 +113,28 @@ def run(typ,freq,data): gcode_result = gcode.geocode(address) logging.debug("Send location via Telegram BOT API") bot.sendLocation('%s' % BOTChatIDAPIKey, gcode_result[0]['geometry']['location']['lat'], gcode_result[0]['geometry']['location']['lng'], disable_notification='true') - elif typ == "FMS": - logging.debug("FMS not supported yet") + logging.debug("Compose output from FMS-message") + # compose message content + output = timeHandler.curtime()+"\n"+data["fms"]+"\n"+data["description"]+"\n"+data["status"] + + # Initiate Telegram Bot + logging.debug("Initiate Telegram BOT") + bot = telegram.Bot(token='%s' % BOTTokenAPIKey) + # Send message to chat via Telegram BOT API + logging.debug("Send message to chat via Telegram BOT API") + bot.sendMessage('%s' % BOTChatIDAPIKey, output) elif typ == "ZVEI": - logging.debug("ZVEI not supported yet") + logging.debug("Compose output from ZVEI-message") + # compose message content + output = timeHandler.curtime()+"\n"+data["zvei"]+"\n"+data["description"] + + # Initiate Telegram Bot + logging.debug("Initiate Telegram BOT") + bot = telegram.Bot(token='%s' % BOTTokenAPIKey) + # Send message to chat via Telegram BOT API + logging.debug("Send message to chat via Telegram BOT API") + bot.sendMessage('%s' % BOTChatIDAPIKey, output) else: logging.warning("Invalid Typ: %s", typ) except Unauthorized: