mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-22 00:00:25 +01:00
read message-text from config
This commit is contained in:
parent
0694154d04
commit
4e1cf00cb3
|
|
@ -414,14 +414,47 @@ 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%
|
||||
|
||||
|
||||
[yowsup]
|
||||
# number or chat-number who whants to become the news
|
||||
empfaenger =
|
||||
empfaenger =
|
||||
# WhatsApp-number of that the news comes
|
||||
sender =
|
||||
sender =
|
||||
# password from this number
|
||||
password=
|
||||
password=
|
||||
|
||||
# %FMS% = FMS Code
|
||||
# %STATUS% = FMS Status
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from telegram.error import (TelegramError, Unauthorized, BadRequest, NetworkErro
|
|||
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
|
||||
|
||||
|
|
@ -81,14 +82,15 @@ def run(typ,freq,data):
|
|||
if typ == "POC":
|
||||
logging.debug("Compose output from POCSAG-message")
|
||||
# compose message content
|
||||
output = timeHandler.curtime()+"\n"+data["ric"]+"("+data["functionChar"]+")\n"+data["description"]+"\n"+data["msg"]
|
||||
text = globalVars.config.get("Telegram","poc_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, output)
|
||||
bot.sendMessage('%s' % BOTChatIDAPIKey, "text")
|
||||
|
||||
# Generate location information only for specific RIC
|
||||
if data["ric"] == RICforLocationAPIKey:
|
||||
|
|
@ -116,25 +118,27 @@ def run(typ,freq,data):
|
|||
elif typ == "FMS":
|
||||
logging.debug("Compose output from FMS-message")
|
||||
# compose message content
|
||||
output = timeHandler.curtime()+"\n"+data["fms"]+"\n"+data["description"]+"\n"+data["status"]
|
||||
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, output)
|
||||
bot.sendMessage('%s' % BOTChatIDAPIKey, "text")
|
||||
elif typ == "ZVEI":
|
||||
logging.debug("Compose output from ZVEI-message")
|
||||
# compose message content
|
||||
output = timeHandler.curtime()+"\n"+data["zvei"]+"\n"+data["description"]
|
||||
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, output)
|
||||
bot.sendMessage('%s' % BOTChatIDAPIKey, "text")
|
||||
else:
|
||||
logging.warning("Invalid Typ: %s", typ)
|
||||
except Unauthorized:
|
||||
|
|
|
|||
Loading…
Reference in a new issue