diff --git a/hbd b/hbd index 82edd7d..36621d0 100755 --- a/hbd +++ b/hbd @@ -22,6 +22,7 @@ import urllib.request, urllib.parse, urllib.error import urllib.parse import http.client import threading +import subprocess from hashlib import md5 import json import zlib @@ -206,6 +207,8 @@ def pushmsg(msg): pushover(msg) if pushsrv in ["all","mattermost"]: pushmattermost(msg) + if pushsrv in ["all","signal"]: + pushsignal(msg) if pushsrv in ["all"]: print("notice:", msg) @@ -254,6 +257,32 @@ def pushmattermost(msg): if not rc: print(rc) +USER = "+16472472447" +RECIPIENT = "+14168226179" + +def pushsignal(msg, title="hbd", recipient=RECIPIENT): + + message = f'"{title}: {msg}"' + CLI = [ + "/usr/bin/ssh", "andreas@w02", + "/usr/local/bin/signal-cli", "-u", USER, + "send", "-m", message, +# "-g", GROUP, + recipient, + ] + + if verbose: print(f"DBG cli: {CLI}") + res = subprocess.run(CLI, shell=False, capture_output=True) + rc = res.returncode == 0 + print(res.stdout.decode()) + + if not rc: + print(f"signalcli failed: {res.stderr.decode()}") + else: + if verbose: print(f"signalcli msg sent, res {res.stdout.decode()}") + return rc + + # nsupdate: set the DNS A record for a fqdn # return: None if ok, else error text def nsupdate(hostname, newip, dyndomain):