-
Notifications
You must be signed in to change notification settings - Fork 0
Working Behind a Proxy
Hinrich Mahler edited this page Feb 20, 2020
·
20 revisions
PTB will obtain its proxy configuration in the following order (the first to be found will be used):
- Programmatic.
- Using
HTTPS_PROXY
environment variable. - Using
https_proxy
environment variable.
# Make sure to import required function
TOKEN='YOUR_BOT_TOKEN'
REQUEST_KWARGS={
# "USERNAME:PASSWORD@" is optional, if you need authentication:
'proxy_url': 'http://USERNAME:PASSWORD@PROXY_HOST:PROXY_PORT/',
}
updater = Updater(TOKEN, request_kwargs=REQUEST_KWARGS)
This is configuration is supported, but requires an optional/extra python package. To install:
pip install python-telegram-bot[socks]
TOKEN='YOUR_BOT_TOKEN'
REQUEST_KWARGS={
'proxy_url': 'socks5 OR socks5h://URL_OF_THE_PROXY_SERVER:PROXY_PORT',
# Optional, if you need authentication:
'urllib3_proxy_kwargs': {
'username': 'PROXY_USER',
'password': 'PROXY_PASS',
}
}
updater = Updater(TOKEN, request_kwargs=REQUEST_KWARGS)
- Wiki of
python-telegram-bot
© Copyright 2015-2025 – Licensed by Creative Commons
- Architecture Overview
- Builder Pattern for
Application
- Types of Handlers
- Working with Files and Media
- Exceptions, Warnings and Logging
- Concurrency in PTB
- Advanced Filters
- Storing data
- Making your bot persistent
- Adding Defaults
- Job Queue
- Arbitrary
callback_data
- Avoiding flood limits
- Webhooks
- Bot API Forward Compatiblity
- Frequently requested design patterns
- Code snippets
- Performance Optimizations
- Telegram Passport
- Bots built with PTB
- Automated Bot Tests