From 636abbd606b80ea0b681cd581dbaae81b0436553 Mon Sep 17 00:00:00 2001 From: neko Date: Mon, 27 Jan 2025 12:20:03 +0500 Subject: [PATCH] Add config.py functionality to load api_id, api_hash and bot_token --- .gitignore | 2 ++ Dockerfile | 4 ++-- README.md | 2 ++ config.py.example | 3 +++ main.py | 19 +++++++++---------- 5 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 config.py.example diff --git a/.gitignore b/.gitignore index 2d92d52..e6350ac 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ *.session-journal downalods/* output/* +config.py +__pycache__ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4540abe..10e01ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,6 @@ RUN apk add --no-cache --virtual temporary python3-dev py3-pip gcc libc-dev && p WORKDIR /2pdf COPY main.py /2pdf/ -COPY 2pdf.session /2pdf/ +COPY config.py /2pdf/ -CMD ["python", "main.py"] \ No newline at end of file +CMD ["python", "main.py"] diff --git a/README.md b/README.md index 2490fd6..d224198 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ The unoserver dependency is entirely optional - however it improves theoretical ```console git clone https://git.darkn.space/neko/tg2pdf.git cd tg2pdf +cp config.py.example config.py +nano config.py podman build -t tg2pdf . podman run --name tg2pdf -d tg2pdf:latest ``` diff --git a/config.py.example b/config.py.example new file mode 100644 index 0000000..5890efe --- /dev/null +++ b/config.py.example @@ -0,0 +1,3 @@ +API_ID = "" +API_HASH = "" +BOT_TOKEN = "" \ No newline at end of file diff --git a/main.py b/main.py index 2d788d2..6be5203 100644 --- a/main.py +++ b/main.py @@ -6,16 +6,15 @@ from pathlib import Path import shutil import time -# api_id = -#api_hash = "" -#bot_token = "" -# app = Client( -# "2pdf", -# api_id=api_id, api_hash=api_hash, -# bot_token=bot_token -# ) - -app = Client("2pdf") +import config # import settings from config.py +api_id = config.API_ID +api_hash = config.API_HASH +bot_token = config.BOT_TOKEN +app = Client( + "2pdf", + api_id=api_id, api_hash=api_hash, + bot_token=bot_token +) def validDocument(mime_type): valid_mime_types = [