Skip to content

Add SOCKS5 proxy support for Telegram API requests via .env#5

Merged
mrvasil merged 1 commit into
mainfrom
copilot/add-socks5-proxy-support
Apr 13, 2026
Merged

Add SOCKS5 proxy support for Telegram API requests via .env#5
mrvasil merged 1 commit into
mainfrom
copilot/add-socks5-proxy-support

Conversation

Copilot AI commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Routes all Telegram API requests through a configurable SOCKS5 proxy, useful when the host network blocks direct Telegram access.

Changes

  • bot.py — reads SOCKS5_PROXY_URL from env, sets telebot.apihelper.proxy before bot init; no-op if unset
  • .env.example — adds SOCKS5_PROXY_URL with usage example
  • requirements.txt — adds requests[socks] (PySocks) for SOCKS5 transport

Usage

# With auth
SOCKS5_PROXY_URL=******123.45.67.89:1080

# Without auth
SOCKS5_PROXY_URL=socks5://123.45.67.89:1080

@mrvasil mrvasil marked this pull request as ready for review April 13, 2026 11:10
Copilot AI review requested due to automatic review settings April 13, 2026 11:10
@mrvasil mrvasil merged commit 048c889 into main Apr 13, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.proxy from SOCKS5_PROXY_URL before 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.

Comment thread .env.example
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

Copilot AI Apr 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants