diff --git a/docs/config.json.md b/docs/config.json.md index f8a22f2..9023720 100644 --- a/docs/config.json.md +++ b/docs/config.json.md @@ -4,4 +4,8 @@ - `name` : Personal Name - `email` : Personal Mail - `secret_key` : Secret Key for Flask -- `xmr_address` : Monero Receive Address \ No newline at end of file +- `xmr_address` : Monero Receive Address +- `notify` : Notification Object +- - `gotify`: Gotify Object +- - - `token` : Gotify Token +- - - `host` : Gotify Host/Domain name \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index a62cfdd..eb2547c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ Flask gnupg +requests git+https://github.com/jmarya/htmlpy#egg=htmlpy \ No newline at end of file diff --git a/src/index.py b/src/index.py index 21374ff..6fdb30e 100644 --- a/src/index.py +++ b/src/index.py @@ -4,6 +4,7 @@ from config import CONFIG from os.path import exists import os import datetime +import requests import gnupg main_pages = Blueprint("main", __name__) @@ -38,6 +39,22 @@ def save_message(msg, name=""): f.write(msg) +def notify(msg, title=None): + try: + gotify_notification(msg, title) + except: + pass + + +def gotify_notification(msg, title=None): + token = CONFIG["notify"]["gotify"]["token"] + url = CONFIG["notify"]["gotify"]["host"] + requests.post( + f"https://{url}/message?token={token}", + {"title": title, "message": msg, "priority": "5"}, + ) + + # Message Sending Page @main_pages.route("/message", methods=["GET", "POST"]) def send_message(): @@ -48,6 +65,7 @@ def send_message(): if msg is not None: cipher = encrypt(msg) save_message(cipher, name) + notify(f"New Message from {name}") return redirect(request.url_root.replace("http", "https")) else: # Return Message Form