mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-20 15:20:16 +01:00
Merge pull request #277 from PeterLaemmle/develop
Update of Telegram plugin
This commit is contained in:
commit
3ce29711a1
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue