From f7905f675911dcf58ab8e81791cad8aa8ac40c8b Mon Sep 17 00:00:00 2001 From: fwmarcel Date: Sat, 29 Oct 2016 15:36:19 +0200 Subject: [PATCH 1/5] yowsup added --- config/config.template.ini | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/config/config.template.ini b/config/config.template.ini index fd55584..aa5f763 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -399,6 +399,46 @@ RICforLocationAPIKey = # Required if you want to create a map based on location information received with the above RIC. GoogleAPIKey = +[yowsup] +# number or chat-number who whants to become the news +empfaenger = +# WhatsApp-number of that the news comes +sender = +# password from this number +password= + +# %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% = Pocsac function/Subric (1-4) +# %FUNCCHAR% = Pocsac 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% + ##################### ##### Not ready yet # From e6144a367f31174bc23849899393d9ca1e1d930f Mon Sep 17 00:00:00 2001 From: fwmarcel Date: Sat, 29 Oct 2016 15:46:36 +0200 Subject: [PATCH 2/5] yowsup added --- plugins/yowsup/yowsup.py | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 plugins/yowsup/yowsup.py diff --git a/plugins/yowsup/yowsup.py b/plugins/yowsup/yowsup.py new file mode 100644 index 0000000..fd63e47 --- /dev/null +++ b/plugins/yowsup/yowsup.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +# -*- coding: cp1252 -*- + +""" +Yowsup-Plugin to dispatch POCSAG - messages to WhatsApp Numbers or Chats + +@author: fwmarcel + +@requires: yowsup2 has to be installed + whatsapp number and password + yowsup-Configuration has to be set in the config.ini +""" + +import logging +import subprocess +import shlex +import os + +from includes import globalVars + +from includes.helper import timeHandler +from includes.helper import wildcardHandler +from includes.helper import configHandler + + +def onLoad(): + return + +def run(typ,freq,data): + try: + if configHandler.checkConfig("yowsup"): + + empfaenger = globalVars.config.get("yowsup", "empfaenger") + sender = globalVars.config.get("yowsup", "sender") + password = globalVars.config.get("yowsup", "password") + devnull = open(os.devnull, "wb") + + if typ == "FMS": + text = globalVars.config.get("yowsup","fms_message") + text = wildcardHandler.replaceWildcards(text, data) + cmd = 'yowsup-cli demos -l ' + sender + ':' + password + ' -s ' + empfaenger + ' "' + text + '" -M' + subprocess.call(shlex.split(cmd)) + logging.debug("Message has been sent") + elif typ == "ZVEI": + text = globalVars.config.get("yowsup","zvei_message") + text = wildcardHandler.replaceWildcards(text, data) + cmd = 'yowsup-cli demos -l ' + sender + ':' + password + ' -s ' + empfaenger + ' "' + text + '" -M' + subprocess.call(shlex.split(cmd)) + logging.debug("Message has been sent") + elif typ == "POC": + try: + text = globalVars.config.get("yowsup","poc_message") + text = wildcardHandler.replaceWildcards(text, data) + cmd = 'yowsup-cli demos -l ' + sender + ':' + password + ' -s ' + empfaenger + ' "' + text + '" -M' + subprocess.call(shlex.split(cmd), stdout=devnull, stderr=devnull) + logging.debug("Message has been sent") + except: + logging.error("Message not send") + logging.debug("Message not send") + return + else: + logging.warning("Invalid Typ: %s", typ) + + except: + logging.error("unknown error") + logging.debug("unknown error", exc_info=True) From 5567ab3c062b67ff6f3822447d7e2ad293a87deb Mon Sep 17 00:00:00 2001 From: fwmarcel Date: Sat, 29 Oct 2016 15:47:35 +0200 Subject: [PATCH 3/5] FMS and ZVEI added --- plugins/yowsup/yowsup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/yowsup/yowsup.py b/plugins/yowsup/yowsup.py index fd63e47..b6841aa 100644 --- a/plugins/yowsup/yowsup.py +++ b/plugins/yowsup/yowsup.py @@ -39,13 +39,13 @@ def run(typ,freq,data): text = globalVars.config.get("yowsup","fms_message") text = wildcardHandler.replaceWildcards(text, data) cmd = 'yowsup-cli demos -l ' + sender + ':' + password + ' -s ' + empfaenger + ' "' + text + '" -M' - subprocess.call(shlex.split(cmd)) + subprocess.call(shlex.split(cmd), stdout=devnull, stderr=devnull) logging.debug("Message has been sent") elif typ == "ZVEI": text = globalVars.config.get("yowsup","zvei_message") text = wildcardHandler.replaceWildcards(text, data) cmd = 'yowsup-cli demos -l ' + sender + ':' + password + ' -s ' + empfaenger + ' "' + text + '" -M' - subprocess.call(shlex.split(cmd)) + subprocess.call(shlex.split(cmd), stdout=devnull, stderr=devnull) logging.debug("Message has been sent") elif typ == "POC": try: From cd80d7760d2b6571d4bf59ebd41fa2324cbbd80e Mon Sep 17 00:00:00 2001 From: flothi Date: Mon, 31 Oct 2016 21:30:04 +0100 Subject: [PATCH 4/5] Update boswatch.sql Adapting table 'poc' to script and changed the letter 'k' to 'c' in function. --- plugins/MySQL/boswatch.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/MySQL/boswatch.sql b/plugins/MySQL/boswatch.sql index e3b0675..37a84c3 100644 --- a/plugins/MySQL/boswatch.sql +++ b/plugins/MySQL/boswatch.sql @@ -65,8 +65,8 @@ CREATE TABLE IF NOT EXISTS `bos_pocsag` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `time` DATETIME NOT NULL, `ric` VARCHAR(7) NOT NULL DEFAULT '0', - `funktion` INT(1) NOT NULL, - `funktionChar` TEXT(1) NOT NULL, + `function` INT(1) NOT NULL, + `functionChar` TEXT(1) NOT NULL, `msg` TEXT NOT NULL, `bitrate` INT(4) NOT NULL, `description` TEXT NOT NULL, From cf3ae2d6dcfab55341980b8fce92be95d133394c Mon Sep 17 00:00:00 2001 From: flothi Date: Mon, 31 Oct 2016 23:16:18 +0100 Subject: [PATCH 5/5] Update boswatch.sql Add error-handling: Rename existing columns from old versions to new (correct) spelling. --- plugins/MySQL/boswatch.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/MySQL/boswatch.sql b/plugins/MySQL/boswatch.sql index 37a84c3..78e30eb 100644 --- a/plugins/MySQL/boswatch.sql +++ b/plugins/MySQL/boswatch.sql @@ -73,6 +73,10 @@ CREATE TABLE IF NOT EXISTS `bos_pocsag` ( PRIMARY KEY (`ID`) ) ENGINE=MYISAM DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1; +-- rename old columns including little error-prevention +ALTER IGNORE TABLE `bos_pocsag` change `funktion` `function` INT(1); +ALTER IGNORE TABLE `bos_pocsag` change `funktionChar` `functionChar` TEXT(1); + -- -------------------------------------------------------- --