telegram.utils.request.Request¶
-
class
telegram.utils.request.
Request
(con_pool_size: int = 1, proxy_url: str = None, urllib3_proxy_kwargs: Dict[str, Any] = None, connect_timeout: float = 5.0, read_timeout: float = 5.0)¶ Bases:
object
Helper 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.Bot
methods. (default: 5.)
-
con_pool_size
¶ The size of the connection pool used.
-
download
(url: str, filename: str, timeout: 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: 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.
- url (
-
retrieve
(url: str, timeout: 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).
- url (