Skip to content

Commit bf3a5a9

Browse files
committed
feat: telegram bot proxy
1 parent 6d8bc74 commit bf3a5a9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

bot_handler.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,17 @@ def start_bot(self):
166166

167167
# Build bot
168168
telegram_config = self.config.get("telegram")
169-
builder = ApplicationBuilder().token(telegram_config.get("api_key"))
169+
proxy = telegram_config.get("proxy")
170+
if proxy:
171+
logging.info(f"Using proxy {proxy} for Telegram bot")
172+
builder = (
173+
ApplicationBuilder()
174+
.token(telegram_config.get("api_key"))
175+
.proxy(proxy)
176+
.get_updates_proxy(proxy)
177+
)
178+
else:
179+
builder = ApplicationBuilder().token(telegram_config.get("api_key"))
170180
self._application = builder.build()
171181

172182
# Set commands

config.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@
116116
"command": "chatid",
117117
"description": "🆔 Show your chat_id"
118118
}
119-
]
119+
],
120+
121+
"__comment15__": "If needed, specify proxy in http://ip:port format (specify http even if it's https proxy)",
122+
"__comment16__": "Use http://username:password@ip:port format in case of proxy with authorization",
123+
"proxy": ""
120124
},
121125

122126
"__comment07__": "Save all requests and responses to the files",

0 commit comments

Comments
 (0)