41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
from dotenv import load_dotenv
|
|
import os
|
|
|
|
def main():
|
|
load_dotenv() # Load environment variables from .env file
|
|
ntfy_username = os.getenv('ntfy_username')
|
|
ntfy_password = os.getenv('ntfy_password')
|
|
ntfy_host = os.getenv('ntfy_host')
|
|
ntfy_topic = os.getenv('ntfy_topic')
|
|
dc_webhook = os.getenv('dc_webhook')
|
|
dc_botname = os.getenv('dc_botname')
|
|
dc_avatar_url = os.getenv('dc_avatar_url')
|
|
|
|
from argparse import ArgumentParser
|
|
import apprise
|
|
|
|
parser = ArgumentParser()
|
|
parser.add_argument("--title")
|
|
parser.add_argument("--body")
|
|
parser.add_argument("--click")
|
|
args = parser.parse_args()
|
|
print(args)
|
|
|
|
apobj = apprise.Apprise()
|
|
# config = apprise.AppriseConfig()
|
|
# config.add('https://myserver:8080/path/to/config')
|
|
if ntfy_host and ntfy_topic:
|
|
ntfy_link = f"ntfys://{ntfy_username}:{ntfy_password}@{ntfy_host}/{ntfy_topic}"
|
|
if args.click:
|
|
ntfy_link = ntfy_link + "?click=" + args.click
|
|
apobj.add(ntfy_link)
|
|
if dc_webhook:
|
|
apobj.add(f"discord://{dc_webhook}?avatar_url={dc_avatar_url}&botname={dc_botname}");
|
|
|
|
apobj.notify(
|
|
body=args.body,
|
|
title=args.title
|
|
)
|
|
|
|
if __name__ == '__main__':
|
|
main() |