diff --git a/Dockerfile b/Dockerfile index 12c0164..06f59b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,12 @@ FROM debian:12 AS base WORKDIR /opt/app +ENV PYTHONPATH=/app RUN apt-get update && \ apt-get install -y curl unzip cron ca-certificates python3 python3-pip && \ rm -rf /var/lib/apt/lists/* # install BunJs RUN curl -fsSL https://bun.com/install | bash ENV PATH="/root/.bun/bin:$PATH" -# symlink python3 to python -RUN ln -s /usr/bin/python3 /usr/bin/python # install dependencies into temp directory # this will cache them and speed up future builds @@ -17,8 +16,8 @@ COPY package.json bun.lock /temp/dev/ RUN cd /temp/dev && bun install --frozen-lockfile # and install python dependencies COPY ./requirements.txt . -RUN pip3 install --break-system-packages -r ./requirements.txt - +RUN python3 -m pip install -r requirements.txt +# RUN python3 -m pip install -U python-dotenv # install with --production (exclude devDependencies) RUN mkdir -p /temp/prod COPY package.json bun.lock /temp/prod/ diff --git a/src/notification.py b/src/notification.py index cda75a9..13a3dfb 100644 --- a/src/notification.py +++ b/src/notification.py @@ -1,37 +1,41 @@ from dotenv import load_dotenv import os -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') +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 + 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) + 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 = 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 -) \ No newline at end of file + apobj.notify( + body=args.body, + title=args.title + ) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/src/sendNotification.ts b/src/sendNotification.ts index 3792745..639ff21 100644 --- a/src/sendNotification.ts +++ b/src/sendNotification.ts @@ -2,7 +2,7 @@ import * as Bun from "bun"; export async function sendNotification(title: string, body: string, click?: string | null) { const command = [ - "python", + "python3", "./src/notification.py", `--title=${title}`, `--body=${body}`,