ass ginal as msg carrier

This commit is contained in:
2021-06-07 11:28:35 -04:00
parent a74e3f6d04
commit 13b009d6e0
+29
View File
@@ -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):