Skip to content

Commit

Permalink
feat: telegram bot proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
F33RNI committed Apr 19, 2024
1 parent 6d8bc74 commit bf3a5a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 11 additions & 1 deletion bot_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,17 @@ def start_bot(self):

# Build bot
telegram_config = self.config.get("telegram")
builder = ApplicationBuilder().token(telegram_config.get("api_key"))
proxy = telegram_config.get("proxy")
if proxy:
logging.info(f"Using proxy {proxy} for Telegram bot")
builder = (
ApplicationBuilder()
.token(telegram_config.get("api_key"))
.proxy(proxy)
.get_updates_proxy(proxy)
)
else:
builder = ApplicationBuilder().token(telegram_config.get("api_key"))
self._application = builder.build()

# Set commands
Expand Down
6 changes: 5 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@
"command": "chatid",
"description": "🆔 Show your chat_id"
}
]
],

"__comment15__": "If needed, specify proxy in http://ip:port format (specify http even if it's https proxy)",
"__comment16__": "Use http://username:password@ip:port format in case of proxy with authorization",
"proxy": ""
},

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

0 comments on commit bf3a5a9

Please sign in to comment.