From 9a50fc7cf4b2e7504cee32d24da634f75880a955 Mon Sep 17 00:00:00 2001 From: jblu Date: Fri, 12 May 2023 10:36:28 -0500 Subject: [PATCH] wrapper function for apprise --- .gitignore | 2 ++ Apprise-Client.py | 15 +++++++++++++++ config.toml.example | 6 ++++++ 3 files changed, 23 insertions(+) create mode 100644 Apprise-Client.py create mode 100644 config.toml.example diff --git a/.gitignore b/.gitignore index 5d381cc..bb746ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*.toml + # ---> Python # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/Apprise-Client.py b/Apprise-Client.py new file mode 100644 index 0000000..b052103 --- /dev/null +++ b/Apprise-Client.py @@ -0,0 +1,15 @@ +import requests as r +from tomllib import load + +config_file_path = './config.toml' +with open(config_file_path, 'rb') as c: + config = load(c) + +def apprise_notify(req_obj, host, port, aurls, title, body): + payload = {'urls': aurls,'title': title,'body': body,} + url = f'http://{host}:{port}/notify/' + apprise_response = req_obj.post(url, json = payload ,verify=False) + return apprise_response + +a = apprise_notify(r,config["apprise"]["host"],config["apprise"]["port"],config["apprise"]["aurls"],\ + config["apprise"]["title"],config["apprise"]["body"]) \ No newline at end of file diff --git a/config.toml.example b/config.toml.example new file mode 100644 index 0000000..12dfeed --- /dev/null +++ b/config.toml.example @@ -0,0 +1,6 @@ +[apprise] +host = "192.168.x.x" +port = 8088 +aurls = 'mailto://user:pass@gmail.com' +title = 'test title' +body = 'test body' \ No newline at end of file