Add SOCKS5 proxy support for Telegram API requests via .env#5
Merged
Conversation
Agent-Logs-Url: https://github.com/zagip/zagipon_bot/sessions/f16381ec-4714-469b-a950-3504139e9326 Co-authored-by: mrvasil <107036801+mrvasil@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
mrvasil
April 13, 2026 11:09
View session
There was a problem hiding this comment.
Pull request overview
Adds optional SOCKS5 proxy support so Telegram API traffic can be routed through a proxy when direct Telegram access is blocked (configured via SOCKS5_PROXY_URL in the environment).
Changes:
- Configure
telebot.apihelper.proxyfromSOCKS5_PROXY_URLbefore bot initialization (no-op when unset). - Add
requests[socks]dependency to enable SOCKS proxy support via PySocks. - Document the new environment variable in
.env.example.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
requirements.txt |
Adds SOCKS-enabled requests extra for proxy transport. |
bot.py |
Reads SOCKS5_PROXY_URL and applies it to telebot API helper proxy settings. |
.env.example |
Documents the new optional proxy configuration variable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| GROUP_ID=asd | ||
| CHANNEL_ID=asd No newline at end of file | ||
| CHANNEL_ID=asd | ||
| # Optional SOCKS5 proxy for Telegram API requests, e.g. socks5://user:pass@host:port |
There was a problem hiding this comment.
Given the PR’s goal (working around networks that may block Telegram), consider documenting socks5h:// here instead of socks5://. In requests/PySocks, socks5h proxies DNS resolution through the proxy, which is often required when local DNS to Telegram is blocked.
Suggested change
| # Optional SOCKS5 proxy for Telegram API requests, e.g. socks5://user:pass@host:port | |
| # Optional SOCKS5 proxy for Telegram API requests, e.g. socks5h://user:pass@host:port |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Routes all Telegram API requests through a configurable SOCKS5 proxy, useful when the host network blocks direct Telegram access.
Changes
bot.py— readsSOCKS5_PROXY_URLfrom env, setstelebot.apihelper.proxybefore bot init; no-op if unset.env.example— addsSOCKS5_PROXY_URLwith usage examplerequirements.txt— addsrequests[socks](PySocks) for SOCKS5 transportUsage