docker version - #12
Conversation
Reviewer's GuideAdds a Dockerized entrypoint script for the Telegram self‑destruct media saver, plus Dockerfile and docker‑compose setup to run it with persisted session data and environment‑driven configuration. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- Accessing TG_API_ID and TG_API_HASH at module import time will raise a raw KeyError if the variables are missing; consider validating these values in main() and emitting a clear, user-friendly error instead.
- There are several broad
except Exceptionblocks around core logic (authentication, chat handling, album processing) that only log the error string; narrowing these or at least logging more context (e.g. chat/message identifiers) would make debugging production issues much easier. - When scheduling album flush tasks you use
asyncio.ensure_futurein Python 3.11; switching toasyncio.create_taskand keeping the task management in a small helper would align better with modern asyncio patterns and simplify cancellation handling.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Accessing TG_API_ID and TG_API_HASH at module import time will raise a raw KeyError if the variables are missing; consider validating these values in main() and emitting a clear, user-friendly error instead.
- There are several broad `except Exception` blocks around core logic (authentication, chat handling, album processing) that only log the error string; narrowing these or at least logging more context (e.g. chat/message identifiers) would make debugging production issues much easier.
- When scheduling album flush tasks you use `asyncio.ensure_future` in Python 3.11; switching to `asyncio.create_task` and keeping the task management in a small helper would align better with modern asyncio patterns and simplify cancellation handling.
## Individual Comments
### Comment 1
<location path="SecPhoto-docker.py" line_range="121" />
<code_context>
+ print(f"Deleted: {f}")
+ except Exception as err:
+ print(f"Could not delete {f}: {err}")
+ client = TelegramClient(client.session.filename, api_id, api_hash)
+ await client.connect()
+ else:
</code_context>
<issue_to_address>
**issue (bug_risk):** Proxy configuration is lost when recreating the TelegramClient after a locked DB error.
In the recovery path you recreate `TelegramClient` without reapplying the original SOCKS5 proxy settings, which changes behavior in proxied environments and can break connectivity. Please persist the proxy configuration from the initial client (e.g., store it in a variable) and reuse it when reconstructing the client here.
</issue_to_address>
### Comment 2
<location path="docker-compose.yml" line_range="2-3" />
<code_context>
+services:
+ telegram-bot:
+ image: secphoto:latest
+ stdin_open: true # docker run -i
+ tty: true # docker run -t
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Compose file relies on a pre-built image but doesn’t define a build context.
Because `telegram-bot` only specifies `image: secphoto:latest` and no `build:` section, `docker compose up` will fail unless that image is already built and tagged locally. If you intend to build from the local Dockerfile, add a `build: .` directive (and optionally adjust or remove `image:`) so the service can be started directly via Compose.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| print(f"Deleted: {f}") | ||
| except Exception as err: | ||
| print(f"Could not delete {f}: {err}") | ||
| client = TelegramClient(client.session.filename, api_id, api_hash) |
There was a problem hiding this comment.
issue (bug_risk): Proxy configuration is lost when recreating the TelegramClient after a locked DB error.
In the recovery path you recreate TelegramClient without reapplying the original SOCKS5 proxy settings, which changes behavior in proxied environments and can break connectivity. Please persist the proxy configuration from the initial client (e.g., store it in a variable) and reuse it when reconstructing the client here.
| telegram-bot: | ||
| image: secphoto:latest |
There was a problem hiding this comment.
suggestion (bug_risk): Compose file relies on a pre-built image but doesn’t define a build context.
Because telegram-bot only specifies image: secphoto:latest and no build: section, docker compose up will fail unless that image is already built and tagged locally. If you intend to build from the local Dockerfile, add a build: . directive (and optionally adjust or remove image:) so the service can be started directly via Compose.
Hi,
wanted to run this in my docker, so here is a docker image + everything needed to build etc
Best regards
Summary by Sourcery
Add a Dockerized entrypoint script and container setup for running the Telegram self‑destructive media saver as a service.
New Features:
Build:
Documentation: