From 6dba08196109cb88d3681ae2af5996864d00ec4e Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Fri, 14 Oct 2016 16:36:00 +0200 Subject: [PATCH 1/2] Update Telegram.py --- plugins/Telegram/Telegram.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index f200283..2673429 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -84,24 +84,23 @@ def run(typ,freq,data): # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") - bot = telegram.Bot(token='%s' % BOTTokenAPIKey) - + 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) # Generate location information only for specific RIC - if data["ric"] == RICforLocationAPIKey: + if data["ric"] == RICforLocationAPIKey: # Generate map logging.debug("Extract address from POCSAG message") address = "+".join(data["msg"].split(')')[0].split('/',1)[1].replace('(',' ').split()) - + logging.debug("Retrieve maps from Google") url = "+".join(["http://maps.googleapis.com/maps/api/staticmap?markers=", address, "&size=480x640&maptype=roadmap&zoom=16&key=", GoogleAPIKey]) urllib.urlretrieve(url, "overview_map.png") url = "+".join(["http://maps.googleapis.com/maps/api/staticmap?markers=", address, "&size=240x320&scale=2&maptype=hybrid&zoom=17&key=", GoogleAPIKey]) urllib.urlretrieve(url, "detail_map.png") - + # Send message and map with Telegram logging.debug("Send message and maps via Telegram BOT") bot.sendPhoto('%s' % BOTChatIDAPIKey, open('overview_map.png', 'rb'), disable_notification='true') From d58e8870921eff397402cbdf1c648dfd8b4171b4 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Sun, 16 Oct 2016 16:07:47 +0200 Subject: [PATCH 2/2] Update Telegram.py --- plugins/Telegram/Telegram.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index 2673429..e1e3ae4 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -73,7 +73,7 @@ def run(typ,freq,data): @return: nothing @exception: nothing, make sure this function will never thrown an exception """ - + try: ########## User Plugin CODE ########## try: @@ -81,10 +81,10 @@ def run(typ,freq,data): logging.debug("Compose output from POCSAG-message") # compose message content output = timeHandler.curtime()+"\n"+data["ric"]+"("+data["functionChar"]+")\n"+data["description"]+"\n"+data["msg"] - + # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") - bot = telegram.Bot(token='%s' % BOTTokenAPIKey) + 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) @@ -94,13 +94,13 @@ def run(typ,freq,data): # Generate map logging.debug("Extract address from POCSAG message") address = "+".join(data["msg"].split(')')[0].split('/',1)[1].replace('(',' ').split()) - + logging.debug("Retrieve maps from Google") url = "+".join(["http://maps.googleapis.com/maps/api/staticmap?markers=", address, "&size=480x640&maptype=roadmap&zoom=16&key=", GoogleAPIKey]) urllib.urlretrieve(url, "overview_map.png") url = "+".join(["http://maps.googleapis.com/maps/api/staticmap?markers=", address, "&size=240x320&scale=2&maptype=hybrid&zoom=17&key=", GoogleAPIKey]) urllib.urlretrieve(url, "detail_map.png") - + # Send message and map with Telegram logging.debug("Send message and maps via Telegram BOT") bot.sendPhoto('%s' % BOTChatIDAPIKey, open('overview_map.png', 'rb'), disable_notification='true')