#!/usr/bin/python3 import json import sys import os import requests USER = "log-discord" def push_notification(user, message): url = os.environ['CALL_LOGGER_DISCORD'] data = { "user": user, "content": message, } resp = requests.post(url=url, json=data, ) try: resp.raise_for_status() except requests.exceptions.HTTPError as err: print(err) if __name__ == '__main__': if len(sys.argv) < 2: print("Script requires a parameter") else: doc=json.loads(sys.argv[1]) msg="{} [{}] {} - {}".format(doc["ts"], doc["level"], doc["module_path"], doc["msg"]) push_notification(USER, msg)