From 66802ee759567c319badee585b2822bd1f56ee15 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Apr 2026 11:04:57 +0000 Subject: [PATCH] feat: route Telegram API requests through SOCKS5 proxy via .env 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> --- .env.example | 4 +++- bot.py | 7 ++++++- requirements.txt | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index cdb864b..47f61e3 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,5 @@ API_TOKEN=asd 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 +SOCKS5_PROXY_URL= \ No newline at end of file diff --git a/bot.py b/bot.py index 5f22e87..f530425 100644 --- a/bot.py +++ b/bot.py @@ -1,5 +1,5 @@ import telebot -from telebot import types +from telebot import types, apihelper import json from datetime import datetime import os @@ -16,6 +16,11 @@ API_TOKEN = os.getenv('API_TOKEN') GROUP_ID = int(os.getenv('GROUP_ID')) CHANNEL_ID = int(os.getenv('CHANNEL_ID')) + +socks5_proxy_url = os.getenv('SOCKS5_PROXY_URL') +if socks5_proxy_url: + apihelper.proxy = {'https': socks5_proxy_url} + bot = telebot.TeleBot(API_TOKEN) my_id = bot.get_me().id diff --git a/requirements.txt b/requirements.txt index 5125ffe..f9be3bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ pyTelegramBotAPI flask flask_sqlalchemy -python-dotenv \ No newline at end of file +python-dotenv +requests[socks] \ No newline at end of file