diff --git a/config/config.template.ini b/config/config.template.ini index a8f141c..d943faf 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -414,39 +414,39 @@ RICforLocationAPIKey = # This is your Google API key. # Required if you want to create a map based on location information received with the above RIC. GoogleAPIKey = - -# %FMS% = FMS Code -# %STATUS% = FMS Status -# %DIR% = Direction of the telegram (0/1) -# %DIRT% = Direction of the telegram (Text-String) -# %TSI% = Tactical Short Information (I-IV) -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -fms_message = %DATE% %TIME%: %FMS% - -# %ZVEI% = ZVEI 5-tone Code -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -zvei_message = %DATE% %TIME%: %ZVEI% - -# %RIC% = POCSAG RIC -# %FUNC% = POCSAG function/Subric (1-4) -# %FUNCCHAR% = POCSAG function/Subric als character (a-d) -# %MSG% = Message of the POCSAG telegram -# %BITRATE% = Bitrate of the POCSAG telegram -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -poc_message = %MSG% - + +# %FMS% = FMS Code +# %STATUS% = FMS Status +# %DIR% = Direction of the telegram (0/1) +# %DIRT% = Direction of the telegram (Text-String) +# %TSI% = Tactical Short Information (I-IV) +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +FMS_message = %DATE% %TIME%: %FMS% + +# %ZVEI% = ZVEI 5-tone Code +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +ZVEI_message = %DATE% %TIME%: %ZVEI% + +# %RIC% = POCSAG RIC +# %FUNC% = POCSAG function/Subric (1-4) +# %FUNCCHAR% = POCSAG function/Subric als character (a-d) +# %MSG% = Message of the POCSAG telegram +# %BITRATE% = Bitrate of the POCSAG telegram +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +POC_message = %MSG% + [yowsup] # number or chat-number who whants to become the news diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index 9cc3246..fc4acc7 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -18,7 +18,6 @@ from includes import globalVars # Global variables # Helper function, uncomment to use from includes.helper import wildcardHandler from includes.helper import configHandler -from includes.helper import timeHandler # local variables BOTTokenAPIKey = None @@ -79,11 +78,12 @@ def run(typ,freq,data): try: ########## User Plugin CODE ########## try: - if typ == "POC": - logging.debug("Compose output from POCSAG-message") + if typ in ("POC", "FMS", "ZVEI"): + logging.debug("Read format and compose output for %s-message" % typ) # compose message content - text = globalVars.config.get("Telegram","poc_message") + text = globalVars.config.get("Telegram", "%s_message" % typ) text = wildcardHandler.replaceWildcards(text, data) + # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") bot = telegram.Bot(token='%s' % BOTTokenAPIKey) @@ -92,7 +92,7 @@ def run(typ,freq,data): bot.sendMessage('%s' % BOTChatIDAPIKey, text) # Generate location information only for specific RIC - if data["ric"] == RICforLocationAPIKey: + if typ == "POC" and data["ric"] == RICforLocationAPIKey: # Generate map logging.debug("Extract address from POCSAG message") address = "+".join(data["msg"].split(')')[0].split('/',1)[1].replace('(',' ').split()) @@ -114,30 +114,6 @@ 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("Compose output from FMS-message") - # compose message content - text = globalVars.config.get("Telegram","fms_message") - text = wildcardHandler.replaceWildcards(text, data) - - # 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, text) - elif typ == "ZVEI": - logging.debug("Compose output from ZVEI-message") - # compose message content - text = globalVars.config.get("Telegram","zvei_message") - text = wildcardHandler.replaceWildcards(text, data) - - # 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, text) else: logging.warning("Invalid Typ: %s", typ) except Unauthorized: