mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2025-12-06 07:42:03 +01:00
parent
dfad66783e
commit
84d39d0686
|
|
@ -18,7 +18,6 @@ from includes import globalVars # Global variables
|
||||||
# Helper function, uncomment to use
|
# Helper function, uncomment to use
|
||||||
from includes.helper import wildcardHandler
|
from includes.helper import wildcardHandler
|
||||||
from includes.helper import configHandler
|
from includes.helper import configHandler
|
||||||
from includes.helper import timeHandler
|
|
||||||
|
|
||||||
# local variables
|
# local variables
|
||||||
BOTTokenAPIKey = None
|
BOTTokenAPIKey = None
|
||||||
|
|
@ -79,11 +78,12 @@ def run(typ,freq,data):
|
||||||
try:
|
try:
|
||||||
########## User Plugin CODE ##########
|
########## User Plugin CODE ##########
|
||||||
try:
|
try:
|
||||||
if typ == "POC":
|
if typ in ("POC", "FMS", "ZVEI"):
|
||||||
logging.debug("Compose output from POCSAG-message")
|
logging.debug("Read format and compose output for %s-message" % typ)
|
||||||
# compose message content
|
# compose message content
|
||||||
text = globalVars.config.get("Telegram","poc_message")
|
text = globalVars.config.get("Telegram", "%s_message" % typ)
|
||||||
text = wildcardHandler.replaceWildcards(text, data, lineBrakeAllowed=True)
|
text = wildcardHandler.replaceWildcards(text, data)
|
||||||
|
|
||||||
# Initiate Telegram Bot
|
# Initiate Telegram Bot
|
||||||
logging.debug("Initiate Telegram BOT")
|
logging.debug("Initiate Telegram BOT")
|
||||||
bot = telegram.Bot(token='%s' % BOTTokenAPIKey)
|
bot = telegram.Bot(token='%s' % BOTTokenAPIKey)
|
||||||
|
|
@ -92,7 +92,7 @@ def run(typ,freq,data):
|
||||||
bot.sendMessage('%s' % BOTChatIDAPIKey, text)
|
bot.sendMessage('%s' % BOTChatIDAPIKey, text)
|
||||||
|
|
||||||
# Generate location information only for specific RIC
|
# Generate location information only for specific RIC
|
||||||
if data["ric"] == RICforLocationAPIKey:
|
if typ == "POC" and data["ric"] == RICforLocationAPIKey:
|
||||||
# Generate map
|
# Generate map
|
||||||
logging.debug("Extract address from POCSAG message")
|
logging.debug("Extract address from POCSAG message")
|
||||||
address = "+".join(data["msg"].split(')')[0].split('/',1)[1].replace('(',' ').split())
|
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)
|
gcode_result = gcode.geocode(address)
|
||||||
logging.debug("Send location via Telegram BOT API")
|
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')
|
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, lineBrakeAllowed=True)
|
|
||||||
|
|
||||||
# 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, lineBrakeAllowed=True)
|
|
||||||
|
|
||||||
# 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:
|
else:
|
||||||
logging.warning("Invalid Typ: %s", typ)
|
logging.warning("Invalid Typ: %s", typ)
|
||||||
except Unauthorized:
|
except Unauthorized:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue