telegram.utils.request.Request¶
-
class
telegram.utils.request.Request(con_pool_size: int = 1, proxy_url: Optional[str] = None, urllib3_proxy_kwargs: Optional[Dict[str, Any]] = None, connect_timeout: float = 5.0, read_timeout: float = 5.0)¶ Bases:
objectHelper class for python-telegram-bot which provides methods to perform POST & GET towards telegram servers.
- Parameters
con_pool_size (int) – Number of connections to keep in the connection pool.
proxy_url (str) – The URL to the proxy server. For example: http://127.0.0.1:3128.
urllib3_proxy_kwargs (dict) – Arbitrary arguments passed as-is to urllib3.ProxyManager. This value will be ignored if proxy_url is not set.
connect_timeout (int|float) – The maximum amount of time (in seconds) to wait for a connection attempt to a server to succeed. None will set an infinite timeout for connection attempts. (default: 5.)
read_timeout (int|float) – The maximum amount of time (in seconds) to wait between consecutive read operations for a response from the server. None will set an infinite timeout. This value is usually overridden by the various
telegram.Botmethods. (default: 5.)
-
property
con_pool_size¶ The size of the connection pool used.
-
download(url: str, filename: str, timeout: Optional[float] = None) → None¶ Download a file by its URL.
- Parameters
url (str) – The web location we want to retrieve.
timeout (
int|float) – If this value is specified, use it as the read timeout from the server (instead of the one specified during creation of the connection pool).filename (
str) – The filename within the path to download the file.
-
post(url: str, data: Dict[str, Any], timeout: Optional[float] = None) → Union[Dict[str, Any], bool]¶ Request an URL.
- Parameters
url (
str) – The web location we want to retrieve.data (dict[str, str|int], optional) – A dict of key/value pairs.
timeout (
int|float, optional) – If this value is specified, use it as the read timeout from the server (instead of the one specified during creation of the connection pool).
- Returns
A JSON object.
-
retrieve(url: str, timeout: Optional[float] = None) → bytes¶ Retrieve the contents of a file by its URL.
- Parameters
url (
str) – The web location we want to retrieve.timeout (
int|float) – If this value is specified, use it as the read timeout from the server (instead of the one specified during creation of the connection pool).