nvd commited on
Update bot.py
Browse files
bot.py
CHANGED
|
@@ -8,7 +8,7 @@ import aiohttp
|
|
| 8 |
import httpx
|
| 9 |
import logging
|
| 10 |
import tempfile
|
| 11 |
-
import
|
| 12 |
from urllib.parse import unquote
|
| 13 |
|
| 14 |
# ---------- Logging ----------
|
|
@@ -185,16 +185,15 @@ async def download_file(url, dest_path):
|
|
| 185 |
f.write(chunk)
|
| 186 |
logger.info(f"✅ Downloaded file to {dest_path}")
|
| 187 |
|
| 188 |
-
# ---------- APK → password‑protected ZIP ----------
|
| 189 |
def create_password_zip(apk_path, zip_path, password="bale"):
|
| 190 |
"""
|
| 191 |
Creates a password‑protected ZIP archive containing the APK.
|
| 192 |
-
Uses
|
| 193 |
"""
|
| 194 |
-
with
|
| 195 |
-
zf.setpassword(password.encode())
|
| 196 |
arcname = os.path.basename(apk_path)
|
| 197 |
-
zf.write(apk_path, arcname=arcname)
|
| 198 |
logger.info(f"🔐 Created password‑protected ZIP: {zip_path}")
|
| 199 |
|
| 200 |
# ---------- Message / Callback handlers ----------
|
|
|
|
| 8 |
import httpx
|
| 9 |
import logging
|
| 10 |
import tempfile
|
| 11 |
+
import zipfile
|
| 12 |
from urllib.parse import unquote
|
| 13 |
|
| 14 |
# ---------- Logging ----------
|
|
|
|
| 185 |
f.write(chunk)
|
| 186 |
logger.info(f"✅ Downloaded file to {dest_path}")
|
| 187 |
|
| 188 |
+
# ---------- APK → password‑protected ZIP (standard library) ----------
|
| 189 |
def create_password_zip(apk_path, zip_path, password="bale"):
|
| 190 |
"""
|
| 191 |
Creates a password‑protected ZIP archive containing the APK.
|
| 192 |
+
Uses built‑in zipfile (ZipCrypto encryption).
|
| 193 |
"""
|
| 194 |
+
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:
|
|
|
|
| 195 |
arcname = os.path.basename(apk_path)
|
| 196 |
+
zf.write(apk_path, arcname=arcname, pwd=password.encode())
|
| 197 |
logger.info(f"🔐 Created password‑protected ZIP: {zip_path}")
|
| 198 |
|
| 199 |
# ---------- Message / Callback handlers ----------
|