RequestData¶
final class telegram.request.RequestData(parameters=None)[source]¶Bases: object
Instances of this class collect the data needed for one request to the Bot API, including all parameters and files to be sent along with the request.
Added in version 20.0.
Warning
How exactly instances of this are created should be considered an implementation detail and not part of PTBs public API. Users should exclusively rely on the documented attributes, properties and methods.
Whether this object contains files to be uploaded via multipart/form-data.
Type: property json_parameters[source]¶Gives the parameters as mapping of parameter name to the respective JSON encoded value.
Tip
By default, this property uses the standard library’s json.dumps(). To use a custom library for JSON encoding, you can directly encode the keys of parameters - note that string valued keys should not be JSON encoded.
The parameters as UTF-8 encoded JSON payload.
Tip
By default, this property uses the standard library’s json.dumps(). To use a custom library for JSON encoding, you can directly encode the keys of parameters - note that string valued keys should not be JSON encoded.
Gives the files contained in this object as mapping of part name to encoded content.
Changed in version 21.5: Content may now be a file handle.
Gives the parameters as mapping of parameter name to the parameter value, which can be a single object of type int, float, str or bool or any (possibly nested) composition of lists, tuples and dictionaries, where each entry, key and value is of one of the mentioned types.
Returns:dict[str, str | int | list[any] | dict[any, any]]
parametrized_url(url, encode_kwargs=None)[source]¶Shortcut for attaching the return value of url_encoded_parameters() to the url.
Parameters:encode_kwargs (dict[str, any], optional) – Additional keyword arguments to pass along to urllib.parse.urlencode().
Encodes the parameters with urllib.parse.urlencode().
Parameters:encode_kwargs (dict[str, any], optional) – Additional keyword arguments to pass along to urllib.parse.urlencode().
Returns: